diff options
Diffstat (limited to 'src/test')
36 files changed, 1266 insertions, 96 deletions
diff --git a/src/test/mir-opt/const-promotion-extern-static.rs b/src/test/mir-opt/const-promotion-extern-static.rs new file mode 100644 index 00000000000..d611ec22c38 --- /dev/null +++ b/src/test/mir-opt/const-promotion-extern-static.rs @@ -0,0 +1,71 @@ +extern "C" { + static X: i32; +} + +static Y: i32 = 42; + +static mut BAR: *const &'static i32 = [&Y].as_ptr(); + +static mut FOO: *const &'static i32 = [unsafe { &X }].as_ptr(); + +fn main() {} + +// END RUST SOURCE +// START rustc.FOO.PromoteTemps.before.mir +// bb0: { +// ... +// _5 = const Scalar(AllocId(1).0x0) : &i32; +// _4 = &(*_5); +// _3 = [move _4]; +// _2 = &_3; +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// StorageDead(_5); +// StorageDead(_3); +// return; +// } +// END rustc.FOO.PromoteTemps.before.mir +// START rustc.BAR.PromoteTemps.before.mir +// bb0: { +// ... +// _5 = const Scalar(AllocId(0).0x0) : &i32; +// _4 = &(*_5); +// _3 = [move _4]; +// _2 = &_3; +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// StorageDead(_5); +// StorageDead(_3); +// return; +// } +// END rustc.BAR.PromoteTemps.before.mir +// START rustc.BAR.PromoteTemps.after.mir +// bb0: { +// ... +// _2 = &(promoted[0]: [&'static i32; 1]); +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// return; +// } +// END rustc.BAR.PromoteTemps.after.mir +// START rustc.FOO.PromoteTemps.after.mir +// bb0: { +// ... +// _2 = &(promoted[0]: [&'static i32; 1]); +// _1 = move _2 as &[&'static i32] (Pointer(Unsize)); +// _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; +// } +// ... +// bb2: { +// return; +// } +// END rustc.FOO.PromoteTemps.after.mir diff --git a/src/test/run-make-fulldeps/simd-ffi/simd.rs b/src/test/run-make-fulldeps/simd-ffi/simd.rs index 75d95a4eaf1..c63fe4ddce2 100644 --- a/src/test/run-make-fulldeps/simd-ffi/simd.rs +++ b/src/test/run-make-fulldeps/simd-ffi/simd.rs @@ -4,35 +4,28 @@ // cross-compiled standard libraries. #![feature(no_core, optin_builtin_traits)] #![no_core] - #![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)] - -#[repr(C)] #[derive(Copy)] #[repr(simd)] pub struct f32x4(f32, f32, f32, f32); - -extern { +extern "C" { #[link_name = "llvm.sqrt.v4f32"] fn vsqrt(x: f32x4) -> f32x4; } pub fn foo(x: f32x4) -> f32x4 { - unsafe {vsqrt(x)} + unsafe { vsqrt(x) } } -#[repr(C)] #[derive(Copy)] #[repr(simd)] pub struct i32x4(i32, i32, i32, i32); - -extern { +extern "C" { // _mm_sll_epi32 - #[cfg(any(target_arch = "x86", - target_arch = "x86-64"))] + #[cfg(any(target_arch = "x86", target_arch = "x86-64"))] #[link_name = "llvm.x86.sse2.psll.d"] fn integer(a: i32x4, b: i32x4) -> i32x4; @@ -48,22 +41,24 @@ extern { // just some substitute foreign symbol, not an LLVM intrinsic; so // we still get type checking, but not as detailed as (ab)using // LLVM. - #[cfg(not(any(target_arch = "x86", - target_arch = "x86-64", - target_arch = "arm", - target_arch = "aarch64")))] + #[cfg(not(any( + target_arch = "x86", + target_arch = "x86-64", + target_arch = "arm", + target_arch = "aarch64" + )))] fn integer(a: i32x4, b: i32x4) -> i32x4; } pub fn bar(a: i32x4, b: i32x4) -> i32x4 { - unsafe {integer(a, b)} + unsafe { integer(a, b) } } #[lang = "sized"] -pub trait Sized { } +pub trait Sized {} #[lang = "copy"] -pub trait Copy { } +pub trait Copy {} impl Copy for f32 {} impl Copy for i32 {} @@ -77,4 +72,6 @@ auto trait Freeze {} #[macro_export] #[rustc_builtin_macro] -macro_rules! Copy { () => () } +macro_rules! Copy { + () => {}; +} diff --git a/src/test/rustdoc/duplicate-cfg.rs b/src/test/rustdoc/duplicate-cfg.rs index 505d6ee769a..9ccc5d7882e 100644 --- a/src/test/rustdoc/duplicate-cfg.rs +++ b/src/test/rustdoc/duplicate-cfg.rs @@ -1,15 +1,42 @@ +// ignore-tidy-linelength + #![crate_name = "foo"] #![feature(doc_cfg)] -// @has 'foo/index.html' -// @!has '-' '//*[@class="stab portability"]' 'feature="sync" and' -// @has '-' '//*[@class="stab portability"]' 'feature="sync"' +// @has 'foo/struct.Foo.html' +// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" only.' #[doc(cfg(feature = "sync"))] #[doc(cfg(feature = "sync"))] pub struct Foo; +// @has 'foo/bar/struct.Bar.html' +// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" only.' #[doc(cfg(feature = "sync"))] pub mod bar { #[doc(cfg(feature = "sync"))] pub struct Bar; } + +// @has 'foo/baz/struct.Baz.html' +// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" only.' +#[doc(cfg(all(feature = "sync", feature = "send")))] +pub mod baz { + #[doc(cfg(feature = "sync"))] + pub struct Baz; +} + +// @has 'foo/qux/struct.Qux.html' +// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" only.' +#[doc(cfg(feature = "sync"))] +pub mod qux { + #[doc(cfg(all(feature = "sync", feature = "send")))] + pub struct Qux; +} + +// @has 'foo/quux/struct.Quux.html' +// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" and foo and bar only.' +#[doc(cfg(all(feature = "sync", feature = "send", foo)))] +pub mod quux { + #[doc(cfg(all(feature = "send", feature = "sync", bar)))] + pub struct Quux; +} diff --git a/src/test/rustdoc/issue-46380.rs b/src/test/rustdoc/issue-46380.rs deleted file mode 100644 index 8837a6b463e..00000000000 --- a/src/test/rustdoc/issue-46380.rs +++ /dev/null @@ -1,5 +0,0 @@ -// compile-flags: --document-private-items - -// @has issue_46380/struct.Hidden.html -#[doc(hidden)] -pub struct Hidden; diff --git a/src/test/rustdoc/issue-67851-both.rs b/src/test/rustdoc/issue-67851-both.rs new file mode 100644 index 00000000000..d69b9431734 --- /dev/null +++ b/src/test/rustdoc/issue-67851-both.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunstable-options --document-private-items --document-hidden-items + +// @has issue_67851_both/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +// @has issue_67851_both/struct.Private.html +struct Private; diff --git a/src/test/rustdoc/issue-67851-hidden.rs b/src/test/rustdoc/issue-67851-hidden.rs new file mode 100644 index 00000000000..8a3cafe4c3d --- /dev/null +++ b/src/test/rustdoc/issue-67851-hidden.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunstable-options --document-hidden-items + +// @has issue_67851_hidden/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +// @!has issue_67851_hidden/struct.Private.html +struct Private; diff --git a/src/test/rustdoc/issue-67851-neither.rs b/src/test/rustdoc/issue-67851-neither.rs new file mode 100644 index 00000000000..4e3cd832853 --- /dev/null +++ b/src/test/rustdoc/issue-67851-neither.rs @@ -0,0 +1,6 @@ +// @!has issue_67851_neither/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +// @!has issue_67851_neither/struct.Private.html +struct Private; diff --git a/src/test/rustdoc/issue-67851-private.rs b/src/test/rustdoc/issue-67851-private.rs new file mode 100644 index 00000000000..8addc7f3e4b --- /dev/null +++ b/src/test/rustdoc/issue-67851-private.rs @@ -0,0 +1,8 @@ +// compile-flags: --document-private-items + +// @!has issue_67851_private/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden; + +// @has issue_67851_private/struct.Private.html +struct Private; diff --git a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs index ee14d715730..abb2e93757e 100644 --- a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs @@ -8,7 +8,7 @@ extern crate rustc_hir; extern crate rustc_span; extern crate syntax; -use rustc::hir::intravisit; +use rustc_hir::intravisit; use rustc_hir as hir; use rustc_hir::Node; use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; diff --git a/src/test/ui/associated-const/issue-63496.stderr b/src/test/ui/associated-const/issue-63496.stderr index 23916a3ba44..3a70e7d43c2 100644 --- a/src/test/ui/associated-const/issue-63496.stderr +++ b/src/test/ui/associated-const/issue-63496.stderr @@ -5,9 +5,13 @@ LL | const C: usize; | --------------- required by `A::C` LL | LL | fn f() -> ([u8; A::C], [u8; A::C]); - | ^^^^ cannot infer type + | ^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `<Type as A>::C` | = note: cannot resolve `_: A` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error[E0283]: type annotations needed --> $DIR/issue-63496.rs:4:33 @@ -16,9 +20,13 @@ LL | const C: usize; | --------------- required by `A::C` LL | LL | fn f() -> ([u8; A::C], [u8; A::C]); - | ^^^^ cannot infer type + | ^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `<Type as A>::C` | = note: cannot resolve `_: A` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-item/issue-48027.stderr b/src/test/ui/associated-item/issue-48027.stderr index 9c825d593d3..ddabd552897 100644 --- a/src/test/ui/associated-item/issue-48027.stderr +++ b/src/test/ui/associated-item/issue-48027.stderr @@ -13,9 +13,13 @@ error[E0283]: type annotations needed LL | const X: usize; | --------------- required by `Bar::X` LL | fn return_n(&self) -> [u8; Bar::X]; - | ^^^^^^ cannot infer type + | ^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `<Type as Bar>::X` | = note: cannot resolve `_: Bar` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-match.rs new file mode 100644 index 00000000000..232d43679b4 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-match.rs @@ -0,0 +1,118 @@ +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + [.., _y] => {} //~ ERROR use of moved value + } +} + +fn move_out_from_begin_field_and_end() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., _y] => {} //~ ERROR use of moved value + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., (_y, _)] => {} //~ ERROR use of moved value + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR use of moved value + [_, _, _y @ ..] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [_, _, _y @ ..] => {} + } +} + +fn move_out_by_subslice_and_const_index_field() { + let a = array(); + match a { + [_y @ .., _, _] => {} + } + match a { + [(_x, _), _, _] => {} //~ ERROR use of moved value + } +} + +fn move_out_by_subslice_and_const_index_end_field() { + let a = array(); + match a { + [_, _, _y @ ..] => {} + } + match a { + [.., (_x, _)] => {} //~ ERROR use of moved value + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr new file mode 100644 index 00000000000..e46a58a8a35 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-match.stderr @@ -0,0 +1,113 @@ +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-match.rs:15:14 + | +LL | [_, _, _x] => {} + | -- value moved here +... +LL | [.., _y] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-match.rs:25:14 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., _y] => {} + | ^^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-match.rs:35:15 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., (_y, _)] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:46:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:57:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:68:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:79:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-match.rs:91:11 + | +LL | [_y @ .., _, _] => {} + | ------- value moved here +... +LL | [(_x, _), _, _] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-match.rs:101:15 + | +LL | [_, _, _y @ ..] => {} + | ------- value moved here +... +LL | [.., (_x, _)] => {} + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-match.rs:112:11 + | +LL | [x @ .., _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.rs new file mode 100644 index 00000000000..e5e61697c68 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.rs @@ -0,0 +1,117 @@ +// Due to #53114, which causes a "read" of the `_` patterns, +// the borrow-checker refuses this code, while it should probably be allowed. +// Once the bug is fixed, the test, which is derived from a +// passing test for `let` statements, should become check-pass. + +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_one_from_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + //~^ ERROR use of moved value + [.., _y, _] => {} + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [.., (_, _y)] => {} + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [_y @ .., _] => {} + } +} + +fn move_out_by_const_subslice_and_index_field() { + let a = array(); + match a { + [_, _y @ ..] => {} + } + match a { + //~^ ERROR use of moved value + [(_x, _), _, _] => {} + } +} + +fn move_out_by_const_subslice_and_end_index_field() { + let a = array(); + match a { + [_y @ .., _] => {} + } + match a { + //~^ ERROR use of moved value + [.., (_x, _)] => {} + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, _y @ ..] => {} + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr new file mode 100644 index 00000000000..72cd4207cce --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-no-overlap-match.stderr @@ -0,0 +1,102 @@ +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:19:11 + | +LL | [_, _, _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:30:11 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:43:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:54:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:65:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:76:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:87:11 + | +LL | [_, _y @ ..] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:98:11 + | +LL | [_y @ .., _] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-no-overlap-match.rs:111:11 + | +LL | [x @ .., _, _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.rs new file mode 100644 index 00000000000..1ca3df52ada --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.rs @@ -0,0 +1,152 @@ +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + [.., ref _y] => {} //~ ERROR [E0382] + } +} + +fn move_out_from_begin_field_and_end() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., ref _y] => {} //~ ERROR [E0382] + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + [.., (ref _y, _)] => {} //~ ERROR [E0382] + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR [E0382] + [ref _y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR [E0382] + [_, _, ref _y @ ..] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR [E0382] + [ref _y @ .., _, _] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR [E0382] + [_, _, ref _y @ ..] => {} + } +} + +fn move_out_by_subslice_and_const_index_field() { + let a = array(); + match a { + [_y @ .., _, _] => {} + } + match a { + [(ref _x, _), _, _] => {} //~ ERROR [E0382] + } +} + +fn move_out_by_subslice_and_const_index_end_field() { + let a = array(); + match a { + [_, _, _y @ ..] => {} + } + match a { + [.., (ref _x, _)] => {} //~ ERROR [E0382] + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _] => {} + } + match a { + //~^ ERROR [E0382] + [_, ref _y @ ..] => {} + } +} + +// Move + Assign + +fn move_out_and_assign_end() { + let mut a = array(); + match a { + [_, _, _x] => {} + } + a[2] = Default::default(); //~ ERROR [E0382] +} + +fn move_out_and_assign_end_field() { + let mut a = array(); + match a { + [_, _, (_x, _)] => {} + } + a[2].1 = Default::default(); //~ ERROR [E0382] +} + +fn move_out_slice_and_assign_end() { + let mut a = array(); + match a { + [_, _, _x @ ..] => {} + } + a[0] = Default::default(); //~ ERROR [E0382] +} + +fn move_out_slice_and_assign_end_field() { + let mut a = array(); + match a { + [_, _, _x @ ..] => {} + } + a[0].1 = Default::default(); //~ ERROR [E0382] +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr new file mode 100644 index 00000000000..028442a4c07 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-match.stderr @@ -0,0 +1,157 @@ +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:15:14 + | +LL | [_, _, _x] => {} + | -- value moved here +... +LL | [.., ref _y] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:25:14 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., ref _y] => {} + | ^^^^^^ value borrowed here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..].0` + --> $DIR/borrowck-move-out-from-array-use-match.rs:35:15 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +... +LL | [.., (ref _y, _)] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:46:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:57:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:68:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:79:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:91:11 + | +LL | [_y @ .., _, _] => {} + | ------- value moved here +... +LL | [(ref _x, _), _, _] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array-use-match.rs:101:15 + | +LL | [_, _, _y @ ..] => {} + | ------- value moved here +... +LL | [.., (ref _x, _)] => {} + | ^^^^^^ value borrowed here after move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:112:11 + | +LL | [x @ .., _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:125:5 + | +LL | [_, _, _x] => {} + | -- value moved here +LL | } +LL | a[2] = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:133:5 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +LL | } +LL | a[2].1 = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:141:5 + | +LL | [_, _, _x @ ..] => {} + | ------- value moved here +LL | } +LL | a[0] = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-match.rs:149:5 + | +LL | [_, _, _x @ ..] => {} + | ------- value moved here +LL | } +LL | a[0].1 = Default::default(); + | ^^^^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs new file mode 100644 index 00000000000..79fe5930096 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.rs @@ -0,0 +1,117 @@ +// Due to #53114, which causes a "read" of the `_` patterns, +// the borrow-checker refuses this code, while it should probably be allowed. +// Once the bug is fixed, the test, which is derived from a +// passing test for `let` statements, should become check-pass. + +#![feature(slice_patterns)] + +fn array() -> [(String, String); 3] { + Default::default() +} + +// Const Index + Const Index + +fn move_out_from_begin_and_one_from_end() { + let a = array(); + match a { + [_, _, _x] => {} + } + match a { + //~^ ERROR use of moved value + [.., ref _y, _] => {} + } +} + +fn move_out_from_begin_field_and_end_field() { + let a = array(); + match a { + [_, _, (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [.., (_, ref _y)] => {} + } +} + +// Const Index + Slice + +fn move_out_by_const_index_and_subslice() { + let a = array(); + match a { + [_x, _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, ref _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_and_subslice() { + let a = array(); + match a { + [.., _x] => {} + } + match a { + //~^ ERROR use of moved value + [ref _y @ .., _] => {} + } +} + +fn move_out_by_const_index_field_and_subslice() { + let a = array(); + match a { + [(_x, _), _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, ref _y @ ..] => {} + } +} + +fn move_out_by_const_index_end_field_and_subslice() { + let a = array(); + match a { + [.., (_x, _)] => {} + } + match a { + //~^ ERROR use of moved value + [ref _y @ .., _] => {} + } +} + +fn move_out_by_const_subslice_and_index_field() { + let a = array(); + match a { + [_, _y @ ..] => {} + } + match a { + //~^ ERROR use of moved value + [(ref _x, _), _, _] => {} + } +} + +fn move_out_by_const_subslice_and_end_index_field() { + let a = array(); + match a { + [_y @ .., _] => {} + } + match a { + //~^ ERROR use of moved value + [.., (ref _x, _)] => {} + } +} + +// Slice + Slice + +fn move_out_by_subslice_and_subslice() { + let a = array(); + match a { + [x @ .., _, _] => {} + } + match a { + //~^ ERROR use of moved value + [_, ref _y @ ..] => {} + } +} + +fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr new file mode 100644 index 00000000000..43ba2b664a1 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-move-out-from-array-use-no-overlap-match.stderr @@ -0,0 +1,102 @@ +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:19:11 + | +LL | [_, _, _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:30:11 + | +LL | [_, _, (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:43:11 + | +LL | [_x, _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:54:11 + | +LL | [.., _x] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:65:11 + | +LL | [(_x, _), _, _] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:76:11 + | +LL | [.., (_x, _)] => {} + | -- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..].0` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:87:11 + | +LL | [_, _y @ ..] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:98:11 + | +LL | [_y @ .., _] => {} + | ------- value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a` + --> $DIR/borrowck-move-out-from-array-use-no-overlap-match.rs:111:11 + | +LL | [x @ .., _, _] => {} + | ------ value moved here +LL | } +LL | match a { + | ^ value used here after partial move + | + = note: move occurs because `a[..]` has type `(std::string::String, std::string::String)`, which does not implement the `Copy` trait + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/conflicting-repr-hints.rs b/src/test/ui/conflicting-repr-hints.rs index cc986b25219..8e9c11690a8 100644 --- a/src/test/ui/conflicting-repr-hints.rs +++ b/src/test/ui/conflicting-repr-hints.rs @@ -1,16 +1,24 @@ #![allow(dead_code)] #[repr(C)] -enum A { A } +enum A { + A, +} #[repr(u64)] -enum B { B } +enum B { + B, +} -#[repr(C, u64)] //~ WARNING conflicting representation hints -enum C { C } +#[repr(C, u64)] //~ ERROR conflicting representation hints +enum C { + C, +} -#[repr(u32, u64)] //~ WARNING conflicting representation hints -enum D { D } +#[repr(u32, u64)] //~ ERROR conflicting representation hints +enum D { + D, +} #[repr(C, packed)] struct E(i32); @@ -37,20 +45,23 @@ struct J(i32); //~ ERROR type has conflicting packed representation hints struct K(i32); #[repr(packed, align(8))] -union X { //~ ERROR type has conflicting packed and align representation hints - i: i32 +union X { + //~^ ERROR type has conflicting packed and align representation hints + i: i32, } #[repr(packed)] #[repr(align(8))] -union Y { //~ ERROR type has conflicting packed and align representation hints - i: i32 +union Y { + //~^ ERROR type has conflicting packed and align representation hints + i: i32, } #[repr(align(8))] #[repr(packed)] -union Z { //~ ERROR type has conflicting packed and align representation hints - i: i32 +union Z { + //~^ ERROR type has conflicting packed and align representation hints + i: i32, } fn main() {} diff --git a/src/test/ui/conflicting-repr-hints.stderr b/src/test/ui/conflicting-repr-hints.stderr index 414c15f93bc..0dfe360dbb3 100644 --- a/src/test/ui/conflicting-repr-hints.stderr +++ b/src/test/ui/conflicting-repr-hints.stderr @@ -1,70 +1,73 @@ -warning[E0566]: conflicting representation hints - --> $DIR/conflicting-repr-hints.rs:9:8 +error[E0566]: conflicting representation hints + --> $DIR/conflicting-repr-hints.rs:13:8 | LL | #[repr(C, u64)] | ^ ^^^ -warning[E0566]: conflicting representation hints - --> $DIR/conflicting-repr-hints.rs:12:8 +error[E0566]: conflicting representation hints + --> $DIR/conflicting-repr-hints.rs:18:8 | LL | #[repr(u32, u64)] | ^^^ ^^^ error[E0587]: type has conflicting packed and align representation hints - --> $DIR/conflicting-repr-hints.rs:19:1 + --> $DIR/conflicting-repr-hints.rs:27:1 | LL | struct F(i32); | ^^^^^^^^^^^^^^ error[E0587]: type has conflicting packed and align representation hints - --> $DIR/conflicting-repr-hints.rs:23:1 + --> $DIR/conflicting-repr-hints.rs:31:1 | LL | struct G(i32); | ^^^^^^^^^^^^^^ error[E0587]: type has conflicting packed and align representation hints - --> $DIR/conflicting-repr-hints.rs:27:1 + --> $DIR/conflicting-repr-hints.rs:35:1 | LL | struct H(i32); | ^^^^^^^^^^^^^^ error[E0634]: type has conflicting packed representation hints - --> $DIR/conflicting-repr-hints.rs:30:1 + --> $DIR/conflicting-repr-hints.rs:38:1 | LL | struct I(i32); | ^^^^^^^^^^^^^^ error[E0634]: type has conflicting packed representation hints - --> $DIR/conflicting-repr-hints.rs:34:1 + --> $DIR/conflicting-repr-hints.rs:42:1 | LL | struct J(i32); | ^^^^^^^^^^^^^^ error[E0587]: type has conflicting packed and align representation hints - --> $DIR/conflicting-repr-hints.rs:40:1 + --> $DIR/conflicting-repr-hints.rs:48:1 | LL | / union X { -LL | | i: i32 +LL | | +LL | | i: i32, LL | | } | |_^ error[E0587]: type has conflicting packed and align representation hints - --> $DIR/conflicting-repr-hints.rs:46:1 + --> $DIR/conflicting-repr-hints.rs:55:1 | LL | / union Y { -LL | | i: i32 +LL | | +LL | | i: i32, LL | | } | |_^ error[E0587]: type has conflicting packed and align representation hints - --> $DIR/conflicting-repr-hints.rs:52:1 + --> $DIR/conflicting-repr-hints.rs:62:1 | LL | / union Z { -LL | | i: i32 +LL | | +LL | | i: i32, LL | | } | |_^ -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors Some errors have detailed explanations: E0566, E0587. For more information about an error, try `rustc --explain E0566`. diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.rs b/src/test/ui/feature-gates/feature-gate-repr-simd.rs index 9d28f437415..1e4a404fa25 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.rs +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.rs @@ -1,7 +1,7 @@ #[repr(simd)] //~ error: SIMD types are experimental struct Foo(u64, u64); -#[repr(C)] //~ warn: conflicting representation hints +#[repr(C)] //~ ERROR conflicting representation hints #[repr(simd)] //~ error: SIMD types are experimental struct Bar(u64, u64); diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr index 02c8400e03e..37a7bd0b129 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr @@ -16,7 +16,7 @@ LL | #[repr(simd)] = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(repr_simd)]` to the crate attributes to enable -warning[E0566]: conflicting representation hints +error[E0566]: conflicting representation hints --> $DIR/feature-gate-repr-simd.rs:4:8 | LL | #[repr(C)] @@ -24,7 +24,7 @@ LL | #[repr(C)] LL | #[repr(simd)] | ^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0566, E0658. For more information about an error, try `rustc --explain E0566`. diff --git a/src/test/ui/issues/issue-14221.stderr b/src/test/ui/issues/issue-14221.stderr index 3e5e25a9f6d..9864c0840d8 100644 --- a/src/test/ui/issues/issue-14221.stderr +++ b/src/test/ui/issues/issue-14221.stderr @@ -3,6 +3,8 @@ warning[E0170]: pattern binding `A` is named the same as one of the variants of | LL | A => "A", | ^ help: to match on the variant, qualify the path: `E::A` + | + = note: `#[warn(bindings_with_variant_name)]` on by default warning[E0170]: pattern binding `B` is named the same as one of the variants of the type `E` --> $DIR/issue-14221.rs:15:13 diff --git a/src/test/ui/issues/issue-19100.stderr b/src/test/ui/issues/issue-19100.stderr index 1ab13477e37..01e5313fcc1 100644 --- a/src/test/ui/issues/issue-19100.stderr +++ b/src/test/ui/issues/issue-19100.stderr @@ -3,6 +3,8 @@ warning[E0170]: pattern binding `Bar` is named the same as one of the variants o | LL | Bar if true | ^^^ help: to match on the variant, qualify the path: `Foo::Bar` + | + = note: `#[warn(bindings_with_variant_name)]` on by default warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo` --> $DIR/issue-19100.rs:22:1 diff --git a/src/test/ui/issues/issue-30302.stderr b/src/test/ui/issues/issue-30302.stderr index d762d6f2b3d..ac1b5235f44 100644 --- a/src/test/ui/issues/issue-30302.stderr +++ b/src/test/ui/issues/issue-30302.stderr @@ -3,6 +3,8 @@ warning[E0170]: pattern binding `Nil` is named the same as one of the variants o | LL | Nil => true, | ^^^ help: to match on the variant, qualify the path: `Stack::Nil` + | + = note: `#[warn(bindings_with_variant_name)]` on by default error: unreachable pattern --> $DIR/issue-30302.rs:15:9 diff --git a/src/test/ui/issues/issue-39720.rs b/src/test/ui/issues/issue-39720.rs index 1a4775fc960..8cf841f9371 100644 --- a/src/test/ui/issues/issue-39720.rs +++ b/src/test/ui/issues/issue-39720.rs @@ -1,26 +1,22 @@ // run-pass -#![allow(non_snake_case)] - // ignore-emscripten FIXME(#45351) #![feature(repr_simd, platform_intrinsics)] -#[repr(C)] //~ WARNING conflicting representation hints #[repr(simd)] #[derive(Copy, Clone, Debug)] -pub struct char3(pub i8, pub i8, pub i8); +pub struct Char3(pub i8, pub i8, pub i8); -#[repr(C)] //~ WARNING conflicting representation hints #[repr(simd)] #[derive(Copy, Clone, Debug)] -pub struct short3(pub i16, pub i16, pub i16); +pub struct Short3(pub i16, pub i16, pub i16); extern "platform-intrinsic" { fn simd_cast<T, U>(x: T) -> U; } fn main() { - let cast: short3 = unsafe { simd_cast(char3(10, -3, -9)) }; + let cast: Short3 = unsafe { simd_cast(Char3(10, -3, -9)) }; println!("{:?}", cast); } diff --git a/src/test/ui/issues/issue-39720.stderr b/src/test/ui/issues/issue-39720.stderr deleted file mode 100644 index 8121ed28940..00000000000 --- a/src/test/ui/issues/issue-39720.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning[E0566]: conflicting representation hints - --> $DIR/issue-39720.rs:8:8 - | -LL | #[repr(C)] - | ^ -LL | #[repr(simd)] - | ^^^^ - -warning[E0566]: conflicting representation hints - --> $DIR/issue-39720.rs:13:8 - | -LL | #[repr(C)] - | ^ -LL | #[repr(simd)] - | ^^^^ - diff --git a/src/test/ui/issues/issue-47094.rs b/src/test/ui/issues/issue-47094.rs index 97da984d4af..3258ee92a74 100644 --- a/src/test/ui/issues/issue-47094.rs +++ b/src/test/ui/issues/issue-47094.rs @@ -1,12 +1,10 @@ -// check-pass - -#[repr(C,u8)] //~ WARNING conflicting representation hints +#[repr(C, u8)] //~ ERROR conflicting representation hints enum Foo { A, B, } -#[repr(C)] //~ WARNING conflicting representation hints +#[repr(C)] //~ ERROR conflicting representation hints #[repr(u8)] enum Bar { A, diff --git a/src/test/ui/issues/issue-47094.stderr b/src/test/ui/issues/issue-47094.stderr index 16bcec0c7bb..c807f644fd3 100644 --- a/src/test/ui/issues/issue-47094.stderr +++ b/src/test/ui/issues/issue-47094.stderr @@ -1,14 +1,17 @@ -warning[E0566]: conflicting representation hints - --> $DIR/issue-47094.rs:3:8 +error[E0566]: conflicting representation hints + --> $DIR/issue-47094.rs:1:8 | -LL | #[repr(C,u8)] - | ^ ^^ +LL | #[repr(C, u8)] + | ^ ^^ -warning[E0566]: conflicting representation hints - --> $DIR/issue-47094.rs:9:8 +error[E0566]: conflicting representation hints + --> $DIR/issue-47094.rs:7:8 | LL | #[repr(C)] | ^ LL | #[repr(u8)] | ^^ +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0566`. diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/issues/issue-58022.stderr index ef0d66d7ad6..70a7c38b834 100644 --- a/src/test/ui/issues/issue-58022.stderr +++ b/src/test/ui/issues/issue-58022.stderr @@ -11,9 +11,13 @@ LL | const SIZE: usize; | ------------------ required by `Foo::SIZE` LL | LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; - | ^^^^^^^^^ cannot infer type + | ^^^^^^^^^ + | | + | cannot infer type + | help: use the fully qualified path to an implementation: `<Type as Foo>::SIZE` | = note: cannot resolve `_: Foo` + = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/lint/lint-uppercase-variables.stderr b/src/test/ui/lint/lint-uppercase-variables.stderr index f614d5d71f8..b937832ac62 100644 --- a/src/test/ui/lint/lint-uppercase-variables.stderr +++ b/src/test/ui/lint/lint-uppercase-variables.stderr @@ -3,6 +3,8 @@ warning[E0170]: pattern binding `Foo` is named the same as one of the variants o | LL | Foo => {} | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + | + = note: `#[warn(bindings_with_variant_name)]` on by default warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:22:9 diff --git a/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr b/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr index abb8d6907e7..21218d9a173 100644 --- a/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr +++ b/src/test/ui/pattern/issue-67776-match-same-name-enum-variant-refs.stderr @@ -3,6 +3,8 @@ warning[E0170]: pattern binding `Bar` is named the same as one of the variants o | LL | Bar => {}, | ^^^ help: to match on the variant, qualify the path: `Foo::Bar` + | + = note: `#[warn(bindings_with_variant_name)]` on by default warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo` --> $DIR/issue-67776-match-same-name-enum-variant-refs.rs:19:9 diff --git a/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs b/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs new file mode 100644 index 00000000000..be13076b8af --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs @@ -0,0 +1,38 @@ +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(option_expect_none, option_unwrap_none)] + +//! Test that panic locations for `#[track_caller]` functions in std have the correct +//! location reported. + +fn main() { + // inspect the `PanicInfo` we receive to ensure the right file is the source + std::panic::set_hook(Box::new(|info| { + let actual = info.location().unwrap(); + if actual.file() != file!() { + eprintln!("expected a location in the test file, found {:?}", actual); + panic!(); + } + })); + + fn assert_panicked(f: impl FnOnce() + std::panic::UnwindSafe) { + std::panic::catch_unwind(f).unwrap_err(); + } + + let nope: Option<()> = None; + assert_panicked(|| nope.unwrap()); + assert_panicked(|| nope.expect("")); + + let yep: Option<()> = Some(()); + assert_panicked(|| yep.unwrap_none()); + assert_panicked(|| yep.expect_none("")); + + let oops: Result<(), ()> = Err(()); + assert_panicked(|| oops.unwrap()); + assert_panicked(|| oops.expect("")); + + let fine: Result<(), ()> = Ok(()); + assert_panicked(|| fine.unwrap_err()); + assert_panicked(|| fine.expect_err("")); +} diff --git a/src/test/ui/suggestions/issue-66968-suggest-sorted-words.rs b/src/test/ui/suggestions/issue-66968-suggest-sorted-words.rs new file mode 100644 index 00000000000..440bb653a83 --- /dev/null +++ b/src/test/ui/suggestions/issue-66968-suggest-sorted-words.rs @@ -0,0 +1,4 @@ +fn main() { + let a_longer_variable_name = 1; + println!("{}", a_variable_longer_name); //~ ERROR E0425 +} diff --git a/src/test/ui/suggestions/issue-66968-suggest-sorted-words.stderr b/src/test/ui/suggestions/issue-66968-suggest-sorted-words.stderr new file mode 100644 index 00000000000..d7b33ea41f7 --- /dev/null +++ b/src/test/ui/suggestions/issue-66968-suggest-sorted-words.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `a_variable_longer_name` in this scope + --> $DIR/issue-66968-suggest-sorted-words.rs:3:20 + | +LL | println!("{}", a_variable_longer_name); + | ^^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `a_longer_variable_name` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. |
