Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid_value lint: fix help text #66182

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
);
err.span_label(expr.span,
"this code causes undefined behavior when executed");
err.span_label(expr.span, "help: use `MaybeUninit<T>` instead");
err.span_label(expr.span, "help: use `MaybeUninit<T>` instead, \
and only call `assume_init` after initialization is done");
if let Some(span) = span {
err.span_note(span, &msg);
} else {
Expand Down
70 changes: 35 additions & 35 deletions src/test/ui/lint/uninitialized-zeroed.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let _val: &'static T = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: lint level defined here
--> $DIR/uninitialized-zeroed.rs:7:9
Expand All @@ -21,7 +21,7 @@ LL | let _val: &'static T = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: References must be non-null

Expand All @@ -32,7 +32,7 @@ LL | let _val: Wrap<&'static T> = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: References must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:18:18
Expand All @@ -47,7 +47,7 @@ LL | let _val: Wrap<&'static T> = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: References must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:18:18
Expand All @@ -62,7 +62,7 @@ LL | let _val: ! = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: The never type (`!`) has no valid value

Expand All @@ -73,7 +73,7 @@ LL | let _val: ! = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: The never type (`!`) has no valid value

Expand All @@ -84,7 +84,7 @@ LL | let _val: (i32, !) = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: The never type (`!`) has no valid value

Expand All @@ -95,7 +95,7 @@ LL | let _val: (i32, !) = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: The never type (`!`) has no valid value

Expand All @@ -106,7 +106,7 @@ LL | let _val: Void = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: 0-variant enums have no valid value

Expand All @@ -117,7 +117,7 @@ LL | let _val: Void = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: 0-variant enums have no valid value

Expand All @@ -128,7 +128,7 @@ LL | let _val: &'static i32 = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: References must be non-null

Expand All @@ -139,7 +139,7 @@ LL | let _val: &'static i32 = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: References must be non-null

Expand All @@ -150,7 +150,7 @@ LL | let _val: Ref = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: References must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:15:12
Expand All @@ -165,7 +165,7 @@ LL | let _val: Ref = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: References must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:15:12
Expand All @@ -180,7 +180,7 @@ LL | let _val: fn() = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: Function pointers must be non-null

Expand All @@ -191,7 +191,7 @@ LL | let _val: fn() = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: Function pointers must be non-null

Expand All @@ -202,7 +202,7 @@ LL | let _val: Wrap<fn()> = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: Function pointers must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:18:18
Expand All @@ -217,7 +217,7 @@ LL | let _val: Wrap<fn()> = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: Function pointers must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:18:18
Expand All @@ -232,7 +232,7 @@ LL | let _val: WrapEnum<fn()> = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: Function pointers must be non-null (in this enum field)
--> $DIR/uninitialized-zeroed.rs:19:28
Expand All @@ -247,7 +247,7 @@ LL | let _val: WrapEnum<fn()> = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: Function pointers must be non-null (in this enum field)
--> $DIR/uninitialized-zeroed.rs:19:28
Expand All @@ -262,7 +262,7 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: References must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:16:16
Expand All @@ -277,7 +277,7 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: References must be non-null (in this struct field)
--> $DIR/uninitialized-zeroed.rs:16:16
Expand All @@ -292,7 +292,7 @@ LL | let _val: NonNull<i32> = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: std::ptr::NonNull<i32> must be non-null

Expand All @@ -303,7 +303,7 @@ LL | let _val: NonNull<i32> = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: std::ptr::NonNull<i32> must be non-null

Expand All @@ -314,7 +314,7 @@ LL | let _val: *const dyn Send = mem::zeroed();
| ^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: The vtable of a wide raw pointer must be non-null

Expand All @@ -325,7 +325,7 @@ LL | let _val: *const dyn Send = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: The vtable of a wide raw pointer must be non-null

Expand All @@ -336,7 +336,7 @@ LL | let _val: bool = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: Booleans must be `true` or `false`

Expand All @@ -347,7 +347,7 @@ LL | let _val: Wrap<char> = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
note: Characters must be a valid unicode codepoint (in this struct field)
--> $DIR/uninitialized-zeroed.rs:18:18
Expand All @@ -362,7 +362,7 @@ LL | let _val: NonBig = mem::uninitialized();
| ^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: NonBig must be initialized inside its custom valid range

Expand All @@ -373,7 +373,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: References must be non-null

Expand All @@ -384,7 +384,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: References must be non-null

Expand All @@ -395,7 +395,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0);
| ^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: std::num::NonZeroU32 must be non-null

Expand All @@ -406,7 +406,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::zeroed().assume_init();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: std::ptr::NonNull<i32> must be non-null

Expand All @@ -417,7 +417,7 @@ LL | let _val: NonNull<i32> = MaybeUninit::uninit().assume_init();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: std::ptr::NonNull<i32> must be non-null

Expand All @@ -428,7 +428,7 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| this code causes undefined behavior when executed
| help: use `MaybeUninit<T>` instead
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
|
= note: Booleans must be `true` or `false`

Expand Down