From f77c183aa6821e646cbea45f385a0860fb3674a2 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 6 Mar 2023 13:57:20 +0000 Subject: [PATCH] Report all lints, even if other errors already occurred. This reduces surprises of the "I fixed all the errors, now I'm getting new ones"-kind --- compiler/rustc_interface/src/passes.rs | 9 -- .../borrowck/borrowck-access-permissions.rs | 37 ++++++--- .../borrowck-access-permissions.stderr | 20 ++--- .../borrowck/borrowck-assign-to-constants.rs | 4 +- .../borrowck-assign-to-constants.stderr | 4 +- tests/ui/borrowck/issue-64453.rs | 4 +- tests/ui/borrowck/issue-64453.stderr | 10 +-- tests/ui/cleanup-rvalue-scopes-cf.rs | 24 +++--- tests/ui/cleanup-rvalue-scopes-cf.stderr | 56 ++++++------- .../closures/issue-82438-mut-without-upvar.rs | 13 ++- .../issue-82438-mut-without-upvar.stderr | 4 +- .../const-extern-fn-min-const-fn.rs | 23 +++-- .../const-extern-fn-min-const-fn.stderr | 33 ++++++-- .../ui/consts/const-fn-not-safe-for-const.rs | 4 +- .../consts/const-mut-refs/mut_ref_in_final.rs | 8 +- .../const-mut-refs/mut_ref_in_final.stderr | 24 ++++-- tests/ui/consts/const-pattern-irrefutable.rs | 2 + .../consts/const-pattern-irrefutable.stderr | 6 +- tests/ui/consts/const-suggest-feature.rs | 1 + tests/ui/consts/const-suggest-feature.stderr | 10 ++- .../issue-17718-const-bad-values.32bit.stderr | 37 +++++++++ .../issue-17718-const-bad-values.64bit.stderr | 37 +++++++++ .../ui/consts/issue-17718-const-bad-values.rs | 3 + .../issue-17718-const-bad-values.stderr | 26 ------ tests/ui/consts/issue-32829-2.rs | 19 ++--- tests/ui/consts/issue-66693.rs | 6 ++ tests/ui/consts/issue-66693.stderr | 79 ++++++++++++++++-- tests/ui/consts/mir_check_nonconst.rs | 2 +- tests/ui/consts/mir_check_nonconst.stderr | 2 +- .../qualif-indirect-mutation-fail.stderr | 39 ++++++++- tests/ui/dst/dst-index.rs | 6 +- tests/ui/error-codes/E0017.32bit.stderr | 83 +++++++++++++++++++ tests/ui/error-codes/E0017.64bit.stderr | 83 +++++++++++++++++++ tests/ui/error-codes/E0017.rs | 14 +++- .../{E0017.stderr => E0388.32bit.stderr} | 35 ++++---- .../{E0388.stderr => E0388.64bit.stderr} | 35 +++++--- tests/ui/error-codes/E0388.rs | 12 ++- tests/ui/extern/issue-28324.mir.stderr | 11 ++- tests/ui/extern/issue-28324.rs | 1 + tests/ui/extern/issue-28324.thir.stderr | 11 ++- ...te-non_exhaustive_omitted_patterns_lint.rs | 8 +- ...on_exhaustive_omitted_patterns_lint.stderr | 67 ++++++++++++--- tests/ui/intrinsics/issue-28575.mir.stderr | 14 +++- tests/ui/intrinsics/issue-28575.rs | 1 + tests/ui/intrinsics/issue-28575.thir.stderr | 14 +++- tests/ui/issues/issue-11681.rs | 11 ++- tests/ui/issues/issue-11681.stderr | 10 +-- tests/ui/issues/issue-13497-2.rs | 8 +- tests/ui/issues/issue-13497-2.stderr | 13 +-- tests/ui/issues/issue-16538.mir.stderr | 8 +- tests/ui/issues/issue-16538.rs | 4 +- tests/ui/issues/issue-16538.thir.stderr | 8 +- tests/ui/issues/issue-46604.rs | 8 +- tests/ui/issues/issue-46604.stderr | 10 +-- ...6158-scalarpair-payload-might-be-uninit.rs | 2 +- tests/ui/pattern/usefulness/guards.rs | 19 +++-- tests/ui/pattern/usefulness/guards.stderr | 4 +- tests/ui/pattern/usefulness/issue-50900.rs | 6 +- .../ui/pattern/usefulness/issue-50900.stderr | 6 +- ...range-pattern-out-of-bounds-issue-68972.rs | 2 + ...e-pattern-out-of-bounds-issue-68972.stderr | 21 ++++- .../regions-infer-proc-static-upvar.rs | 12 +-- .../regions-infer-proc-static-upvar.stderr | 2 +- ...ions-lifetime-of-struct-or-enum-variant.rs | 23 ++--- ...-lifetime-of-struct-or-enum-variant.stderr | 20 ++--- .../const-closure-trait-method-fail.stderr | 23 ++++- .../const-drop-fail.precise.stderr | 57 ++++++++++++- .../const-drop-fail.stock.stderr | 57 ++++++++++++- .../safe-calls.mir.stderr | 2 +- .../rfc-2396-target_feature-11/safe-calls.rs | 2 +- .../safe-calls.thir.stderr | 2 +- tests/ui/rfcs/rfc1623-2.rs | 4 +- tests/ui/span/issue-25199.rs | 18 ++-- tests/ui/span/issue-25199.stderr | 22 ++++- tests/ui/static/issue-18118-2.rs | 6 +- tests/ui/static/issue-18118-2.stderr | 2 +- tests/ui/static/issue-18118.rs | 2 +- tests/ui/static/static-mut-not-constant.rs | 2 +- .../ui/static/static-mut-not-constant.stderr | 2 +- .../static-mut-requires-unsafe.mir.stderr | 6 +- tests/ui/static/static-mut-requires-unsafe.rs | 8 +- .../static-mut-requires-unsafe.thir.stderr | 6 +- .../static/static-vec-repeat-not-constant.rs | 6 +- .../static-vec-repeat-not-constant.stderr | 4 +- tests/ui/statics/issue-14227.mir.stderr | 11 ++- tests/ui/statics/issue-14227.rs | 1 + tests/ui/statics/issue-14227.thir.stderr | 11 ++- .../trivial-bounds-leak-copy.rs | 6 +- .../trivial-bounds-leak-copy.stderr | 12 ++- .../uninhabited-matches-feature-gated.rs | 14 +++- .../uninhabited-matches-feature-gated.stderr | 73 ++++++++++++++-- 91 files changed, 1122 insertions(+), 375 deletions(-) create mode 100644 tests/ui/consts/issue-17718-const-bad-values.32bit.stderr create mode 100644 tests/ui/consts/issue-17718-const-bad-values.64bit.stderr delete mode 100644 tests/ui/consts/issue-17718-const-bad-values.stderr create mode 100644 tests/ui/error-codes/E0017.32bit.stderr create mode 100644 tests/ui/error-codes/E0017.64bit.stderr rename tests/ui/error-codes/{E0017.stderr => E0388.32bit.stderr} (67%) rename tests/ui/error-codes/{E0388.stderr => E0388.64bit.stderr} (64%) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 48401eabd1ed1..ad374f1a952f1 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -790,15 +790,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { sess.time("layout_testing", || layout_test::test_layout(tcx)); - // Avoid overwhelming user with errors if borrow checking failed. - // I'm not sure how helpful this is, to be honest, but it avoids a - // lot of annoying errors in the ui tests (basically, - // lint warnings and so on -- kindck used to do this abort, but - // kindck is gone now). -nmatsakis - if let Some(reported) = sess.has_errors() { - return Err(reported); - } - sess.time("misc_checking_3", || { parallel!( { diff --git a/tests/ui/borrowck/borrowck-access-permissions.rs b/tests/ui/borrowck/borrowck-access-permissions.rs index 469ad508b0e77..4cc6b60c677ea 100644 --- a/tests/ui/borrowck/borrowck-access-permissions.rs +++ b/tests/ui/borrowck/borrowck-access-permissions.rs @@ -1,21 +1,26 @@ -static static_x : i32 = 1; -static mut static_x_mut : i32 = 1; +static STATIC_X: i32 = 1; +static mut STATIC_X_MUT: i32 = 1; fn main() { let x = 1; let mut x_mut = 1; - { // borrow of local + { + // borrow of local let _y1 = &mut x; //~ ERROR [E0596] let _y2 = &mut x_mut; // No error } - { // borrow of static - let _y1 = &mut static_x; //~ ERROR [E0596] - unsafe { let _y2 = &mut static_x_mut; } // No error + { + // borrow of static + let _y1 = &mut STATIC_X; //~ ERROR [E0596] + unsafe { + let _y2 = &mut STATIC_X_MUT; + } // No error } - { // borrow of deref to box + { + // borrow of deref to box let box_x = Box::new(1); let mut box_x_mut = Box::new(1); @@ -23,7 +28,8 @@ fn main() { let _y2 = &mut *box_x_mut; // No error } - { // borrow of deref to reference + { + // borrow of deref to reference let ref_x = &x; let ref_x_mut = &mut x_mut; @@ -31,9 +37,10 @@ fn main() { let _y2 = &mut *ref_x_mut; // No error } - { // borrow of deref to pointer - let ptr_x : *const _ = &x; - let ptr_mut_x : *mut _ = &mut x_mut; + { + // borrow of deref to pointer + let ptr_x: *const _ = &x; + let ptr_mut_x: *mut _ = &mut x_mut; unsafe { let _y1 = &mut *ptr_x; //~ ERROR [E0596] @@ -41,8 +48,12 @@ fn main() { } } - { // borrowing mutably through an immutable reference - struct Foo<'a> { f: &'a mut i32, g: &'a i32 }; + { + // borrowing mutably through an immutable reference + struct Foo<'a> { + f: &'a mut i32, + g: &'a i32, + }; let mut foo = Foo { f: &mut x_mut, g: &x }; let foo_ref = &foo; let _y = &mut *foo_ref.f; //~ ERROR [E0596] diff --git a/tests/ui/borrowck/borrowck-access-permissions.stderr b/tests/ui/borrowck/borrowck-access-permissions.stderr index c161e2d95b43a..1072ab4c20c92 100644 --- a/tests/ui/borrowck/borrowck-access-permissions.stderr +++ b/tests/ui/borrowck/borrowck-access-permissions.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:9:19 + --> $DIR/borrowck-access-permissions.rs:10:19 | LL | let _y1 = &mut x; | ^^^^^^ cannot borrow as mutable @@ -9,14 +9,14 @@ help: consider changing this to be mutable LL | let mut x = 1; | +++ -error[E0596]: cannot borrow immutable static item `static_x` as mutable - --> $DIR/borrowck-access-permissions.rs:14:19 +error[E0596]: cannot borrow immutable static item `STATIC_X` as mutable + --> $DIR/borrowck-access-permissions.rs:16:19 | -LL | let _y1 = &mut static_x; +LL | let _y1 = &mut STATIC_X; | ^^^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:22:19 + --> $DIR/borrowck-access-permissions.rs:27:19 | LL | let _y1 = &mut *box_x; | ^^^^^^^^^^^ cannot borrow as mutable @@ -27,7 +27,7 @@ LL | let mut box_x = Box::new(1); | +++ error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:30:19 + --> $DIR/borrowck-access-permissions.rs:36:19 | LL | let _y1 = &mut *ref_x; | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable @@ -38,18 +38,18 @@ LL | let ref_x = &mut x; | +++ error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer - --> $DIR/borrowck-access-permissions.rs:39:23 + --> $DIR/borrowck-access-permissions.rs:46:23 | LL | let _y1 = &mut *ptr_x; | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable | help: consider changing this to be a mutable pointer | -LL | let ptr_x : *const _ = &mut x; - | +++ +LL | let ptr_x: *const _ = &mut x; + | +++ error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:48:18 + --> $DIR/borrowck-access-permissions.rs:59:18 | LL | let _y = &mut *foo_ref.f; | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/borrowck-assign-to-constants.rs b/tests/ui/borrowck/borrowck-assign-to-constants.rs index 5881dccf61ab3..fbeb7792b6233 100644 --- a/tests/ui/borrowck/borrowck-assign-to-constants.rs +++ b/tests/ui/borrowck/borrowck-assign-to-constants.rs @@ -1,6 +1,6 @@ -static foo: isize = 5; +static FOO: isize = 5; fn main() { // assigning to various global constants - foo = 6; //~ ERROR cannot assign to immutable static item `foo` + FOO = 6; //~ ERROR cannot assign to immutable static item `FOO` } diff --git a/tests/ui/borrowck/borrowck-assign-to-constants.stderr b/tests/ui/borrowck/borrowck-assign-to-constants.stderr index 864d933da127f..49b95250406ca 100644 --- a/tests/ui/borrowck/borrowck-assign-to-constants.stderr +++ b/tests/ui/borrowck/borrowck-assign-to-constants.stderr @@ -1,7 +1,7 @@ -error[E0594]: cannot assign to immutable static item `foo` +error[E0594]: cannot assign to immutable static item `FOO` --> $DIR/borrowck-assign-to-constants.rs:5:5 | -LL | foo = 6; +LL | FOO = 6; | ^^^^^^^ cannot assign error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-64453.rs b/tests/ui/borrowck/issue-64453.rs index 33d55be5812e7..1673d118d85bc 100644 --- a/tests/ui/borrowck/issue-64453.rs +++ b/tests/ui/borrowck/issue-64453.rs @@ -1,7 +1,7 @@ struct Project; struct Value; -static settings_dir: String = format!(""); +static SETTINGS_DIR: String = format!(""); //~^ ERROR cannot call non-const fn //~| ERROR is not yet stable as a const @@ -11,7 +11,7 @@ fn from_string(_: String) -> Value { fn set_editor(_: Value) {} fn main() { - let settings_data = from_string(settings_dir); + let settings_data = from_string(SETTINGS_DIR); //~^ ERROR cannot move out of static item let args: i32 = 0; diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index f032ea779dd48..dd3877845b3b0 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -1,7 +1,7 @@ error: `Arguments::<'a>::new_const` is not yet stable as a const fn --> $DIR/issue-64453.rs:4:31 | -LL | static settings_dir: String = format!(""); +LL | static SETTINGS_DIR: String = format!(""); | ^^^^^^^^^^^ | = help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable @@ -10,18 +10,18 @@ LL | static settings_dir: String = format!(""); error[E0015]: cannot call non-const fn `format` in statics --> $DIR/issue-64453.rs:4:31 | -LL | static settings_dir: String = format!(""); +LL | static SETTINGS_DIR: String = format!(""); | ^^^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0507]: cannot move out of static item `settings_dir` +error[E0507]: cannot move out of static item `SETTINGS_DIR` --> $DIR/issue-64453.rs:14:37 | -LL | let settings_data = from_string(settings_dir); - | ^^^^^^^^^^^^ move occurs because `settings_dir` has type `String`, which does not implement the `Copy` trait +LL | let settings_data = from_string(SETTINGS_DIR); + | ^^^^^^^^^^^^ move occurs because `SETTINGS_DIR` has type `String`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/tests/ui/cleanup-rvalue-scopes-cf.rs b/tests/ui/cleanup-rvalue-scopes-cf.rs index e3cecb1bffed6..c242498e6b1b5 100644 --- a/tests/ui/cleanup-rvalue-scopes-cf.rs +++ b/tests/ui/cleanup-rvalue-scopes-cf.rs @@ -5,10 +5,14 @@ use std::ops::Drop; static mut FLAGS: u64 = 0; -struct StackBox { f: T } -struct AddFlags { bits: u64 } +struct StackBox { + f: T, +} +struct AddFlags { + bits: u64, +} -fn AddFlags(bits: u64) -> AddFlags { +fn add_flags(bits: u64) -> AddFlags { AddFlags { bits: bits } } @@ -23,13 +27,13 @@ impl AddFlags { } pub fn main() { - let x1 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed - let x2 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed - let x3 = &*arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed - let ref x4 = *arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed - let &ref x5 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed - let x6 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed - let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; + let x1 = arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed + let x2 = add_flags(1).get(); //~ ERROR temporary value dropped while borrowed + let x3 = &*arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed + let ref x4 = *arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed + let &ref x5 = arg(&add_flags(1)); //~ ERROR temporary value dropped while borrowed + let x6 = add_flags(1).get(); //~ ERROR temporary value dropped while borrowed + let StackBox { f: x7 } = StackBox { f: add_flags(1).get() }; //~^ ERROR temporary value dropped while borrowed (x1, x2, x3, x4, x5, x6, x7); } diff --git a/tests/ui/cleanup-rvalue-scopes-cf.stderr b/tests/ui/cleanup-rvalue-scopes-cf.stderr index 425cd75141cec..d27685a53a600 100644 --- a/tests/ui/cleanup-rvalue-scopes-cf.stderr +++ b/tests/ui/cleanup-rvalue-scopes-cf.stderr @@ -1,8 +1,8 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:26:19 + --> $DIR/cleanup-rvalue-scopes-cf.rs:30:19 | -LL | let x1 = arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let x1 = arg(&add_flags(1)); + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use ... @@ -11,15 +11,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let x1 = arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:27:14 + --> $DIR/cleanup-rvalue-scopes-cf.rs:31:14 | -LL | let x2 = AddFlags(1).get(); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let x2 = add_flags(1).get(); + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use ... @@ -28,15 +28,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let x2 = binding.get(); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:28:21 + --> $DIR/cleanup-rvalue-scopes-cf.rs:32:21 | -LL | let x3 = &*arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let x3 = &*arg(&add_flags(1)); + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use ... @@ -45,15 +45,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let x3 = &*arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:29:24 + --> $DIR/cleanup-rvalue-scopes-cf.rs:33:24 | -LL | let ref x4 = *arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let ref x4 = *arg(&add_flags(1)); + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use ... @@ -62,15 +62,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let ref x4 = *arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:30:24 + --> $DIR/cleanup-rvalue-scopes-cf.rs:34:24 | -LL | let &ref x5 = arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let &ref x5 = arg(&add_flags(1)); + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use ... @@ -79,15 +79,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let &ref x5 = arg(&binding); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:31:14 + --> $DIR/cleanup-rvalue-scopes-cf.rs:35:14 | -LL | let x6 = AddFlags(1).get(); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let x6 = add_flags(1).get(); + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use ... @@ -96,15 +96,15 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let x6 = binding.get(); | error[E0716]: temporary value dropped while borrowed - --> $DIR/cleanup-rvalue-scopes-cf.rs:32:44 + --> $DIR/cleanup-rvalue-scopes-cf.rs:36:44 | -LL | let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement +LL | let StackBox { f: x7 } = StackBox { f: add_flags(1).get() }; + | ^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | | creates a temporary value which is freed while still in use LL | @@ -113,7 +113,7 @@ LL | (x1, x2, x3, x4, x5, x6, x7); | help: consider using a `let` binding to create a longer lived value | -LL ~ let binding = AddFlags(1); +LL ~ let binding = add_flags(1); LL ~ let StackBox { f: x7 } = StackBox { f: binding.get() }; | diff --git a/tests/ui/closures/issue-82438-mut-without-upvar.rs b/tests/ui/closures/issue-82438-mut-without-upvar.rs index 5d88e1e77d450..ff97660b30048 100644 --- a/tests/ui/closures/issue-82438-mut-without-upvar.rs +++ b/tests/ui/closures/issue-82438-mut-without-upvar.rs @@ -1,28 +1,25 @@ use std::error::Error; -struct A { -} +struct A {} impl A { pub fn new() -> A { - A { - } + A {} } pub fn f<'a>( &'a self, team_name: &'a str, - c: &'a mut dyn FnMut(String, String, u64, u64) + c: &'a mut dyn FnMut(String, String, u64, u64), ) -> Result<(), Box> { Ok(()) } } - fn main() { - let A = A::new(); + let a = A::new(); let participant_name = "A"; let c = |a, b, c, d| {}; - A.f(participant_name, &mut c); //~ ERROR cannot borrow + a.f(participant_name, &mut c); //~ ERROR cannot borrow } diff --git a/tests/ui/closures/issue-82438-mut-without-upvar.stderr b/tests/ui/closures/issue-82438-mut-without-upvar.stderr index f0951b7d10873..88d4c32838e72 100644 --- a/tests/ui/closures/issue-82438-mut-without-upvar.stderr +++ b/tests/ui/closures/issue-82438-mut-without-upvar.stderr @@ -1,7 +1,7 @@ error[E0596]: cannot borrow `c` as mutable, as it is not declared as mutable - --> $DIR/issue-82438-mut-without-upvar.rs:27:27 + --> $DIR/issue-82438-mut-without-upvar.rs:24:27 | -LL | A.f(participant_name, &mut c); +LL | a.f(participant_name, &mut c); | ^^^^^^ cannot borrow as mutable | help: consider changing this to be mutable diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs index c7078e46fa64f..95aecf10b0084 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs @@ -1,11 +1,20 @@ #![feature(const_extern_fn)] -const extern "C" fn unsize(x: &[u8; 3]) -> &[u8] { x } -const unsafe extern "C" fn closure() -> fn() { || {} } -const unsafe extern "C" fn use_float() { 1.0 + 1.0; } -//~^ ERROR floating point arithmetic -const extern "C" fn ptr_cast(val: *const u8) { val as usize; } -//~^ ERROR pointers cannot be cast to integers - +const extern "C" fn unsize(x: &[u8; 3]) -> &[u8] { + //~^ WARN: not FFI-safe + x +} +const unsafe extern "C" fn closure() -> fn() { + //~^ WARN: not FFI-safe + || {} +} +const unsafe extern "C" fn use_float() { + 1.0 + 1.0; + //~^ ERROR floating point arithmetic +} +const extern "C" fn ptr_cast(val: *const u8) { + val as usize; + //~^ ERROR pointers cannot be cast to integers +} fn main() {} diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr index 4bab466fb95a7..f8d72a75f1382 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr @@ -1,21 +1,40 @@ error[E0658]: floating point arithmetic is not allowed in constant functions - --> $DIR/const-extern-fn-min-const-fn.rs:5:42 + --> $DIR/const-extern-fn-min-const-fn.rs:12:5 | -LL | const unsafe extern "C" fn use_float() { 1.0 + 1.0; } - | ^^^^^^^^^ +LL | 1.0 + 1.0; + | ^^^^^^^^^ | = note: see issue #57241 for more information = help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable error: pointers cannot be cast to integers during const eval - --> $DIR/const-extern-fn-min-const-fn.rs:7:48 + --> $DIR/const-extern-fn-min-const-fn.rs:16:5 | -LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; } - | ^^^^^^^^^^^^ +LL | val as usize; + | ^^^^^^^^^^^^ | = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior -error: aborting due to 2 previous errors +warning: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/const-extern-fn-min-const-fn.rs:3:44 + | +LL | const extern "C" fn unsize(x: &[u8; 3]) -> &[u8] { + | ^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + = note: `#[warn(improper_ctypes_definitions)]` on by default + +warning: `extern` fn uses type `fn()`, which is not FFI-safe + --> $DIR/const-extern-fn-min-const-fn.rs:7:41 + | +LL | const unsafe extern "C" fn closure() -> fn() { + | ^^^^ not FFI-safe + | + = help: consider using an `extern fn(...) -> ...` function pointer instead + = note: this function pointer has Rust-specific calling convention + +error: aborting due to 2 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-fn-not-safe-for-const.rs b/tests/ui/consts/const-fn-not-safe-for-const.rs index b2fe73ae9302c..b330c3e3f47a4 100644 --- a/tests/ui/consts/const-fn-not-safe-for-const.rs +++ b/tests/ui/consts/const-fn-not-safe-for-const.rs @@ -16,12 +16,12 @@ const fn sub1() -> u32 { static Y: u32 = 0; -const fn get_Y() -> u32 { +const fn get_y() -> u32 { Y //~^ ERROR E0013 } -const fn get_Y_addr() -> &'static u32 { +const fn get_y_addr() -> &'static u32 { &Y //~^ ERROR E0013 } diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs index a7d329f125be4..0be5f054d14ef 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -8,6 +8,7 @@ const A: *const i32 = &4; // but we do not want to allow this to compile, // as that would be an enormous footgun in oli-obk's opinion. const B: *mut i32 = &mut 4; //~ ERROR mutable references are not allowed +//~^ ERROR: untyped pointers are not allowed // Ok, no actual mutable allocation exists const B2: Option<&mut i32> = None; @@ -15,12 +16,13 @@ const B2: Option<&mut i32> = None; // Not ok, can't prove that no mutable allocation ends up in final value const B3: Option<&mut i32> = Some(&mut 42); //~ ERROR temporary value dropped while borrowed -const fn helper(x: &mut i32) -> Option<&mut i32> { Some(x) } +const fn helper(x: &mut i32) -> Option<&mut i32> { + Some(x) +} const B4: Option<&mut i32> = helper(&mut 42); //~ ERROR temporary value dropped while borrowed -// Ok, because no references to mutable data exist here, since the `{}` moves -// its value and then takes a reference to that. const C: *const i32 = &{ + //~^ ERROR: untyped pointers are not allowed let mut x = 42; x += 3; x diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 78c58b5ab092b..319a20d6d13e7 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -5,7 +5,7 @@ LL | const B: *mut i32 = &mut 4; | ^^^^^^ error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:16:40 + --> $DIR/mut_ref_in_final.rs:17:40 | LL | const B3: Option<&mut i32> = Some(&mut 42); | ----------^^- @@ -15,7 +15,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:19:42 + --> $DIR/mut_ref_in_final.rs:22:42 | LL | const B4: Option<&mut i32> = helper(&mut 42); | ------------^^- @@ -25,7 +25,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:34:65 + --> $DIR/mut_ref_in_final.rs:36:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -35,7 +35,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:37:67 + --> $DIR/mut_ref_in_final.rs:39:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -45,7 +45,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:40:71 + --> $DIR/mut_ref_in_final.rs:42:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -54,7 +54,19 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | | creates a temporary value which is freed while still in use | using this value as a static requires that borrow lasts for `'static` -error: aborting due to 6 previous errors +error: untyped pointers are not allowed in constant + --> $DIR/mut_ref_in_final.rs:10:1 + | +LL | const B: *mut i32 = &mut 4; + | ^^^^^^^^^^^^^^^^^ + +error: untyped pointers are not allowed in constant + --> $DIR/mut_ref_in_final.rs:24:1 + | +LL | const C: *const i32 = &{ + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors Some errors have detailed explanations: E0716, E0764. For more information about an error, try `rustc --explain E0716`. diff --git a/tests/ui/consts/const-pattern-irrefutable.rs b/tests/ui/consts/const-pattern-irrefutable.rs index 61bdf57ffdb94..46f9c7f1881a5 100644 --- a/tests/ui/consts/const-pattern-irrefutable.rs +++ b/tests/ui/consts/const-pattern-irrefutable.rs @@ -1,3 +1,5 @@ +#![allow(non_upper_case_globals)] + mod foo { pub const b: u8 = 2; pub const d: u8 = 2; diff --git a/tests/ui/consts/const-pattern-irrefutable.stderr b/tests/ui/consts/const-pattern-irrefutable.stderr index 2aed68bdd6433..f084dd4b1ed1b 100644 --- a/tests/ui/consts/const-pattern-irrefutable.stderr +++ b/tests/ui/consts/const-pattern-irrefutable.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:12:9 + --> $DIR/const-pattern-irrefutable.rs:14:9 | LL | let a = 4; | ^ @@ -13,7 +13,7 @@ LL | let a = 4; = note: the matched value is of type `u8` error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:17:9 + --> $DIR/const-pattern-irrefutable.rs:19:9 | LL | let c = 4; | ^ @@ -27,7 +27,7 @@ LL | let c = 4; = note: the matched value is of type `u8` error[E0005]: refutable pattern in local binding - --> $DIR/const-pattern-irrefutable.rs:22:9 + --> $DIR/const-pattern-irrefutable.rs:24:9 | LL | let d = 4; | ^ diff --git a/tests/ui/consts/const-suggest-feature.rs b/tests/ui/consts/const-suggest-feature.rs index d76d01a3d5ed8..c0fa1062b25d2 100644 --- a/tests/ui/consts/const-suggest-feature.rs +++ b/tests/ui/consts/const-suggest-feature.rs @@ -2,6 +2,7 @@ const WRITE: () = unsafe { *std::ptr::null_mut() = 0; //~^ ERROR dereferencing raw mutable pointers in constants is unstable //~| HELP add `#![feature(const_mut_refs)]` to the crate attributes to enable + //~| WARN: dereferencing a null pointer }; fn main() {} diff --git a/tests/ui/consts/const-suggest-feature.stderr b/tests/ui/consts/const-suggest-feature.stderr index 3bc1eacf32f96..dd55b06dd4af1 100644 --- a/tests/ui/consts/const-suggest-feature.stderr +++ b/tests/ui/consts/const-suggest-feature.stderr @@ -7,6 +7,14 @@ LL | *std::ptr::null_mut() = 0; = note: see issue #57349 for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error: aborting due to previous error +warning: dereferencing a null pointer + --> $DIR/const-suggest-feature.rs:2:5 + | +LL | *std::ptr::null_mut() = 0; + | ^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed + | + = note: `#[warn(deref_nullptr)]` on by default + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/issue-17718-const-bad-values.32bit.stderr b/tests/ui/consts/issue-17718-const-bad-values.32bit.stderr new file mode 100644 index 0000000000000..3ead043d9c67e --- /dev/null +++ b/tests/ui/consts/issue-17718-const-bad-values.32bit.stderr @@ -0,0 +1,37 @@ +error[E0764]: mutable references are not allowed in the final value of constants + --> $DIR/issue-17718-const-bad-values.rs:3:34 + | +LL | const C1: &'static mut [usize] = &mut []; + | ^^^^^^^ + +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-const-bad-values.rs:8:46 + | +LL | const C2: &'static mut usize = unsafe { &mut S }; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-const-bad-values.rs:8:46 + | +LL | const C2: &'static mut usize = unsafe { &mut S }; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error[E0080]: it is undefined behavior to use this value + --> $DIR/issue-17718-const-bad-values.rs:3:1 + | +LL | const C1: &'static mut [usize] = &mut []; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 4) { + ╾─alloc4──╼ 00 00 00 00 │ ╾──╼.... + } + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0013, E0080, E0764. +For more information about an error, try `rustc --explain E0013`. diff --git a/tests/ui/consts/issue-17718-const-bad-values.64bit.stderr b/tests/ui/consts/issue-17718-const-bad-values.64bit.stderr new file mode 100644 index 0000000000000..7e4b99156eefc --- /dev/null +++ b/tests/ui/consts/issue-17718-const-bad-values.64bit.stderr @@ -0,0 +1,37 @@ +error[E0764]: mutable references are not allowed in the final value of constants + --> $DIR/issue-17718-const-bad-values.rs:3:34 + | +LL | const C1: &'static mut [usize] = &mut []; + | ^^^^^^^ + +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-const-bad-values.rs:8:46 + | +LL | const C2: &'static mut usize = unsafe { &mut S }; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error[E0013]: constants cannot refer to statics + --> $DIR/issue-17718-const-bad-values.rs:8:46 + | +LL | const C2: &'static mut usize = unsafe { &mut S }; + | ^ + | + = help: consider extracting the value of the `static` to a `const`, and referring to that + +error[E0080]: it is undefined behavior to use this value + --> $DIR/issue-17718-const-bad-values.rs:3:1 + | +LL | const C1: &'static mut [usize] = &mut []; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 16, align: 8) { + ╾───────alloc4────────╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ + } + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0013, E0080, E0764. +For more information about an error, try `rustc --explain E0013`. diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index 62bbb3b569c37..e3491ba7f795b 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -1,5 +1,8 @@ +// stderr-per-bitwidth + const C1: &'static mut [usize] = &mut []; //~^ ERROR: mutable references are not allowed +//~| ERROR: it is undefined behavior static mut S: usize = 3; const C2: &'static mut usize = unsafe { &mut S }; diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr deleted file mode 100644 index ce60aaa0797f8..0000000000000 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/issue-17718-const-bad-values.rs:1:34 - | -LL | const C1: &'static mut [usize] = &mut []; - | ^^^^^^^ - -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-const-bad-values.rs:5:46 - | -LL | const C2: &'static mut usize = unsafe { &mut S }; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-const-bad-values.rs:5:46 - | -LL | const C2: &'static mut usize = unsafe { &mut S }; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0013, E0764. -For more information about an error, try `rustc --explain E0013`. diff --git a/tests/ui/consts/issue-32829-2.rs b/tests/ui/consts/issue-32829-2.rs index d70b5a8c4e13a..502505baea8ab 100644 --- a/tests/ui/consts/issue-32829-2.rs +++ b/tests/ui/consts/issue-32829-2.rs @@ -1,11 +1,11 @@ -const bad : u32 = { +const BAD: u32 = { { 5; 0 } }; -const bad_two : u32 = { +const BAD2: u32 = { { invalid(); //~^ ERROR: cannot call non-const fn `invalid` @@ -13,21 +13,21 @@ const bad_two : u32 = { } }; -const bad_three : u32 = { +const BAD3: u32 = { { valid(); 0 } }; -static bad_four : u32 = { +static BAD4: u32 = { { 5; 0 } }; -static bad_five : u32 = { +static BAD5: u32 = { { invalid(); //~^ ERROR: cannot call non-const fn `invalid` @@ -35,21 +35,21 @@ static bad_five : u32 = { } }; -static bad_six : u32 = { +static BAD6: u32 = { { valid(); 0 } }; -static mut bad_seven : u32 = { +static mut BAD7: u32 = { { 5; 0 } }; -static mut bad_eight : u32 = { +static mut BAD8: u32 = { { invalid(); //~^ ERROR: cannot call non-const fn `invalid` @@ -57,14 +57,13 @@ static mut bad_eight : u32 = { } }; -static mut bad_nine : u32 = { +static mut BAD9: u32 = { { valid(); 0 } }; - fn invalid() {} const fn valid() {} diff --git a/tests/ui/consts/issue-66693.rs b/tests/ui/consts/issue-66693.rs index df45d01ec0299..0cf39894cf35a 100644 --- a/tests/ui/consts/issue-66693.rs +++ b/tests/ui/consts/issue-66693.rs @@ -3,18 +3,24 @@ const _: () = panic!(1); //~^ ERROR: argument to `panic!()` in a const context must have type `&str` +//~| WARN: panic message is not a string literal static _FOO: () = panic!(true); //~^ ERROR: argument to `panic!()` in a const context must have type `&str` +//~| WARN: panic message is not a string literal const fn _foo() { panic!(&1); //~^ ERROR: argument to `panic!()` in a const context must have type `&str` + //~| WARN: panic message is not a string literal } // ensure that conforming panics don't cause an error +// beyond the expected failure due to the panic itself const _: () = panic!(); +//~^ ERROR: evaluation of constant value failed static _BAR: () = panic!("panic in static"); +//~^ ERROR: could not evaluate static initializer const fn _bar() { panic!("panic in const fn"); diff --git a/tests/ui/consts/issue-66693.stderr b/tests/ui/consts/issue-66693.stderr index e9a3fced61cc1..bf0fd758363f0 100644 --- a/tests/ui/consts/issue-66693.stderr +++ b/tests/ui/consts/issue-66693.stderr @@ -7,7 +7,7 @@ LL | const _: () = panic!(1); = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: argument to `panic!()` in a const context must have type `&str` - --> $DIR/issue-66693.rs:7:19 + --> $DIR/issue-66693.rs:8:19 | LL | static _FOO: () = panic!(true); | ^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | static _FOO: () = panic!(true); = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: argument to `panic!()` in a const context must have type `&str` - --> $DIR/issue-66693.rs:11:5 + --> $DIR/issue-66693.rs:13:5 | LL | panic!(&1); | ^^^^^^^^^^ @@ -23,16 +23,85 @@ LL | panic!(&1); = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used - --> $DIR/issue-66693.rs:11:12 + --> $DIR/issue-66693.rs:13:12 | LL | panic!(&1); | ^^ note: erroneous constant used - --> $DIR/issue-66693.rs:11:12 + --> $DIR/issue-66693.rs:13:12 | LL | panic!(&1); | ^^ -error: aborting due to 3 previous errors +warning: panic message is not a string literal + --> $DIR/issue-66693.rs:4:22 + | +LL | const _: () = panic!(1); + | ^ + | + = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: `#[warn(non_fmt_panics)]` on by default +help: add a "{}" format string to `Display` the message + | +LL | const _: () = panic!("{}", 1); + | +++++ +help: or use std::panic::panic_any instead + | +LL | const _: () = std::panic::panic_any(1); + | ~~~~~~~~~~~~~~~~~~~~~ + +warning: panic message is not a string literal + --> $DIR/issue-66693.rs:8:26 + | +LL | static _FOO: () = panic!(true); + | ^^^^ + | + = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see +help: add a "{}" format string to `Display` the message + | +LL | static _FOO: () = panic!("{}", true); + | +++++ +help: or use std::panic::panic_any instead + | +LL | static _FOO: () = std::panic::panic_any(true); + | ~~~~~~~~~~~~~~~~~~~~~ + +warning: panic message is not a string literal + --> $DIR/issue-66693.rs:13:12 + | +LL | panic!(&1); + | ^^ + | + = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see +help: add a "{}" format string to `Display` the message + | +LL | panic!("{}", &1); + | +++++ +help: or use std::panic::panic_any instead + | +LL | std::panic::panic_any(&1); + | ~~~~~~~~~~~~~~~~~~~~~ + +error[E0080]: evaluation of constant value failed + --> $DIR/issue-66693.rs:20:15 + | +LL | const _: () = panic!(); + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693.rs:20:15 + | + = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0080]: could not evaluate static initializer + --> $DIR/issue-66693.rs:22:19 + | +LL | static _BAR: () = panic!("panic in static"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'panic in static', $DIR/issue-66693.rs:22:19 + | + = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors; 3 warnings emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/mir_check_nonconst.rs b/tests/ui/consts/mir_check_nonconst.rs index b6f34b922fae5..4b483f552a772 100644 --- a/tests/ui/consts/mir_check_nonconst.rs +++ b/tests/ui/consts/mir_check_nonconst.rs @@ -5,7 +5,7 @@ fn bar() -> Foo { Foo { a: 5 } } -static foo: Foo = bar(); +static FOO: Foo = bar(); //~^ ERROR cannot call non-const fn fn main() {} diff --git a/tests/ui/consts/mir_check_nonconst.stderr b/tests/ui/consts/mir_check_nonconst.stderr index 1e0652722ff2d..db2a5f0ea33da 100644 --- a/tests/ui/consts/mir_check_nonconst.stderr +++ b/tests/ui/consts/mir_check_nonconst.stderr @@ -1,7 +1,7 @@ error[E0015]: cannot call non-const fn `bar` in statics --> $DIR/mir_check_nonconst.rs:8:19 | -LL | static foo: Foo = bar(); +LL | static FOO: Foo = bar(); | ^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index 6379c00e4b434..f17e439e80551 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -52,6 +52,41 @@ error[E0493]: destructor of `Option` cannot be evaluated at compile-time LL | let x: Option = None; | ^ the destructor for this type cannot be evaluated in constant functions -error: aborting due to 9 previous errors +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function ` as Drop>::drop` + | +note: inside `std::ptr::drop_in_place::> - shim(Some(Vec))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place:: - shim(Some(String))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place::> - shim(Some(Option))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `A1` + --> $DIR/qualif-indirect-mutation-fail.rs:21:1 + | +LL | }; + | ^ + +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function ` as Drop>::drop` + | +note: inside `std::ptr::drop_in_place::> - shim(Some(Vec))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place:: - shim(Some(String))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place::> - shim(Some(Option))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `A2` + --> $DIR/qualif-indirect-mutation-fail.rs:32:1 + | +LL | }; + | ^ + +error: aborting due to 11 previous errors -For more information about this error, try `rustc --explain E0493`. +Some errors have detailed explanations: E0080, E0493. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/dst/dst-index.rs b/tests/ui/dst/dst-index.rs index 2f2c5df462699..2cc27450a83ec 100644 --- a/tests/ui/dst/dst-index.rs +++ b/tests/ui/dst/dst-index.rs @@ -1,8 +1,8 @@ // Test that overloaded index expressions with DST result types // can't be used as rvalues -use std::ops::Index; use std::fmt::Debug; +use std::ops::Index; #[derive(Copy, Clone)] struct S; @@ -22,8 +22,8 @@ impl Index for T { type Output = dyn Debug + 'static; fn index<'a>(&'a self, idx: usize) -> &'a (dyn Debug + 'static) { - static x: usize = 42; - &x + static X: usize = 42; + &X } } diff --git a/tests/ui/error-codes/E0017.32bit.stderr b/tests/ui/error-codes/E0017.32bit.stderr new file mode 100644 index 0000000000000..21ee85a1834c2 --- /dev/null +++ b/tests/ui/error-codes/E0017.32bit.stderr @@ -0,0 +1,83 @@ +warning: taking a mutable reference to a `const` item + --> $DIR/E0017.rs:7:30 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^ + | + = note: each usage of a `const` item creates a new temporary + = note: the mutable reference will refer to this temporary, not the original `const` item +note: `const` item defined here + --> $DIR/E0017.rs:4:1 + | +LL | const C: i32 = 2; + | ^^^^^^^^^^^^ + = note: `#[warn(const_item_mutation)]` on by default + +error[E0764]: mutable references are not allowed in the final value of constants + --> $DIR/E0017.rs:7:30 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^ + +error[E0658]: mutation through a reference is not allowed in statics + --> $DIR/E0017.rs:11:39 + | +LL | static STATIC_REF: &'static mut i32 = &mut X; + | ^^^^^^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0764]: mutable references are not allowed in the final value of statics + --> $DIR/E0017.rs:11:39 + | +LL | static STATIC_REF: &'static mut i32 = &mut X; + | ^^^^^^ + +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/E0017.rs:11:39 + | +LL | static STATIC_REF: &'static mut i32 = &mut X; + | ^^^^^^ cannot borrow as mutable + +warning: taking a mutable reference to a `const` item + --> $DIR/E0017.rs:16:38 + | +LL | static CONST_REF: &'static mut i32 = &mut C; + | ^^^^^^ + | + = note: each usage of a `const` item creates a new temporary + = note: the mutable reference will refer to this temporary, not the original `const` item +note: `const` item defined here + --> $DIR/E0017.rs:4:1 + | +LL | const C: i32 = 2; + | ^^^^^^^^^^^^ + +error[E0764]: mutable references are not allowed in the final value of statics + --> $DIR/E0017.rs:16:38 + | +LL | static CONST_REF: &'static mut i32 = &mut C; + | ^^^^^^ + +error[E0764]: mutable references are not allowed in the final value of statics + --> $DIR/E0017.rs:19:52 + | +LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; + | ^^^^^^ + +error[E0080]: it is undefined behavior to use this value + --> $DIR/E0017.rs:7:1 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾─alloc7──╼ │ ╾──╼ + } + +error: aborting due to 7 previous errors; 2 warnings emitted + +Some errors have detailed explanations: E0080, E0596, E0658, E0764. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/error-codes/E0017.64bit.stderr b/tests/ui/error-codes/E0017.64bit.stderr new file mode 100644 index 0000000000000..c9b8220849da6 --- /dev/null +++ b/tests/ui/error-codes/E0017.64bit.stderr @@ -0,0 +1,83 @@ +warning: taking a mutable reference to a `const` item + --> $DIR/E0017.rs:7:30 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^ + | + = note: each usage of a `const` item creates a new temporary + = note: the mutable reference will refer to this temporary, not the original `const` item +note: `const` item defined here + --> $DIR/E0017.rs:4:1 + | +LL | const C: i32 = 2; + | ^^^^^^^^^^^^ + = note: `#[warn(const_item_mutation)]` on by default + +error[E0764]: mutable references are not allowed in the final value of constants + --> $DIR/E0017.rs:7:30 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^ + +error[E0658]: mutation through a reference is not allowed in statics + --> $DIR/E0017.rs:11:39 + | +LL | static STATIC_REF: &'static mut i32 = &mut X; + | ^^^^^^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0764]: mutable references are not allowed in the final value of statics + --> $DIR/E0017.rs:11:39 + | +LL | static STATIC_REF: &'static mut i32 = &mut X; + | ^^^^^^ + +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/E0017.rs:11:39 + | +LL | static STATIC_REF: &'static mut i32 = &mut X; + | ^^^^^^ cannot borrow as mutable + +warning: taking a mutable reference to a `const` item + --> $DIR/E0017.rs:16:38 + | +LL | static CONST_REF: &'static mut i32 = &mut C; + | ^^^^^^ + | + = note: each usage of a `const` item creates a new temporary + = note: the mutable reference will refer to this temporary, not the original `const` item +note: `const` item defined here + --> $DIR/E0017.rs:4:1 + | +LL | const C: i32 = 2; + | ^^^^^^^^^^^^ + +error[E0764]: mutable references are not allowed in the final value of statics + --> $DIR/E0017.rs:16:38 + | +LL | static CONST_REF: &'static mut i32 = &mut C; + | ^^^^^^ + +error[E0764]: mutable references are not allowed in the final value of statics + --> $DIR/E0017.rs:19:52 + | +LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; + | ^^^^^^ + +error[E0080]: it is undefined behavior to use this value + --> $DIR/E0017.rs:7:1 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾───────alloc7────────╼ │ ╾──────╼ + } + +error: aborting due to 7 previous errors; 2 warnings emitted + +Some errors have detailed explanations: E0080, E0596, E0658, E0764. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/error-codes/E0017.rs b/tests/ui/error-codes/E0017.rs index c211ad1a2f8f6..f9565eac5b380 100644 --- a/tests/ui/error-codes/E0017.rs +++ b/tests/ui/error-codes/E0017.rs @@ -1,14 +1,20 @@ +// stderr-per-bitwidth + static X: i32 = 1; const C: i32 = 2; static mut M: i32 = 3; const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed - //~| WARN taking a mutable + +//~| WARN taking a mutable +//~| ERROR: it is undefined behavior static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658 - //~| ERROR cannot borrow - //~| ERROR mutable references are not allowed + +//~| ERROR cannot borrow +//~| ERROR mutable references are not allowed static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed - //~| WARN taking a mutable + +//~| WARN taking a mutable static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR mutable references are not fn main() {} diff --git a/tests/ui/error-codes/E0017.stderr b/tests/ui/error-codes/E0388.32bit.stderr similarity index 67% rename from tests/ui/error-codes/E0017.stderr rename to tests/ui/error-codes/E0388.32bit.stderr index 6e48f9582f1c0..8a210e21b9e2c 100644 --- a/tests/ui/error-codes/E0017.stderr +++ b/tests/ui/error-codes/E0388.32bit.stderr @@ -1,5 +1,5 @@ warning: taking a mutable reference to a `const` item - --> $DIR/E0017.rs:5:30 + --> $DIR/E0388.rs:6:30 | LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ @@ -7,20 +7,20 @@ LL | const CR: &'static mut i32 = &mut C; = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: `const` item defined here - --> $DIR/E0017.rs:2:1 + --> $DIR/E0388.rs:4:1 | LL | const C: i32 = 2; | ^^^^^^^^^^^^ = note: `#[warn(const_item_mutation)]` on by default error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/E0017.rs:5:30 + --> $DIR/E0388.rs:6:30 | LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ error[E0658]: mutation through a reference is not allowed in statics - --> $DIR/E0017.rs:7:39 + --> $DIR/E0388.rs:9:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ @@ -29,19 +29,19 @@ LL | static STATIC_REF: &'static mut i32 = &mut X; = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0017.rs:7:39 + --> $DIR/E0388.rs:9:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0017.rs:7:39 + --> $DIR/E0388.rs:9:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ cannot borrow as mutable warning: taking a mutable reference to a `const` item - --> $DIR/E0017.rs:11:38 + --> $DIR/E0388.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ @@ -49,24 +49,29 @@ LL | static CONST_REF: &'static mut i32 = &mut C; = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: `const` item defined here - --> $DIR/E0017.rs:2:1 + --> $DIR/E0388.rs:4:1 | LL | const C: i32 = 2; | ^^^^^^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0017.rs:11:38 + --> $DIR/E0388.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ -error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0017.rs:13:52 +error[E0080]: it is undefined behavior to use this value + --> $DIR/E0388.rs:6:1 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` | -LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; - | ^^^^^^ + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾─alloc5──╼ │ ╾──╼ + } error: aborting due to 6 previous errors; 2 warnings emitted -Some errors have detailed explanations: E0596, E0658, E0764. -For more information about an error, try `rustc --explain E0596`. +Some errors have detailed explanations: E0080, E0596, E0658, E0764. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/error-codes/E0388.stderr b/tests/ui/error-codes/E0388.64bit.stderr similarity index 64% rename from tests/ui/error-codes/E0388.stderr rename to tests/ui/error-codes/E0388.64bit.stderr index b51aa263d5e1c..b94ae5b025da8 100644 --- a/tests/ui/error-codes/E0388.stderr +++ b/tests/ui/error-codes/E0388.64bit.stderr @@ -1,5 +1,5 @@ warning: taking a mutable reference to a `const` item - --> $DIR/E0388.rs:4:30 + --> $DIR/E0388.rs:6:30 | LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ @@ -7,20 +7,20 @@ LL | const CR: &'static mut i32 = &mut C; = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: `const` item defined here - --> $DIR/E0388.rs:2:1 + --> $DIR/E0388.rs:4:1 | LL | const C: i32 = 2; | ^^^^^^^^^^^^ = note: `#[warn(const_item_mutation)]` on by default error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/E0388.rs:4:30 + --> $DIR/E0388.rs:6:30 | LL | const CR: &'static mut i32 = &mut C; | ^^^^^^ error[E0658]: mutation through a reference is not allowed in statics - --> $DIR/E0388.rs:6:39 + --> $DIR/E0388.rs:9:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ @@ -29,19 +29,19 @@ LL | static STATIC_REF: &'static mut i32 = &mut X; = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0388.rs:6:39 + --> $DIR/E0388.rs:9:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0388.rs:6:39 + --> $DIR/E0388.rs:9:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ cannot borrow as mutable warning: taking a mutable reference to a `const` item - --> $DIR/E0388.rs:10:38 + --> $DIR/E0388.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ @@ -49,18 +49,29 @@ LL | static CONST_REF: &'static mut i32 = &mut C; = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: `const` item defined here - --> $DIR/E0388.rs:2:1 + --> $DIR/E0388.rs:4:1 | LL | const C: i32 = 2; | ^^^^^^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/E0388.rs:10:38 + --> $DIR/E0388.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; | ^^^^^^ -error: aborting due to 5 previous errors; 2 warnings emitted +error[E0080]: it is undefined behavior to use this value + --> $DIR/E0388.rs:6:1 + | +LL | const CR: &'static mut i32 = &mut C; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾───────alloc5────────╼ │ ╾──────╼ + } + +error: aborting due to 6 previous errors; 2 warnings emitted -Some errors have detailed explanations: E0596, E0658, E0764. -For more information about an error, try `rustc --explain E0596`. +Some errors have detailed explanations: E0080, E0596, E0658, E0764. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/error-codes/E0388.rs b/tests/ui/error-codes/E0388.rs index 6049d95f0d277..2fc2f001498a7 100644 --- a/tests/ui/error-codes/E0388.rs +++ b/tests/ui/error-codes/E0388.rs @@ -1,13 +1,17 @@ +// stderr-per-bitwidth + static X: i32 = 1; const C: i32 = 2; const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed - //~| WARN taking a mutable +//~| WARN taking a mutable +//~| ERROR: it is undefined behavior to use this value static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR cannot borrow - //~| ERROR E0658 - //~| ERROR mutable references are not allowed +//~| ERROR E0658 +//~| ERROR mutable references are not allowed static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed - //~| WARN taking a mutable + +//~| WARN taking a mutable fn main() {} diff --git a/tests/ui/extern/issue-28324.mir.stderr b/tests/ui/extern/issue-28324.mir.stderr index aff8bf7927dd1..6ac3910d17ab9 100644 --- a/tests/ui/extern/issue-28324.mir.stderr +++ b/tests/ui/extern/issue-28324.mir.stderr @@ -6,6 +6,13 @@ LL | pub static BAZ: u32 = *&error_message_count; | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: aborting due to previous error +error[E0080]: could not evaluate static initializer + --> $DIR/issue-28324.rs:8:23 + | +LL | pub static BAZ: u32 = *&error_message_count; + | ^^^^^^^^^^^^^^^^^^^^^ cannot read from extern static (DefId(0:4 ~ issue_28324[8ec4]::{extern#0}::error_message_count)) + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0133`. +Some errors have detailed explanations: E0080, E0133. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/extern/issue-28324.rs b/tests/ui/extern/issue-28324.rs index fbe83e325edb4..9487cba866528 100644 --- a/tests/ui/extern/issue-28324.rs +++ b/tests/ui/extern/issue-28324.rs @@ -7,5 +7,6 @@ extern "C" { pub static BAZ: u32 = *&error_message_count; //~^ ERROR use of extern static is unsafe and requires +//~| ERROR: could not evaluate static initializer fn main() {} diff --git a/tests/ui/extern/issue-28324.thir.stderr b/tests/ui/extern/issue-28324.thir.stderr index c696c35983016..84dc4d1e5d265 100644 --- a/tests/ui/extern/issue-28324.thir.stderr +++ b/tests/ui/extern/issue-28324.thir.stderr @@ -6,6 +6,13 @@ LL | pub static BAZ: u32 = *&error_message_count; | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: aborting due to previous error +error[E0080]: could not evaluate static initializer + --> $DIR/issue-28324.rs:8:23 + | +LL | pub static BAZ: u32 = *&error_message_count; + | ^^^^^^^^^^^^^^^^^^^^^ cannot read from extern static (DefId(0:4 ~ issue_28324[8ec4]::{extern#0}::error_message_count)) + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0133`. +Some errors have detailed explanations: E0080, E0133. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs index 9b646060adfd9..ca7b815e82d38 100644 --- a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs @@ -3,13 +3,17 @@ #![deny(non_exhaustive_omitted_patterns)] //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` +//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` #![allow(non_exhaustive_omitted_patterns)] //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` +//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` fn main() { enum Foo { - A, B, C, + A, + B, + C, } #[allow(non_exhaustive_omitted_patterns)] @@ -17,6 +21,7 @@ fn main() { //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` + //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` match Foo::A { Foo::A => {} Foo::B => {} @@ -31,4 +36,5 @@ fn main() { } //~^^^ WARNING unknown lint: `non_exhaustive_omitted_patterns` //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` + //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` } diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr index fb39c404c207e..b567304d8d401 100644 --- a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr @@ -10,7 +10,7 @@ LL | #![deny(non_exhaustive_omitted_patterns)] = note: `#[warn(unknown_lints)]` on by default warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:6:1 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:7:1 | LL | #![allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | #![allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 | LL | #[allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 | LL | #[allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | #[allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:29:9 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:34:9 | LL | #[warn(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | #![deny(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:6:1 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:7:1 | LL | #![allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | #![allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 | LL | #[allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | #[allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 | LL | #[allow(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | #[allow(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable warning: unknown lint: `non_exhaustive_omitted_patterns` - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:29:9 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:34:9 | LL | #[warn(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,18 +100,19 @@ LL | #[warn(non_exhaustive_omitted_patterns)] = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable error[E0004]: non-exhaustive patterns: `Foo::C` not covered - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:20:11 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:25:11 | LL | match Foo::A { | ^^^^^^ pattern `Foo::C` not covered | note: `Foo` defined here - --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:12:15 + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:16:9 | LL | enum Foo { | --- -LL | A, B, C, - | ^ not covered +... +LL | C, + | ^ not covered = note: the matched value is of type `Foo` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | @@ -119,6 +120,46 @@ LL ~ Foo::B => {}, LL + Foo::C => todo!() | -error: aborting due to previous error; 10 warnings emitted +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:3:1 + | +LL | #![deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:7:1 + | +LL | #![allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:19:5 + | +LL | #[allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:34:9 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +error: aborting due to previous error; 14 warnings emitted For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/intrinsics/issue-28575.mir.stderr b/tests/ui/intrinsics/issue-28575.mir.stderr index c42498390c78d..e1e35d3d3ed9a 100644 --- a/tests/ui/intrinsics/issue-28575.mir.stderr +++ b/tests/ui/intrinsics/issue-28575.mir.stderr @@ -1,11 +1,21 @@ error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-28575.rs:11:5 + --> $DIR/issue-28575.rs:12:5 | LL | FOO() | ^^^ use of extern static | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: aborting due to previous error +warning: `extern` block uses type `extern "rust-intrinsic" fn()`, which is not FFI-safe + --> $DIR/issue-28575.rs:7:21 + | +LL | pub static FOO: extern "rust-intrinsic" fn(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using an `extern fn(...) -> ...` function pointer instead + = note: this function pointer has Rust-specific calling convention + = note: `#[warn(improper_ctypes)]` on by default + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/intrinsics/issue-28575.rs b/tests/ui/intrinsics/issue-28575.rs index 410f664f89d44..f395cf9cbb2fa 100644 --- a/tests/ui/intrinsics/issue-28575.rs +++ b/tests/ui/intrinsics/issue-28575.rs @@ -5,6 +5,7 @@ extern "C" { pub static FOO: extern "rust-intrinsic" fn(); + //~^ WARN: not FFI-safe } fn main() { diff --git a/tests/ui/intrinsics/issue-28575.thir.stderr b/tests/ui/intrinsics/issue-28575.thir.stderr index c42498390c78d..e1e35d3d3ed9a 100644 --- a/tests/ui/intrinsics/issue-28575.thir.stderr +++ b/tests/ui/intrinsics/issue-28575.thir.stderr @@ -1,11 +1,21 @@ error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-28575.rs:11:5 + --> $DIR/issue-28575.rs:12:5 | LL | FOO() | ^^^ use of extern static | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: aborting due to previous error +warning: `extern` block uses type `extern "rust-intrinsic" fn()`, which is not FFI-safe + --> $DIR/issue-28575.rs:7:21 + | +LL | pub static FOO: extern "rust-intrinsic" fn(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using an `extern fn(...) -> ...` function pointer instead + = note: this function pointer has Rust-specific calling convention + = note: `#[warn(improper_ctypes)]` on by default + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/issues/issue-11681.rs b/tests/ui/issues/issue-11681.rs index 6d8810d805200..cb258dcb9f4a3 100644 --- a/tests/ui/issues/issue-11681.rs +++ b/tests/ui/issues/issue-11681.rs @@ -5,15 +5,14 @@ struct Test; impl Drop for Test { - fn drop (&mut self) {} + fn drop(&mut self) {} } -fn createTest<'a>() -> &'a Test { - let testValue = &Test; - return testValue; //~ ERROR cannot return value referencing temporary value +fn create_test<'a>() -> &'a Test { + let test_value = &Test; + return test_value; //~ ERROR cannot return value referencing temporary value } - pub fn main() { - createTest(); + create_test(); } diff --git a/tests/ui/issues/issue-11681.stderr b/tests/ui/issues/issue-11681.stderr index f2f9307667194..643bb9972f6f0 100644 --- a/tests/ui/issues/issue-11681.stderr +++ b/tests/ui/issues/issue-11681.stderr @@ -1,10 +1,10 @@ error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-11681.rs:13:10 + --> $DIR/issue-11681.rs:13:12 | -LL | let testValue = &Test; - | ---- temporary value created here -LL | return testValue; - | ^^^^^^^^^ returns a value referencing data owned by the current function +LL | let test_value = &Test; + | ---- temporary value created here +LL | return test_value; + | ^^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to previous error diff --git a/tests/ui/issues/issue-13497-2.rs b/tests/ui/issues/issue-13497-2.rs index c82da0f0096ad..fe7e375052748 100644 --- a/tests/ui/issues/issue-13497-2.rs +++ b/tests/ui/issues/issue-13497-2.rs @@ -1,7 +1,9 @@ fn read_lines_borrowed<'a>() -> Vec<&'a str> { - let rawLines: Vec = vec!["foo ".to_string(), " bar".to_string()]; - rawLines //~ ERROR cannot return value referencing local variable `rawLines` - .iter().map(|l| l.trim()).collect() + let raw_lines: Vec = vec!["foo ".to_string(), " bar".to_string()]; + raw_lines //~ ERROR cannot return value referencing local variable `raw_lines` + .iter() + .map(|l| l.trim()) + .collect() } fn main() {} diff --git a/tests/ui/issues/issue-13497-2.stderr b/tests/ui/issues/issue-13497-2.stderr index a365e24e27e27..23ccde869dec1 100644 --- a/tests/ui/issues/issue-13497-2.stderr +++ b/tests/ui/issues/issue-13497-2.stderr @@ -1,11 +1,12 @@ -error[E0515]: cannot return value referencing local variable `rawLines` +error[E0515]: cannot return value referencing local variable `raw_lines` --> $DIR/issue-13497-2.rs:3:5 | -LL | // rawLines -LL | || .iter().map(|l| l.trim()).collect() - | ||_______________-___________________________^ returns a value referencing data owned by the current function - | |_______________| - | `rawLines` is borrowed here +LL | // raw_lines +LL | || .iter() + | ||_______________- `raw_lines` is borrowed here +LL | | .map(|l| l.trim()) +LL | | .collect() + | |___________________^ returns a value referencing data owned by the current function error: aborting due to previous error diff --git a/tests/ui/issues/issue-16538.mir.stderr b/tests/ui/issues/issue-16538.mir.stderr index e320df4b7ad8f..cd936beb3e8f6 100644 --- a/tests/ui/issues/issue-16538.mir.stderr +++ b/tests/ui/issues/issue-16538.mir.stderr @@ -1,7 +1,7 @@ -error[E0015]: cannot call non-const fn `Y::foo` in statics +error[E0015]: cannot call non-const fn `foo` in statics --> $DIR/issue-16538.rs:14:23 | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +LL | static FOO: &y::X = &*y::foo(y::x as *const y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants @@ -10,7 +10,7 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-16538.rs:14:30 | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +LL | static FOO: &y::X = &*y::foo(y::x as *const y::X); | ^^^^ use of extern static | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior @@ -18,7 +18,7 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block --> $DIR/issue-16538.rs:14:21 | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +LL | static FOO: &y::X = &*y::foo(y::x as *const y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer | = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior diff --git a/tests/ui/issues/issue-16538.rs b/tests/ui/issues/issue-16538.rs index 270fa30141427..10ac2cd9425e4 100644 --- a/tests/ui/issues/issue-16538.rs +++ b/tests/ui/issues/issue-16538.rs @@ -1,7 +1,7 @@ // revisions: mir thir // [thir]compile-flags: -Z thir-unsafeck -mod Y { +mod y { pub type X = usize; extern "C" { pub static x: *const usize; @@ -11,7 +11,7 @@ mod Y { } } -static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +static FOO: &y::X = &*y::foo(y::x as *const y::X); //~^ ERROR dereference of raw pointer //~| ERROR E0015 //~| ERROR use of extern static is unsafe and requires diff --git a/tests/ui/issues/issue-16538.thir.stderr b/tests/ui/issues/issue-16538.thir.stderr index 4a862869274f8..3278f8c23ffcd 100644 --- a/tests/ui/issues/issue-16538.thir.stderr +++ b/tests/ui/issues/issue-16538.thir.stderr @@ -1,7 +1,7 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block --> $DIR/issue-16538.rs:14:22 | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +LL | static FOO: &y::X = &*y::foo(y::x as *const y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer | = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior @@ -9,15 +9,15 @@ LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-16538.rs:14:30 | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +LL | static FOO: &y::X = &*y::foo(y::x as *const y::X); | ^^^^ use of extern static | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error[E0015]: cannot call non-const fn `Y::foo` in statics +error[E0015]: cannot call non-const fn `foo` in statics --> $DIR/issue-16538.rs:14:23 | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +LL | static FOO: &y::X = &*y::foo(y::x as *const y::X); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants diff --git a/tests/ui/issues/issue-46604.rs b/tests/ui/issues/issue-46604.rs index 6ec6e7bdcb81e..7c48feaf9d7a4 100644 --- a/tests/ui/issues/issue-46604.rs +++ b/tests/ui/issues/issue-46604.rs @@ -1,7 +1,7 @@ -static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR mutable references are not allowed -fn write>(buffer: T) { } +static BUF: &mut [u8] = &mut [1u8, 2, 3, 4, 5, 7]; //~ ERROR mutable references are not allowed +fn write>(buffer: T) {} fn main() { - write(&buf); - buf[0]=2; //~ ERROR E0594 + write(&BUF); + BUF[0] = 2; //~ ERROR E0594 } diff --git a/tests/ui/issues/issue-46604.stderr b/tests/ui/issues/issue-46604.stderr index 7faa2d79ba483..60342662f8299 100644 --- a/tests/ui/issues/issue-46604.stderr +++ b/tests/ui/issues/issue-46604.stderr @@ -1,14 +1,14 @@ error[E0764]: mutable references are not allowed in the final value of statics --> $DIR/issue-46604.rs:1:25 | -LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; - | ^^^^^^^^^^^^^^^^^^^^ +LL | static BUF: &mut [u8] = &mut [1u8, 2, 3, 4, 5, 7]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item +error[E0594]: cannot assign to `BUF[_]`, as `BUF` is an immutable static item --> $DIR/issue-46604.rs:6:5 | -LL | buf[0]=2; - | ^^^^^^^^ cannot assign +LL | BUF[0] = 2; + | ^^^^^^^^^^ cannot assign error: aborting due to 2 previous errors diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.rs b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.rs index af5f5885d67c5..8f327b3d3036a 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.rs +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.rs @@ -4,7 +4,7 @@ use std::mem::MaybeUninit; -enum HasNiche { +pub enum HasNiche { A, B, C, diff --git a/tests/ui/pattern/usefulness/guards.rs b/tests/ui/pattern/usefulness/guards.rs index b15440cf608bd..b78ce0d8ddc34 100644 --- a/tests/ui/pattern/usefulness/guards.rs +++ b/tests/ui/pattern/usefulness/guards.rs @@ -1,22 +1,25 @@ #![feature(exclusive_range_pattern)] #![deny(unreachable_patterns)] -enum Q { R(Option) } +enum Q { + R(Option), +} pub fn main() { match Q::R(None) { - Q::R(S) if S.is_some() => {} + Q::R(s) if s.is_some() => {} _ => {} } - match 0u8 { //~ ERROR non-exhaustive patterns - 0 .. 128 => {} - 128 ..= 255 if true => {} + match 0u8 { + //~^ ERROR non-exhaustive patterns + 0..128 => {} + 128..=255 if true => {} } match 0u8 { - 0 .. 128 => {} - 128 ..= 255 if false => {} - 128 ..= 255 => {} // ok, because previous arm was guarded + 0..128 => {} + 128..=255 if false => {} + 128..=255 => {} // ok, because previous arm was guarded } } diff --git a/tests/ui/pattern/usefulness/guards.stderr b/tests/ui/pattern/usefulness/guards.stderr index fc6748958de5b..47ef1baf69839 100644 --- a/tests/ui/pattern/usefulness/guards.stderr +++ b/tests/ui/pattern/usefulness/guards.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `128_u8..=u8::MAX` not covered - --> $DIR/guards.rs:12:11 + --> $DIR/guards.rs:14:11 | LL | match 0u8 { | ^^^ pattern `128_u8..=u8::MAX` not covered @@ -7,7 +7,7 @@ LL | match 0u8 { = note: the matched value is of type `u8` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 128 ..= 255 if true => {}, +LL ~ 128..=255 if true => {}, LL + 128_u8..=u8::MAX => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-50900.rs b/tests/ui/pattern/usefulness/issue-50900.rs index 9cc760e9a10d7..26761c2899131 100644 --- a/tests/ui/pattern/usefulness/issue-50900.rs +++ b/tests/ui/pattern/usefulness/issue-50900.rs @@ -8,12 +8,12 @@ pub enum Context { } impl Tag { - const ExifIFDPointer: Tag = Tag(Context::Tiff, 34665); + const EXIF_IFD_POINTER: Tag = Tag(Context::Tiff, 34665); } fn main() { - match Tag::ExifIFDPointer { + match Tag::EXIF_IFD_POINTER { //~^ ERROR: non-exhaustive patterns: `Tag(Context::Exif, _)` not covered - Tag::ExifIFDPointer => {} + Tag::EXIF_IFD_POINTER => {} } } diff --git a/tests/ui/pattern/usefulness/issue-50900.stderr b/tests/ui/pattern/usefulness/issue-50900.stderr index 7880c89256714..c457b1eaf982e 100644 --- a/tests/ui/pattern/usefulness/issue-50900.stderr +++ b/tests/ui/pattern/usefulness/issue-50900.stderr @@ -1,8 +1,8 @@ error[E0004]: non-exhaustive patterns: `Tag(Context::Exif, _)` not covered --> $DIR/issue-50900.rs:15:11 | -LL | match Tag::ExifIFDPointer { - | ^^^^^^^^^^^^^^^^^^^ pattern `Tag(Context::Exif, _)` not covered +LL | match Tag::EXIF_IFD_POINTER { + | ^^^^^^^^^^^^^^^^^^^^^ pattern `Tag(Context::Exif, _)` not covered | note: `Tag` defined here --> $DIR/issue-50900.rs:2:12 @@ -12,7 +12,7 @@ LL | pub struct Tag(pub Context, pub u16); = note: the matched value is of type `Tag` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Tag::ExifIFDPointer => {}, +LL ~ Tag::EXIF_IFD_POINTER => {}, LL + Tag(Context::Exif, _) => todo!() | diff --git a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs index 206f05d0d3caf..d02caff1febd2 100644 --- a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs +++ b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs @@ -4,8 +4,10 @@ fn main() { match 0u8 { 251..257 => {} //~^ ERROR literal out of range + //~| ERROR literal out of range 251..=256 => {} //~^ ERROR literal out of range + //~| ERROR literal out of range _ => {} } } diff --git a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr index 4f3f9d1eb3a76..912e73d062aca 100644 --- a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr +++ b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr @@ -5,10 +5,27 @@ LL | 251..257 => {} | ^^^ this value doesn't fit in `u8` whose maximum value is `255` error: literal out of range for `u8` - --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:7:15 + --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:8:15 | LL | 251..=256 => {} | ^^^ this value doesn't fit in `u8` whose maximum value is `255` -error: aborting due to 2 previous errors +error: literal out of range for `u8` + --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:5:14 + | +LL | 251..257 => {} + | ^^^ + | + = note: the literal `257` does not fit into the type `u8` whose range is `0..=255` + = note: `#[deny(overflowing_literals)]` on by default + +error: literal out of range for `u8` + --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:8:15 + | +LL | 251..=256 => {} + | ^^^ + | + = note: the literal `256` does not fit into the type `u8` whose range is `0..=255` + +error: aborting due to 4 previous errors diff --git a/tests/ui/regions/regions-infer-proc-static-upvar.rs b/tests/ui/regions/regions-infer-proc-static-upvar.rs index 5a64aa7345047..5f87d209000fe 100644 --- a/tests/ui/regions/regions-infer-proc-static-upvar.rs +++ b/tests/ui/regions/regions-infer-proc-static-upvar.rs @@ -1,24 +1,24 @@ // Test that, when a variable of type `&T` is captured inside a proc, // we correctly infer/require that its lifetime is 'static. -fn foo(_p: F) { } +fn foo(_p: F) {} -static i: isize = 3; +static I: isize = 3; fn capture_local() { let x = 3; let y = &x; //~ ERROR `x` does not live long enough - foo(move|| { + foo(move || { let _a = *y; }); } fn capture_static() { // Legal because &i can have static lifetime: - let y = &i; - foo(move|| { + let y = &I; + foo(move || { let _a = *y; }); } -fn main() { } +fn main() {} diff --git a/tests/ui/regions/regions-infer-proc-static-upvar.stderr b/tests/ui/regions/regions-infer-proc-static-upvar.stderr index c8a33bbc52236..7c6793f000e41 100644 --- a/tests/ui/regions/regions-infer-proc-static-upvar.stderr +++ b/tests/ui/regions/regions-infer-proc-static-upvar.stderr @@ -5,7 +5,7 @@ LL | let x = 3; | - binding `x` declared here LL | let y = &x; | ^^ borrowed value does not live long enough -LL | / foo(move|| { +LL | / foo(move || { LL | | let _a = *y; LL | | }); | |______- argument requires that `x` is borrowed for `'static` diff --git a/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs b/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs index 1b25294c7e161..16b7de9cae7cf 100644 --- a/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs +++ b/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs @@ -2,25 +2,26 @@ // are treated as rvalues and their lifetime is not bounded to // the static scope. -fn id(x: T) -> T { x } +fn id(x: T) -> T { + x +} struct Test; enum MyEnum { - Variant1 + Variant1, } -fn structLifetime<'a>() -> &'a Test { - let testValue = &id(Test); - testValue - //~^ ERROR cannot return value referencing temporary value +fn struct_lifetime<'a>() -> &'a Test { + let test_value = &id(Test); + test_value + //~^ ERROR cannot return value referencing temporary value } -fn variantLifetime<'a>() -> &'a MyEnum { - let testValue = &id(MyEnum::Variant1); - testValue - //~^ ERROR cannot return value referencing temporary value +fn variant_lifetime<'a>() -> &'a MyEnum { + let test_value = &id(MyEnum::Variant1); + test_value + //~^ ERROR cannot return value referencing temporary value } - fn main() {} diff --git a/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr b/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr index b4bf2ab312d30..48053639baee4 100644 --- a/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr +++ b/tests/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr @@ -1,18 +1,18 @@ error[E0515]: cannot return value referencing temporary value - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:15:3 + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:17:5 | -LL | let testValue = &id(Test); - | -------- temporary value created here -LL | testValue - | ^^^^^^^^^ returns a value referencing data owned by the current function +LL | let test_value = &id(Test); + | -------- temporary value created here +LL | test_value + | ^^^^^^^^^^ returns a value referencing data owned by the current function error[E0515]: cannot return value referencing temporary value - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:21:3 + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:23:5 | -LL | let testValue = &id(MyEnum::Variant1); - | -------------------- temporary value created here -LL | testValue - | ^^^^^^^^^ returns a value referencing data owned by the current function +LL | let test_value = &id(MyEnum::Variant1); + | -------------------- temporary value created here +LL | test_value + | ^^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to 2 previous errors diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr index 112416a354343..9a66d72b1b222 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -11,6 +11,25 @@ LL | const _: () = assert!(need_const_closure(Tr::a) == 42); | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it appears within the type `fn(()) -> i32 {<() as Tr>::a}` -error: aborting due to previous error +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | + = note: calling non-const function `<() as Tr>::a` + | +note: inside ` i32 {<() as Tr>::a} as FnOnce<((),)>>::call_once - shim(fn(()) -> i32 {<() as Tr>::a})` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL +note: inside `need_const_closure:: i32 {<() as Tr>::a}>` + --> $DIR/const-closure-trait-method-fail.rs:15:5 + | +LL | x(()) + | ^^^^^ +note: inside `_` + --> $DIR/const-closure-trait-method-fail.rs:18:23 + | +LL | const _: () = assert!(need_const_closure(Tr::a) == 42); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0080, E0277. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index e745cbd244292..dd433685dae12 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -53,6 +53,59 @@ LL | struct ConstImplWithDropGlue(NonTrivialDrop); | ^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function `::drop` + | +note: inside `std::ptr::drop_in_place:: - shim(Some(NonTrivialDrop))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `check::` + --> $DIR/const-drop-fail.rs:24:43 + | +LL | const fn check(_: T) {} + | ^ +note: inside `_` + --> $DIR/const-drop-fail.rs:28:23 + | +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function `::drop` + | +note: inside `std::ptr::drop_in_place:: - shim(Some(NonTrivialDrop))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place:: - shim(Some(ConstImplWithDropGlue))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `check::` + --> $DIR/const-drop-fail.rs:24:43 + | +LL | const fn check(_: T) {} + | ^ +note: inside `_` + --> $DIR/const-drop-fail.rs:28:23 + | +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0080, E0277. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index e745cbd244292..dd433685dae12 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -53,6 +53,59 @@ LL | struct ConstImplWithDropGlue(NonTrivialDrop); | ^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function `::drop` + | +note: inside `std::ptr::drop_in_place:: - shim(Some(NonTrivialDrop))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `check::` + --> $DIR/const-drop-fail.rs:24:43 + | +LL | const fn check(_: T) {} + | ^ +note: inside `_` + --> $DIR/const-drop-fail.rs:28:23 + | +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function `::drop` + | +note: inside `std::ptr::drop_in_place:: - shim(Some(NonTrivialDrop))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::drop_in_place:: - shim(Some(ConstImplWithDropGlue))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `check::` + --> $DIR/const-drop-fail.rs:24:43 + | +LL | const fn check(_: T) {} + | ^ +note: inside `_` + --> $DIR/const-drop-fail.rs:28:23 + | +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0080, E0277. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr index 0ef7b8b09f11f..0c69a561fd4ff 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.mir.stderr @@ -73,7 +73,7 @@ LL | sse2(); error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block --> $DIR/safe-calls.rs:65:18 | -LL | const name: () = sse2(); +LL | const NAME: () = sse2(); | ^^^^^^ call to function with `#[target_feature]` | = note: can only be called if the required target features are available diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs index cebc6f9478404..a6f2ccddf68c2 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs @@ -62,7 +62,7 @@ fn qux() { //[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe } -const name: () = sse2(); +const NAME: () = sse2(); //[mir]~^ ERROR call to function with `#[target_feature]` is unsafe //[thir]~^^ ERROR call to function `sse2` with `#[target_feature]` is unsafe diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr index c75ac6e8b9ae0..c4735c2fcb5cd 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.thir.stderr @@ -73,7 +73,7 @@ LL | sse2(); error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block --> $DIR/safe-calls.rs:65:18 | -LL | const name: () = sse2(); +LL | const NAME: () = sse2(); | ^^^^^^ call to function with `#[target_feature]` | = note: can only be called if the required target features are available diff --git a/tests/ui/rfcs/rfc1623-2.rs b/tests/ui/rfcs/rfc1623-2.rs index c0e13a5f5f031..ccd373475e915 100644 --- a/tests/ui/rfcs/rfc1623-2.rs +++ b/tests/ui/rfcs/rfc1623-2.rs @@ -50,9 +50,9 @@ static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8] const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); // this should be the same as without elision -static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = +static STATIC_NON_ELIDED_FN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = +const CONST_NON_ELIDED_FN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); // another function that elides, each to a different unbound lifetime diff --git a/tests/ui/span/issue-25199.rs b/tests/ui/span/issue-25199.rs index dbc3b190068ec..aff630ee27a47 100644 --- a/tests/ui/span/issue-25199.rs +++ b/tests/ui/span/issue-25199.rs @@ -18,7 +18,7 @@ use std::cell::RefCell; -trait Obj { } +trait Obj {} struct VecHolder { v: Vec<(bool, &'static str)>, @@ -34,20 +34,15 @@ impl Drop for VecHolder { struct Container<'a> { v: VecHolder, - d: RefCell>>, + d: RefCell>>, } impl<'a> Container<'a> { fn new() -> Container<'a> { - Container { - d: RefCell::new(Vec::new()), - v: VecHolder { - v: vec![(true, "valid"); 100] - } - } + Container { d: RefCell::new(Vec::new()), v: VecHolder { v: vec![(true, "valid"); 100] } } } - fn store(&'a self, val: T) { + fn store(&'a self, val: T) { self.d.borrow_mut().push(Box::new(val)); } } @@ -56,18 +51,19 @@ struct Test<'a> { test: &'a Container<'a>, } -impl<'a> Obj for Test<'a> { } +impl<'a> Obj for Test<'a> {} impl<'a> Drop for Test<'a> { fn drop(&mut self) { for e in &self.test.v.v { assert!(e.0, e.1); + //~^ WARN: panic message is not a string literal } } } fn main() { let container = Container::new(); - let test = Test{test: &container}; + let test = Test { test: &container }; //~^ ERROR `container` does not live long enough println!("container.v[30]: {:?}", container.v.v[30]); container.store(test); diff --git a/tests/ui/span/issue-25199.stderr b/tests/ui/span/issue-25199.stderr index 1e0276f0c3694..b2149d651d770 100644 --- a/tests/ui/span/issue-25199.stderr +++ b/tests/ui/span/issue-25199.stderr @@ -1,10 +1,10 @@ error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:70:27 + --> $DIR/issue-25199.rs:66:29 | LL | let container = Container::new(); | --------- binding `container` declared here -LL | let test = Test{test: &container}; - | ^^^^^^^^^^ borrowed value does not live long enough +LL | let test = Test { test: &container }; + | ^^^^^^^^^^ borrowed value does not live long enough ... LL | } | - @@ -12,6 +12,20 @@ LL | } | `container` dropped here while still borrowed | borrow might be used here, when `container` is dropped and runs the destructor for type `Container<'_>` -error: aborting due to previous error +warning: panic message is not a string literal + --> $DIR/issue-25199.rs:58:26 + | +LL | assert!(e.0, e.1); + | ^^^ + | + = note: this usage of `assert!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: `#[warn(non_fmt_panics)]` on by default +help: add a "{}" format string to `Display` the message + | +LL | assert!(e.0, "{}", e.1); + | +++++ + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/static/issue-18118-2.rs b/tests/ui/static/issue-18118-2.rs index f712a2eedb7e9..3ded866efa71f 100644 --- a/tests/ui/static/issue-18118-2.rs +++ b/tests/ui/static/issue-18118-2.rs @@ -1,6 +1,6 @@ pub fn main() { - const z: &'static isize = { - static p: isize = 3; - &p //~ ERROR constants cannot refer to statics + const Z: &'static isize = { + static P: isize = 3; + &P //~ ERROR constants cannot refer to statics }; } diff --git a/tests/ui/static/issue-18118-2.stderr b/tests/ui/static/issue-18118-2.stderr index 4fc3ca78f961c..55ee6af0cbd99 100644 --- a/tests/ui/static/issue-18118-2.stderr +++ b/tests/ui/static/issue-18118-2.stderr @@ -1,7 +1,7 @@ error[E0013]: constants cannot refer to statics --> $DIR/issue-18118-2.rs:4:10 | -LL | &p +LL | &P | ^ | = help: consider extracting the value of the `static` to a `const`, and referring to that diff --git a/tests/ui/static/issue-18118.rs b/tests/ui/static/issue-18118.rs index f58a3de281f1a..57dd341e3bf4b 100644 --- a/tests/ui/static/issue-18118.rs +++ b/tests/ui/static/issue-18118.rs @@ -1,5 +1,5 @@ pub fn main() { - const z: &'static isize = { + const Z: &'static isize = { let p = 3; &p //~ ERROR `p` does not live long enough }; diff --git a/tests/ui/static/static-mut-not-constant.rs b/tests/ui/static/static-mut-not-constant.rs index d501e5c295657..7e9e38b09a729 100644 --- a/tests/ui/static/static-mut-not-constant.rs +++ b/tests/ui/static/static-mut-not-constant.rs @@ -1,4 +1,4 @@ -static mut a: Box = Box::new(3); +static mut A: Box = Box::new(3); //~^ ERROR cannot call non-const fn fn main() {} diff --git a/tests/ui/static/static-mut-not-constant.stderr b/tests/ui/static/static-mut-not-constant.stderr index 8411a1557b4f1..2cafcc42ad333 100644 --- a/tests/ui/static/static-mut-not-constant.stderr +++ b/tests/ui/static/static-mut-not-constant.stderr @@ -1,7 +1,7 @@ error[E0015]: cannot call non-const fn `Box::::new` in statics --> $DIR/static-mut-not-constant.rs:1:28 | -LL | static mut a: Box = Box::new(3); +LL | static mut A: Box = Box::new(3); | ^^^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants diff --git a/tests/ui/static/static-mut-requires-unsafe.mir.stderr b/tests/ui/static/static-mut-requires-unsafe.mir.stderr index 0d4ce056fc28a..1c1580292b9a9 100644 --- a/tests/ui/static/static-mut-requires-unsafe.mir.stderr +++ b/tests/ui/static/static-mut-requires-unsafe.mir.stderr @@ -1,7 +1,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or block --> $DIR/static-mut-requires-unsafe.rs:7:5 | -LL | a += 3; +LL | A += 3; | ^^^^^^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior @@ -9,7 +9,7 @@ LL | a += 3; error[E0133]: use of mutable static is unsafe and requires unsafe function or block --> $DIR/static-mut-requires-unsafe.rs:8:5 | -LL | a = 4; +LL | A = 4; | ^^^^^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior @@ -17,7 +17,7 @@ LL | a = 4; error[E0133]: use of mutable static is unsafe and requires unsafe function or block --> $DIR/static-mut-requires-unsafe.rs:9:14 | -LL | let _b = a; +LL | let _b = A; | ^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior diff --git a/tests/ui/static/static-mut-requires-unsafe.rs b/tests/ui/static/static-mut-requires-unsafe.rs index ea3ba0950079e..4d4877ff3bf2b 100644 --- a/tests/ui/static/static-mut-requires-unsafe.rs +++ b/tests/ui/static/static-mut-requires-unsafe.rs @@ -1,10 +1,10 @@ // revisions: mir thir // [thir]compile-flags: -Z thir-unsafeck -static mut a: isize = 3; +static mut A: isize = 3; fn main() { - a += 3; //~ ERROR: requires unsafe - a = 4; //~ ERROR: requires unsafe - let _b = a; //~ ERROR: requires unsafe + A += 3; //~ ERROR: requires unsafe + A = 4; //~ ERROR: requires unsafe + let _b = A; //~ ERROR: requires unsafe } diff --git a/tests/ui/static/static-mut-requires-unsafe.thir.stderr b/tests/ui/static/static-mut-requires-unsafe.thir.stderr index 1a1cf14271a98..938fa1491bb20 100644 --- a/tests/ui/static/static-mut-requires-unsafe.thir.stderr +++ b/tests/ui/static/static-mut-requires-unsafe.thir.stderr @@ -1,7 +1,7 @@ error[E0133]: use of mutable static is unsafe and requires unsafe function or block --> $DIR/static-mut-requires-unsafe.rs:7:5 | -LL | a += 3; +LL | A += 3; | ^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior @@ -9,7 +9,7 @@ LL | a += 3; error[E0133]: use of mutable static is unsafe and requires unsafe function or block --> $DIR/static-mut-requires-unsafe.rs:8:5 | -LL | a = 4; +LL | A = 4; | ^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior @@ -17,7 +17,7 @@ LL | a = 4; error[E0133]: use of mutable static is unsafe and requires unsafe function or block --> $DIR/static-mut-requires-unsafe.rs:9:14 | -LL | let _b = a; +LL | let _b = A; | ^ use of mutable static | = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior diff --git a/tests/ui/static/static-vec-repeat-not-constant.rs b/tests/ui/static/static-vec-repeat-not-constant.rs index 61c87b144d9e4..8f76cfe270a1c 100644 --- a/tests/ui/static/static-vec-repeat-not-constant.rs +++ b/tests/ui/static/static-vec-repeat-not-constant.rs @@ -1,6 +1,8 @@ -fn foo() -> isize { 23 } +fn foo() -> isize { + 23 +} -static a: [isize; 2] = [foo(); 2]; +static A: [isize; 2] = [foo(); 2]; //~^ ERROR: E0015 fn main() {} diff --git a/tests/ui/static/static-vec-repeat-not-constant.stderr b/tests/ui/static/static-vec-repeat-not-constant.stderr index dec0123184d70..58895d4b1c9af 100644 --- a/tests/ui/static/static-vec-repeat-not-constant.stderr +++ b/tests/ui/static/static-vec-repeat-not-constant.stderr @@ -1,7 +1,7 @@ error[E0015]: cannot call non-const fn `foo` in statics - --> $DIR/static-vec-repeat-not-constant.rs:3:25 + --> $DIR/static-vec-repeat-not-constant.rs:5:25 | -LL | static a: [isize; 2] = [foo(); 2]; +LL | static A: [isize; 2] = [foo(); 2]; | ^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants diff --git a/tests/ui/statics/issue-14227.mir.stderr b/tests/ui/statics/issue-14227.mir.stderr index 8e7a2514dd6ab..a91224b1799cd 100644 --- a/tests/ui/statics/issue-14227.mir.stderr +++ b/tests/ui/statics/issue-14227.mir.stderr @@ -6,6 +6,13 @@ LL | static CRASH: u32 = symbol; | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: aborting due to previous error +error[E0080]: could not evaluate static initializer + --> $DIR/issue-14227.rs:7:21 + | +LL | static CRASH: u32 = symbol; + | ^^^^^^ cannot read from extern static (DefId(0:4 ~ issue_14227[1133]::{extern#0}::symbol)) + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0133`. +Some errors have detailed explanations: E0080, E0133. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/statics/issue-14227.rs b/tests/ui/statics/issue-14227.rs index 5f866ec906144..438d60a282e2f 100644 --- a/tests/ui/statics/issue-14227.rs +++ b/tests/ui/statics/issue-14227.rs @@ -6,5 +6,6 @@ extern "C" { } static CRASH: u32 = symbol; //~^ ERROR use of extern static is unsafe and requires +//~| ERROR could not evaluate static initializer fn main() {} diff --git a/tests/ui/statics/issue-14227.thir.stderr b/tests/ui/statics/issue-14227.thir.stderr index 8e7a2514dd6ab..a91224b1799cd 100644 --- a/tests/ui/statics/issue-14227.thir.stderr +++ b/tests/ui/statics/issue-14227.thir.stderr @@ -6,6 +6,13 @@ LL | static CRASH: u32 = symbol; | = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior -error: aborting due to previous error +error[E0080]: could not evaluate static initializer + --> $DIR/issue-14227.rs:7:21 + | +LL | static CRASH: u32 = symbol; + | ^^^^^^ cannot read from extern static (DefId(0:4 ~ issue_14227[1133]::{extern#0}::symbol)) + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0133`. +Some errors have detailed explanations: E0080, E0133. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/trivial-bounds/trivial-bounds-leak-copy.rs b/tests/ui/trivial-bounds/trivial-bounds-leak-copy.rs index cecc0b2da0eb5..afe662483d9f3 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-leak-copy.rs +++ b/tests/ui/trivial-bounds/trivial-bounds-leak-copy.rs @@ -1,7 +1,11 @@ // Check that false Copy bounds don't leak #![feature(trivial_bounds)] -fn copy_out_string(t: &String) -> String where String: Copy { +fn copy_out_string(t: &String) -> String +where + String: Copy, + //~^ WARN: does not depend on any type or lifetime parameters +{ *t } diff --git a/tests/ui/trivial-bounds/trivial-bounds-leak-copy.stderr b/tests/ui/trivial-bounds/trivial-bounds-leak-copy.stderr index b3ec3cd8d9d09..9f3c5ecbdd21f 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-leak-copy.stderr +++ b/tests/ui/trivial-bounds/trivial-bounds-leak-copy.stderr @@ -1,9 +1,17 @@ error[E0507]: cannot move out of `*t` which is behind a shared reference - --> $DIR/trivial-bounds-leak-copy.rs:9:5 + --> $DIR/trivial-bounds-leak-copy.rs:13:5 | LL | *t | ^^ move occurs because `*t` has type `String`, which does not implement the `Copy` trait -error: aborting due to previous error +warning: trait bound String: Copy does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-leak-copy.rs:6:13 + | +LL | String: Copy, + | ^^^^ + | + = note: `#[warn(trivial_bounds)]` on by default + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/uninhabited/uninhabited-matches-feature-gated.rs b/tests/ui/uninhabited/uninhabited-matches-feature-gated.rs index e804afcf9ed99..ed8cddb983a11 100644 --- a/tests/ui/uninhabited/uninhabited-matches-feature-gated.rs +++ b/tests/ui/uninhabited/uninhabited-matches-feature-gated.rs @@ -3,7 +3,8 @@ enum Void {} fn main() { let x: Result = Ok(23); - let _ = match x { //~ ERROR non-exhaustive + let _ = match x { + //~^ ERROR non-exhaustive Ok(n) => n, }; @@ -12,24 +13,31 @@ fn main() { // just accept the fact that this is UB if `main` did run, but it doesn't; // this test only checks that these are feature-gated. let x: &Void = unsafe { zeroed() }; + //~^ WARN: does not permit zero-init let _ = match x {}; //~ ERROR non-exhaustive let x: (Void,) = unsafe { zeroed() }; + //~^ WARN: does not permit zero-init let _ = match x {}; //~ ERROR non-exhaustive let x: [Void; 1] = unsafe { zeroed() }; + //~^ WARN: does not permit zero-init let _ = match x {}; //~ ERROR non-exhaustive let x: &[Void] = unsafe { zeroed() }; - let _ = match x { //~ ERROR non-exhaustive + //~^ WARN: does not permit zero-init + let _ = match x { + //~^ ERROR non-exhaustive &[] => (), }; let x: Void = unsafe { zeroed() }; + //~^ WARN: does not permit zero-init let _ = match x {}; // okay let x: Result = Ok(23); - let _ = match x { //~ ERROR non-exhaustive + let _ = match x { + //~^ ERROR non-exhaustive Ok(x) => x, }; diff --git a/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr b/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr index 466d7f2eadb92..6fdf5c6aace05 100644 --- a/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr +++ b/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr @@ -17,7 +17,7 @@ LL ~ Err(_) => todo!(), | error[E0004]: non-exhaustive patterns: type `&Void` is non-empty - --> $DIR/uninhabited-matches-feature-gated.rs:15:19 + --> $DIR/uninhabited-matches-feature-gated.rs:17:19 | LL | let _ = match x {}; | ^ @@ -37,7 +37,7 @@ LL ~ }; | error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty - --> $DIR/uninhabited-matches-feature-gated.rs:18:19 + --> $DIR/uninhabited-matches-feature-gated.rs:21:19 | LL | let _ = match x {}; | ^ @@ -51,7 +51,7 @@ LL ~ }; | error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty - --> $DIR/uninhabited-matches-feature-gated.rs:21:19 + --> $DIR/uninhabited-matches-feature-gated.rs:25:19 | LL | let _ = match x {}; | ^ @@ -65,7 +65,7 @@ LL ~ }; | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/uninhabited-matches-feature-gated.rs:24:19 + --> $DIR/uninhabited-matches-feature-gated.rs:29:19 | LL | let _ = match x { | ^ pattern `&[_, ..]` not covered @@ -78,7 +78,7 @@ LL ~ &[_, ..] => todo!(), | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/uninhabited-matches-feature-gated.rs:32:19 + --> $DIR/uninhabited-matches-feature-gated.rs:39:19 | LL | let _ = match x { | ^ pattern `Err(_)` not covered @@ -96,7 +96,7 @@ LL ~ Err(_) => todo!(), | error[E0005]: refutable pattern in local binding - --> $DIR/uninhabited-matches-feature-gated.rs:37:9 + --> $DIR/uninhabited-matches-feature-gated.rs:45:9 | LL | let Ok(x) = x; | ^^^^^ pattern `Err(_)` not covered @@ -109,7 +109,66 @@ help: you might want to use `let else` to handle the variant that isn't matched LL | let Ok(x) = x else { todo!() }; | ++++++++++++++++ -error: aborting due to 7 previous errors +warning: the type `&Void` does not permit zero-initialization + --> $DIR/uninhabited-matches-feature-gated.rs:15:29 + | +LL | let x: &Void = unsafe { zeroed() }; + | ^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: references must be non-null + = note: `#[warn(invalid_value)]` on by default + +warning: the type `(Void,)` does not permit zero-initialization + --> $DIR/uninhabited-matches-feature-gated.rs:19:31 + | +LL | let x: (Void,) = unsafe { zeroed() }; + | ^^^^^^^^ this code causes undefined behavior when executed + | +note: enums with no inhabited variants have no valid value + --> $DIR/uninhabited-matches-feature-gated.rs:2:1 + | +LL | enum Void {} + | ^^^^^^^^^ + +warning: the type `[Void; 1]` does not permit zero-initialization + --> $DIR/uninhabited-matches-feature-gated.rs:23:33 + | +LL | let x: [Void; 1] = unsafe { zeroed() }; + | ^^^^^^^^ this code causes undefined behavior when executed + | +note: enums with no inhabited variants have no valid value + --> $DIR/uninhabited-matches-feature-gated.rs:2:1 + | +LL | enum Void {} + | ^^^^^^^^^ + +warning: the type `&[Void]` does not permit zero-initialization + --> $DIR/uninhabited-matches-feature-gated.rs:27:31 + | +LL | let x: &[Void] = unsafe { zeroed() }; + | ^^^^^^^^ + | | + | this code causes undefined behavior when executed + | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done + | + = note: references must be non-null + +warning: the type `Void` does not permit zero-initialization + --> $DIR/uninhabited-matches-feature-gated.rs:34:28 + | +LL | let x: Void = unsafe { zeroed() }; + | ^^^^^^^^ this code causes undefined behavior when executed + | +note: enums with no inhabited variants have no valid value + --> $DIR/uninhabited-matches-feature-gated.rs:2:1 + | +LL | enum Void {} + | ^^^^^^^^^ + +error: aborting due to 7 previous errors; 5 warnings emitted Some errors have detailed explanations: E0004, E0005. For more information about an error, try `rustc --explain E0004`.