Skip to content

Commit e1c0b69

Browse files
WaffleLapkinklensyRalfJung
committed
Apply suggestions from code review
Co-authored-by: klensy <klensy@users.noreply.github.com> Co-authored-by: Ralf Jung <post@ralfj.de>
1 parent 493b5fd commit e1c0b69

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

compiler/rustc_lint/src/implicit_unsafe_autorefs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ declare_lint! {
2323
///
2424
/// When working with raw pointers it's usually undesirable to create references,
2525
/// since they inflict a lot of safety requirement. Unfortunately, it's possible
26-
/// to take a reference to a dereferece of a raw pointer implitly, which inflicts
26+
/// to take a reference to a dereference of a raw pointer implicitly, which inflicts
2727
/// the usual reference requirements without you even knowing that.
2828
///
2929
/// If you are sure, you can soundly take a reference, then you can take it explicitly:
@@ -68,9 +68,9 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitUnsafeAutorefs {
6868
let msg = "implicit auto-ref creates a reference to a dereference of a raw pointer";
6969
cx.struct_span_lint(IMPLICIT_UNSAFE_AUTOREFS, expr.span, msg, |lint| {
7070
lint
71-
.note("creating a reference inflicts a lot of safety requirements")
71+
.note("creating a reference requires the pointer to be valid and imposes aliasing requirements")
7272
.multipart_suggestion(
73-
"if this reference is intentional, make it explicit",
73+
"try using a raw pointer method instead; or if this reference is intentional, make it explicit",
7474
vec![
7575
(expr.span.shrink_to_lo(), format!("(&{mutbl}")),
7676
(expr.span.shrink_to_hi(), ")".to_owned())

src/test/ui/lint/implicit_unsafe_autorefs.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
error: implicit auto-ref creates a reference to a dereference of a raw pointer
2-
--> $DIR/implicit_unsafe_autoref.rs:5:18
2+
--> $DIR/implicit_unsafe_autorefs.rs:5:18
33
|
44
LL | addr_of_mut!((*ptr)[..16])
55
| ^^^^^^
66
|
7-
= note: creating a reference inflicts a lot of safety requirements
7+
= note: creating a reference requires the pointer to be valid and imposes aliasing requirements
88
= note: `#[deny(implicit_unsafe_autorefs)]` on by default
9-
help: if this reference is intentional, make it explicit
9+
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
1010
|
1111
LL | addr_of_mut!((&mut (*ptr))[..16])
1212
| +++++ +
1313

1414
error: implicit auto-ref creates a reference to a dereference of a raw pointer
15-
--> $DIR/implicit_unsafe_autoref.rs:10:14
15+
--> $DIR/implicit_unsafe_autorefs.rs:10:14
1616
|
1717
LL | addr_of!((*ptr)[..16])
1818
| ^^^^^^
1919
|
20-
= note: creating a reference inflicts a lot of safety requirements
21-
help: if this reference is intentional, make it explicit
20+
= note: creating a reference requires the pointer to be valid and imposes aliasing requirements
21+
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
2222
|
2323
LL | addr_of!((&(*ptr))[..16])
2424
| ++ +

0 commit comments

Comments
 (0)