Skip to content

Commit

Permalink
rename lint
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 25, 2020
1 parent 061773f commit d959a8f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
8 changes: 4 additions & 4 deletions src/librustc_mir/transform/check_packed_ref.rs
@@ -1,7 +1,7 @@
use rustc_middle::mir::visit::{PlaceContext, Visitor};
use rustc_middle::mir::*;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::lint::builtin::PACKED_REFERENCES;
use rustc_session::lint::builtin::UNALIGNED_REFERENCES;

use crate::transform::{MirPass, MirSource};
use crate::util;
Expand Down Expand Up @@ -47,13 +47,13 @@ impl<'a, 'tcx> Visitor<'tcx> for PackedRefChecker<'a, 'tcx> {
.assert_crate_local()
.lint_root;
self.tcx.struct_span_lint_hir(
PACKED_REFERENCES,
UNALIGNED_REFERENCES,
lint_root,
source_info.span,
|lint| {
lint.build(&format!("reference to packed field is not allowed",))
lint.build(&format!("reference to packed field is unaligned",))
.note(
"fields of packed structs might be misaligned, and creating \
"fields of packed structs are not properly aligned, and creating \
a misaligned reference is undefined behavior (even if that \
reference is never dereferenced)",
)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_session/lint/builtin.rs
Expand Up @@ -217,7 +217,7 @@ declare_lint! {
}

declare_lint! {
pub PACKED_REFERENCES,
pub UNALIGNED_REFERENCES,
Allow,
"detects unaligned references to fields of packed structs",
}
Expand Down Expand Up @@ -551,7 +551,7 @@ declare_lint_pass! {
INVALID_TYPE_PARAM_DEFAULT,
CONST_ERR,
RENAMED_AND_REMOVED_LINTS,
PACKED_REFERENCES,
UNALIGNED_REFERENCES,
SAFE_PACKED_BORROWS,
PATTERNS_IN_FNS_WITHOUT_BODY,
MISSING_FRAGMENT_SPECIFIER,
Expand Down
39 changes: 0 additions & 39 deletions src/test/ui/lint/packed_reference.stderr

This file was deleted.

@@ -1,4 +1,4 @@
#![deny(packed_references)]
#![deny(unaligned_references)]

#[repr(packed)]
pub struct Good {
Expand Down
39 changes: 39 additions & 0 deletions src/test/ui/lint/unaligned_references.stderr
@@ -0,0 +1,39 @@
error: reference to packed field is unaligned
--> $DIR/unaligned_references.rs:14:17
|
LL | let _ = &good.data;
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/unaligned_references.rs:1:9
|
LL | #![deny(unaligned_references)]
| ^^^^^^^^^^^^^^^^^^^^
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
--> $DIR/unaligned_references.rs:15:17
|
LL | let _ = &good.data as *const _;
| ^^^^^^^^^^
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
--> $DIR/unaligned_references.rs:16:27
|
LL | let _: *const _ = &good.data;
| ^^^^^^^^^^
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: reference to packed field is unaligned
--> $DIR/unaligned_references.rs:17:17
|
LL | let _ = &good.data2[0];
| ^^^^^^^^^^^^^^
|
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)

error: aborting due to 4 previous errors

0 comments on commit d959a8f

Please sign in to comment.