Skip to content

Commit d959a8f

Browse files
committed
rename lint
1 parent 061773f commit d959a8f

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

src/librustc_mir/transform/check_packed_ref.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_middle::mir::visit::{PlaceContext, Visitor};
22
use rustc_middle::mir::*;
33
use rustc_middle::ty::{self, TyCtxt};
4-
use rustc_session::lint::builtin::PACKED_REFERENCES;
4+
use rustc_session::lint::builtin::UNALIGNED_REFERENCES;
55

66
use crate::transform::{MirPass, MirSource};
77
use crate::util;
@@ -47,13 +47,13 @@ impl<'a, 'tcx> Visitor<'tcx> for PackedRefChecker<'a, 'tcx> {
4747
.assert_crate_local()
4848
.lint_root;
4949
self.tcx.struct_span_lint_hir(
50-
PACKED_REFERENCES,
50+
UNALIGNED_REFERENCES,
5151
lint_root,
5252
source_info.span,
5353
|lint| {
54-
lint.build(&format!("reference to packed field is not allowed",))
54+
lint.build(&format!("reference to packed field is unaligned",))
5555
.note(
56-
"fields of packed structs might be misaligned, and creating \
56+
"fields of packed structs are not properly aligned, and creating \
5757
a misaligned reference is undefined behavior (even if that \
5858
reference is never dereferenced)",
5959
)

src/librustc_session/lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ declare_lint! {
217217
}
218218

219219
declare_lint! {
220-
pub PACKED_REFERENCES,
220+
pub UNALIGNED_REFERENCES,
221221
Allow,
222222
"detects unaligned references to fields of packed structs",
223223
}
@@ -551,7 +551,7 @@ declare_lint_pass! {
551551
INVALID_TYPE_PARAM_DEFAULT,
552552
CONST_ERR,
553553
RENAMED_AND_REMOVED_LINTS,
554-
PACKED_REFERENCES,
554+
UNALIGNED_REFERENCES,
555555
SAFE_PACKED_BORROWS,
556556
PATTERNS_IN_FNS_WITHOUT_BODY,
557557
MISSING_FRAGMENT_SPECIFIER,

src/test/ui/lint/packed_reference.stderr

-39
This file was deleted.

src/test/ui/lint/packed_reference.rs renamed to src/test/ui/lint/unaligned_references.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(packed_references)]
1+
#![deny(unaligned_references)]
22

33
#[repr(packed)]
44
pub struct Good {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error: reference to packed field is unaligned
2+
--> $DIR/unaligned_references.rs:14:17
3+
|
4+
LL | let _ = &good.data;
5+
| ^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/unaligned_references.rs:1:9
9+
|
10+
LL | #![deny(unaligned_references)]
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
13+
14+
error: reference to packed field is unaligned
15+
--> $DIR/unaligned_references.rs:15:17
16+
|
17+
LL | let _ = &good.data as *const _;
18+
| ^^^^^^^^^^
19+
|
20+
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
21+
22+
error: reference to packed field is unaligned
23+
--> $DIR/unaligned_references.rs:16:27
24+
|
25+
LL | let _: *const _ = &good.data;
26+
| ^^^^^^^^^^
27+
|
28+
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
29+
30+
error: reference to packed field is unaligned
31+
--> $DIR/unaligned_references.rs:17:17
32+
|
33+
LL | let _ = &good.data2[0];
34+
| ^^^^^^^^^^^^^^
35+
|
36+
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
37+
38+
error: aborting due to 4 previous errors
39+

0 commit comments

Comments
 (0)