diff options
Diffstat (limited to 'tests')
27 files changed, 530 insertions, 194 deletions
diff --git a/tests/mir-opt/building/match/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match/match_false_edges.main.built.after.mir index b71b2412cdf..dfa31cfff6b 100644 --- a/tests/mir-opt/building/match/match_false_edges.main.built.after.mir +++ b/tests/mir-opt/building/match/match_false_edges.main.built.after.mir @@ -48,7 +48,7 @@ fn main() -> () { } bb2: { - falseEdge -> [real: bb15, imaginary: bb6]; + falseEdge -> [real: bb15, imaginary: bb3]; } bb3: { diff --git a/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir index e95a97b5b87..c3497c6989d 100644 --- a/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/sort_candidates.constant_eq.SimplifyCfg-initial.after.mir @@ -40,7 +40,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb4: { - falseEdge -> [real: bb12, imaginary: bb9]; + falseEdge -> [real: bb12, imaginary: bb7]; } bb5: { @@ -48,7 +48,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb6: { - falseEdge -> [real: bb16, imaginary: bb3]; + falseEdge -> [real: bb16, imaginary: bb1]; } bb7: { @@ -60,7 +60,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { } bb9: { - falseEdge -> [real: bb15, imaginary: bb6]; + falseEdge -> [real: bb15, imaginary: bb5]; } bb10: { @@ -89,7 +89,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 { bb14: { StorageDead(_10); - falseEdge -> [real: bb5, imaginary: bb9]; + falseEdge -> [real: bb5, imaginary: bb7]; } bb15: { diff --git a/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir b/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir index 80d3c2e5c23..4a1e4fb9ec5 100644 --- a/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/building/match/sort_candidates.disjoint_ranges.SimplifyCfg-initial.after.mir @@ -23,7 +23,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { } bb2: { - falseEdge -> [real: bb9, imaginary: bb4]; + falseEdge -> [real: bb9, imaginary: bb3]; } bb3: { @@ -32,7 +32,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { } bb4: { - falseEdge -> [real: bb12, imaginary: bb6]; + falseEdge -> [real: bb12, imaginary: bb5]; } bb5: { @@ -69,7 +69,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 { bb11: { StorageDead(_8); - falseEdge -> [real: bb1, imaginary: bb4]; + falseEdge -> [real: bb1, imaginary: bb3]; } bb12: { diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 307f7105dd2..ba333ba1a58 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -60,11 +60,11 @@ } - bb5: { -- falseEdge -> [real: bb13, imaginary: bb3]; +- falseEdge -> [real: bb13, imaginary: bb2]; - } - - bb6: { -- falseEdge -> [real: bb8, imaginary: bb5]; +- falseEdge -> [real: bb8, imaginary: bb1]; - } - - bb7: { @@ -127,7 +127,7 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb1, imaginary: bb5]; +- falseEdge -> [real: bb1, imaginary: bb1]; + goto -> bb1; } @@ -184,7 +184,7 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb2, imaginary: bb3]; +- falseEdge -> [real: bb2, imaginary: bb2]; + goto -> bb2; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 307f7105dd2..ba333ba1a58 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -60,11 +60,11 @@ } - bb5: { -- falseEdge -> [real: bb13, imaginary: bb3]; +- falseEdge -> [real: bb13, imaginary: bb2]; - } - - bb6: { -- falseEdge -> [real: bb8, imaginary: bb5]; +- falseEdge -> [real: bb8, imaginary: bb1]; - } - - bb7: { @@ -127,7 +127,7 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb1, imaginary: bb5]; +- falseEdge -> [real: bb1, imaginary: bb1]; + goto -> bb1; } @@ -184,7 +184,7 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb2, imaginary: bb3]; +- falseEdge -> [real: bb2, imaginary: bb2]; + goto -> bb2; } diff --git a/tests/run-make/hir-tree/Makefile b/tests/run-make/hir-tree/Makefile deleted file mode 100644 index b0450ea4bc5..00000000000 --- a/tests/run-make/hir-tree/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../tools.mk - -# Test that hir-tree output doesn't crash and includes -# the string constant we would expect to see. - -all: - $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs - $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir diff --git a/tests/run-make/hir-tree/input.rs b/tests/run-make/hir-tree/input.rs deleted file mode 100644 index 9d1a4e9e47d..00000000000 --- a/tests/run-make/hir-tree/input.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, Rustaceans!"); -} diff --git a/tests/ui/extern/issue-95829.stderr b/tests/ui/extern/issue-95829.stderr index b902f0ef8f5..16504d1f0c9 100644 --- a/tests/ui/extern/issue-95829.stderr +++ b/tests/ui/extern/issue-95829.stderr @@ -16,17 +16,12 @@ LL | | } = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html error: functions in `extern` blocks cannot have qualifiers - --> $DIR/issue-95829.rs:4:14 + --> $DIR/issue-95829.rs:4:5 | LL | extern { | ------ in this `extern` block LL | async fn L() { - | ^ - | -help: remove the qualifiers - | -LL | fn L() { - | ~~ + | ^^^^^ help: remove this qualifier error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs b/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs deleted file mode 100644 index 03071c351a4..00000000000 --- a/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ force-host -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::Literal; - -fn test() { - Literal::byte_character(b'a'); //~ ERROR use of unstable library feature 'proc_macro_byte_character' -} diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr b/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr deleted file mode 100644 index c14d19381c8..00000000000 --- a/tests/ui/feature-gates/feature-gate-proc_macro_byte_character.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: use of unstable library feature 'proc_macro_byte_character' - --> $DIR/feature-gate-proc_macro_byte_character.rs:9:5 - | -LL | Literal::byte_character(b'a'); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #115268 <https://github.com/rust-lang/rust/issues/115268> for more information - = help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.rs b/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.rs deleted file mode 100644 index 1750fe952f5..00000000000 --- a/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ edition: 2021 -//@ force-host -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::Literal; - -fn test() { - Literal::c_string(c"a"); //~ ERROR use of unstable library feature 'proc_macro_c_str_literals' -} diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.stderr b/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.stderr deleted file mode 100644 index 9bba1d50ce3..00000000000 --- a/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: use of unstable library feature 'proc_macro_c_str_literals' - --> $DIR/feature-gate-proc_macro_c_str_literals.rs:10:5 - | -LL | Literal::c_string(c"a"); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information - = help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.rs b/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.rs new file mode 100644 index 00000000000..0e07d21b2f5 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.rs @@ -0,0 +1,11 @@ +// Don't panic when iterating through the `hir::Map::parent_iter` of an RPITIT. + +pub trait Foo { + fn demo() -> impl Foo + //~^ ERROR the trait bound `String: Copy` is not satisfied + where + String: Copy; + //~^ ERROR the trait bound `String: Copy` is not satisfied +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr b/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr new file mode 100644 index 00000000000..8ff8f12cdf4 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/synthetic-hir-has-parent.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/synthetic-hir-has-parent.rs:7:9 + | +LL | String: Copy; + | ^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | + = help: see issue #48214 +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/synthetic-hir-has-parent.rs:4:18 + | +LL | fn demo() -> impl Foo + | ^^^^^^^^ the trait `Copy` is not implemented for `String` + | + = help: see issue #48214 +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/layout/ice-non-last-unsized-field-issue-121473.rs b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.rs new file mode 100644 index 00000000000..737a7ffbc29 --- /dev/null +++ b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.rs @@ -0,0 +1,79 @@ +// Regression test for #121473 +// Checks that no ICE occurs when `size_of` +// is applied to a struct that has an unsized +// field which is not its last field + +use std::mem::size_of; + +pub struct BadStruct { + pub field1: i32, + pub field2: str, // Unsized field that is not the last field + //~^ ERROR the size for values of type `str` cannot be known at compilation time + pub field3: [u8; 16], +} + +enum BadEnum1 { + Variant1 { + field1: i32, + field2: str, // Unsized + //~^ ERROR the size for values of type `str` cannot be known at compilation time + field3: [u8; 16], + }, +} + +enum BadEnum2 { + Variant1( + i32, + str, // Unsized + //~^ ERROR the size for values of type `str` cannot be known at compilation time + [u8; 16] + ), +} + +enum BadEnumMultiVariant { + Variant1(i32), + Variant2 { + field1: i32, + field2: str, // Unsized + //~^ ERROR the size for values of type `str` cannot be known at compilation time + field3: [u8; 16], + }, + Variant3 +} + +union BadUnion { + field1: i32, + field2: str, // Unsized + //~^ ERROR the size for values of type `str` cannot be known at compilation time + //~| ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + field3: [u8; 16], +} + +// Used to test that projection type fields that normalize +// to a sized type do not cause problems +struct StructWithProjections<'a> +{ + field1: <&'a [i32] as IntoIterator>::IntoIter, + field2: i32 +} + +pub fn main() { + let _a = &size_of::<BadStruct>(); + assert_eq!(size_of::<BadStruct>(), 21); + + let _a = &size_of::<BadEnum1>(); + assert_eq!(size_of::<BadEnum1>(), 21); + + let _a = &size_of::<BadEnum2>(); + assert_eq!(size_of::<BadEnum2>(), 21); + + let _a = &size_of::<BadEnumMultiVariant>(); + assert_eq!(size_of::<BadEnumMultiVariant>(), 21); + + let _a = &size_of::<BadUnion>(); + assert_eq!(size_of::<BadUnion>(), 21); + + let _a = &size_of::<StructWithProjections>(); + assert_eq!(size_of::<StructWithProjections>(), 21); + let _a = StructWithProjections { field1: [1, 3].iter(), field2: 3 }; +} diff --git a/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr new file mode 100644 index 00000000000..626be7ac283 --- /dev/null +++ b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr @@ -0,0 +1,106 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:10:17 + | +LL | pub field2: str, // Unsized field that is not the last field + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: only the last field of a struct may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +LL | pub field2: &str, // Unsized field that is not the last field + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | pub field2: Box<str>, // Unsized field that is not the last field + | ++++ + + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:18:17 + | +LL | field2: str, // Unsized + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: no field of an enum variant may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +LL | field2: &str, // Unsized + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | field2: Box<str>, // Unsized + | ++++ + + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:27:9 + | +LL | str, // Unsized + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: no field of an enum variant may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +LL | &str, // Unsized + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | Box<str>, // Unsized + | ++++ + + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:37:17 + | +LL | field2: str, // Unsized + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: no field of an enum variant may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +LL | field2: &str, // Unsized + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | field2: Box<str>, // Unsized + | ++++ + + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:13 + | +LL | field2: str, // Unsized + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: no field of a union may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +LL | field2: &str, // Unsized + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | field2: Box<str>, // Unsized + | ++++ + + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:5 + | +LL | field2: str, // Unsized + | ^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | field2: std::mem::ManuallyDrop<str>, // Unsized + | +++++++++++++++++++++++ + + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0277, E0740. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/nll/match-cfg-fake-edges.rs b/tests/ui/nll/match-cfg-fake-edges.rs index 1afc7931a6b..e349c2c8e2a 100644 --- a/tests/ui/nll/match-cfg-fake-edges.rs +++ b/tests/ui/nll/match-cfg-fake-edges.rs @@ -3,10 +3,46 @@ #![feature(if_let_guard)] +#[rustfmt::skip] +fn all_patterns_are_tested() { + // Even though `x` is never actually moved out of, we don't want borrowck results to be based on + // whether MIR lowering reveals which patterns are unreachable. + let x = String::new(); + match true { + _ => {}, + _ => drop(x), + } + // Borrowck must not know the second arm is never run. + drop(x); //~ ERROR use of moved value + + let x = String::new(); + if let _ = true { //~ WARN irrefutable + } else { + drop(x) + } + // Borrowck must not know the else branch is never run. + drop(x); //~ ERROR use of moved value + + let x = (String::new(), String::new()); + match x { + (y, _) | (_, y) => (), + } + &x.0; //~ ERROR borrow of moved value + // Borrowck must not know the second pattern never matches. + &x.1; //~ ERROR borrow of moved value + + let x = (String::new(), String::new()); + let ((y, _) | (_, y)) = x; + &x.0; //~ ERROR borrow of moved value + // Borrowck must not know the second pattern never matches. + &x.1; //~ ERROR borrow of moved value +} + +#[rustfmt::skip] fn guard_always_precedes_arm(y: i32) { - let mut x; // x should always be initialized, as the only way to reach the arm is // through the guard. + let mut x; match y { 0 | 2 if { x = 2; true } => x, _ => 2, @@ -14,56 +50,69 @@ fn guard_always_precedes_arm(y: i32) { let mut x; match y { + _ => 2, + 0 | 2 if { x = 2; true } => x, + }; + + let mut x; + match y { 0 | 2 if let Some(()) = { x = 2; Some(()) } => x, _ => 2, }; } +#[rustfmt::skip] fn guard_may_be_skipped(y: i32) { + // Even though x *is* always initialized, we don't want to have borrowck results be based on + // whether MIR lowering reveals which patterns are exhaustive. + let x; + match y { + _ if { x = 2; true } => {}, + // Borrowck must not know the guard is always run. + _ => drop(x), //~ ERROR used binding `x` is possibly-uninitialized + }; + let x; - // Even though x *is* always initialized, we don't want to have borrowck - // results be based on whether patterns are exhaustive. match y { _ if { x = 2; true } => 1, - _ if { - x; //~ ERROR E0381 - false - } => 2, + // Borrowck must not know the guard is always run. + _ if { x; false } => 2, //~ ERROR used binding `x` isn't initialized _ => 3, }; let x; match y { _ if let Some(()) = { x = 2; Some(()) } => 1, - _ if let Some(()) = { - x; //~ ERROR E0381 - None - } => 2, + _ if let Some(()) = { x; None } => 2, //~ ERROR used binding `x` isn't initialized _ => 3, }; } +#[rustfmt::skip] fn guard_may_be_taken(y: bool) { - let x = String::new(); // Even though x *is* never moved before the use, we don't want to have // borrowck results be based on whether patterns are disjoint. + let x = String::new(); + match y { + false if { drop(x); true } => {}, + // Borrowck must not know the guard is not run in the `true` case. + true => drop(x), //~ ERROR use of moved value: `x` + false => {}, + }; + + // Fine in the other order. + let x = String::new(); match y { - false if { drop(x); true } => 1, - true => { - x; //~ ERROR use of moved value: `x` - 2 - } - false => 3, + true => drop(x), + false if { drop(x); true } => {}, + false => {}, }; let x = String::new(); match y { - false if let Some(()) = { drop(x); Some(()) } => 1, - true => { - x; //~ ERROR use of moved value: `x` - 2 - } - false => 3, + false if let Some(()) = { drop(x); Some(()) } => {}, + true => drop(x), //~ ERROR use of moved value: `x` + false => {}, }; } diff --git a/tests/ui/nll/match-cfg-fake-edges.stderr b/tests/ui/nll/match-cfg-fake-edges.stderr index a6261345cea..d692ded36fa 100644 --- a/tests/ui/nll/match-cfg-fake-edges.stderr +++ b/tests/ui/nll/match-cfg-fake-edges.stderr @@ -1,14 +1,128 @@ -error[E0381]: used binding `x` isn't initialized - --> $DIR/match-cfg-fake-edges.rs:29:13 +warning: irrefutable `if let` pattern + --> $DIR/match-cfg-fake-edges.rs:19:8 + | +LL | if let _ = true { + | ^^^^^^^^^^^^ + | + = note: this pattern will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` + = note: `#[warn(irrefutable_let_patterns)]` on by default + +error[E0382]: use of moved value: `x` + --> $DIR/match-cfg-fake-edges.rs:16:10 + | +LL | let x = String::new(); + | - move occurs because `x` has type `String`, which does not implement the `Copy` trait +... +LL | _ => drop(x), + | - value moved here +... +LL | drop(x); + | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | _ => drop(x.clone()), + | ++++++++ + +error[E0382]: use of moved value: `x` + --> $DIR/match-cfg-fake-edges.rs:24:10 + | +LL | let x = String::new(); + | - move occurs because `x` has type `String`, which does not implement the `Copy` trait +... +LL | drop(x) + | - value moved here +... +LL | drop(x); + | ^ value used here after move + | +help: consider cloning the value if the performance cost is acceptable + | +LL | drop(x.clone()) + | ++++++++ + +error[E0382]: borrow of moved value: `x.0` + --> $DIR/match-cfg-fake-edges.rs:30:5 + | +LL | (y, _) | (_, y) => (), + | - value moved here +LL | } +LL | &x.0; + | ^^^^ value borrowed here after move + | + = note: move occurs because `x.0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | (ref y, _) | (_, y) => (), + | +++ + +error[E0382]: borrow of moved value: `x.1` + --> $DIR/match-cfg-fake-edges.rs:32:5 + | +LL | (y, _) | (_, y) => (), + | - value moved here +... +LL | &x.1; + | ^^^^ value borrowed here after move + | + = note: move occurs because `x.1` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | (y, _) | (_, ref y) => (), + | +++ + +error[E0382]: borrow of moved value: `x.0` + --> $DIR/match-cfg-fake-edges.rs:36:5 + | +LL | let ((y, _) | (_, y)) = x; + | - value moved here +LL | &x.0; + | ^^^^ value borrowed here after move + | + = note: move occurs because `x.0` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ((ref y, _) | (_, y)) = x; + | +++ + +error[E0382]: borrow of moved value: `x.1` + --> $DIR/match-cfg-fake-edges.rs:38:5 + | +LL | let ((y, _) | (_, y)) = x; + | - value moved here +... +LL | &x.1; + | ^^^^ value borrowed here after move + | + = note: move occurs because `x.1` has type `String`, which does not implement the `Copy` trait +help: borrow this binding in the pattern to avoid moving the value + | +LL | let ((y, _) | (_, ref y)) = x; + | +++ + +error[E0381]: used binding `x` is possibly-uninitialized + --> $DIR/match-cfg-fake-edges.rs:72:19 | LL | let x; | - binding declared here but left uninitialized ... +LL | _ => drop(x), + | - ^ `x` used here but it is possibly-uninitialized + | | + | if this pattern is matched, `x` is not initialized + +error[E0381]: used binding `x` isn't initialized + --> $DIR/match-cfg-fake-edges.rs:79:16 + | +LL | let x; + | - binding declared here but left uninitialized +LL | match y { LL | _ if { x = 2; true } => 1, | ----- binding initialized here in some conditions -LL | _ if { -LL | x; - | ^ `x` used here but it isn't initialized +LL | // Borrowck must not know the guard is always run. +LL | _ if { x; false } => 2, + | ^ `x` used here but it isn't initialized | help: consider assigning a value | @@ -16,16 +130,15 @@ LL | let x = 0; | +++ error[E0381]: used binding `x` isn't initialized - --> $DIR/match-cfg-fake-edges.rs:39:13 + --> $DIR/match-cfg-fake-edges.rs:86:31 | LL | let x; | - binding declared here but left uninitialized LL | match y { LL | _ if let Some(()) = { x = 2; Some(()) } => 1, | ----- binding initialized here in some conditions -LL | _ if let Some(()) = { -LL | x; - | ^ `x` used here but it isn't initialized +LL | _ if let Some(()) = { x; None } => 2, + | ^ `x` used here but it isn't initialized | help: consider assigning a value | @@ -33,40 +146,39 @@ LL | let x = 0; | +++ error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:53:13 + --> $DIR/match-cfg-fake-edges.rs:99:22 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait -... -LL | false if { drop(x); true } => 1, +LL | match y { +LL | false if { drop(x); true } => {}, | - value moved here -LL | true => { -LL | x; - | ^ value used here after move +LL | // Borrowck must not know the guard is not run in the `true` case. +LL | true => drop(x), + | ^ value used here after move | help: consider cloning the value if the performance cost is acceptable | -LL | false if { drop(x.clone()); true } => 1, +LL | false if { drop(x.clone()); true } => {}, | ++++++++ error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:63:13 + --> $DIR/match-cfg-fake-edges.rs:114:22 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait LL | match y { -LL | false if let Some(()) = { drop(x); Some(()) } => 1, +LL | false if let Some(()) = { drop(x); Some(()) } => {}, | - value moved here -LL | true => { -LL | x; - | ^ value used here after move +LL | true => drop(x), + | ^ value used here after move | help: consider cloning the value if the performance cost is acceptable | -LL | false if let Some(()) = { drop(x.clone()); Some(()) } => 1, +LL | false if let Some(()) = { drop(x.clone()); Some(()) } => {}, | ++++++++ -error: aborting due to 4 previous errors +error: aborting due to 11 previous errors; 1 warning emitted Some errors have detailed explanations: E0381, E0382. For more information about an error, try `rustc --explain E0381`. diff --git a/tests/ui/nll/match-cfg-fake-edges2.rs b/tests/ui/nll/match-cfg-fake-edges2.rs index 48f95e03b78..ac90fb9cd1e 100644 --- a/tests/ui/nll/match-cfg-fake-edges2.rs +++ b/tests/ui/nll/match-cfg-fake-edges2.rs @@ -5,13 +5,20 @@ fn all_previous_tests_may_be_done(y: &mut (bool, bool)) { let r = &mut y.1; // We don't actually test y.1 to select the second arm, but we don't want // borrowck results to be based on the order we match patterns. - match y { //~ ERROR cannot use `y.1` because it was mutably borrowed - (false, true) => 1, - (true, _) => { - r; - 2 - } - (false, _) => 3, + match y { + //~^ ERROR cannot use `y.1` because it was mutably borrowed + (false, true) => {} + // Borrowck must not know we don't test `y.1` when `y.0` is `true`. + (true, _) => drop(r), + (false, _) => {} + }; + + // Fine in the other order. + let r = &mut y.1; + match y { + (true, _) => drop(r), + (false, true) => {} + (false, _) => {} }; } diff --git a/tests/ui/nll/match-cfg-fake-edges2.stderr b/tests/ui/nll/match-cfg-fake-edges2.stderr index 639cba1406a..0a228d62b92 100644 --- a/tests/ui/nll/match-cfg-fake-edges2.stderr +++ b/tests/ui/nll/match-cfg-fake-edges2.stderr @@ -7,8 +7,8 @@ LL | let r = &mut y.1; LL | match y { | ^^^^^^^ use of borrowed `y.1` ... -LL | r; - | - borrow later used here +LL | (true, _) => drop(r), + | - borrow later used here error: aborting due to 1 previous error diff --git a/tests/ui/parser/fn-header-semantic-fail.rs b/tests/ui/parser/fn-header-semantic-fail.rs index 25d7c3f35fc..6ed173b6854 100644 --- a/tests/ui/parser/fn-header-semantic-fail.rs +++ b/tests/ui/parser/fn-header-semantic-fail.rs @@ -48,6 +48,9 @@ fn main() { const fn fe3(); //~ ERROR functions in `extern` blocks cannot have qualifiers extern "C" fn fe4(); //~ ERROR functions in `extern` blocks cannot have qualifiers const async unsafe extern "C" fn fe5(); //~ ERROR functions in `extern` blocks - //~^ ERROR functions cannot be both `const` and `async` + //~| ERROR functions in `extern` blocks + //~| ERROR functions in `extern` blocks + //~| ERROR functions in `extern` blocks + //~| ERROR functions cannot be both `const` and `async` } } diff --git a/tests/ui/parser/fn-header-semantic-fail.stderr b/tests/ui/parser/fn-header-semantic-fail.stderr index 696d8e01b63..cfc54839eb7 100644 --- a/tests/ui/parser/fn-header-semantic-fail.stderr +++ b/tests/ui/parser/fn-header-semantic-fail.stderr @@ -71,73 +71,75 @@ LL | const async unsafe extern "C" fn fi5() {} | `const` because of this error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:46:18 + --> $DIR/fn-header-semantic-fail.rs:46:9 | LL | extern "C" { | ---------- in this `extern` block LL | async fn fe1(); - | ^^^ - | -help: remove the qualifiers - | -LL | fn fe1(); - | ~~ + | ^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:47:19 + --> $DIR/fn-header-semantic-fail.rs:47:9 | LL | extern "C" { | ---------- in this `extern` block LL | async fn fe1(); LL | unsafe fn fe2(); - | ^^^ - | -help: remove the qualifiers - | -LL | fn fe2(); - | ~~ + | ^^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:48:18 + --> $DIR/fn-header-semantic-fail.rs:48:9 | LL | extern "C" { | ---------- in this `extern` block ... LL | const fn fe3(); - | ^^^ - | -help: remove the qualifiers - | -LL | fn fe3(); - | ~~ + | ^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:49:23 + --> $DIR/fn-header-semantic-fail.rs:49:9 | LL | extern "C" { | ---------- in this `extern` block ... LL | extern "C" fn fe4(); - | ^^^ - | -help: remove the qualifiers + | ^^^^^^^^^^ help: remove this qualifier + +error: functions in `extern` blocks cannot have qualifiers + --> $DIR/fn-header-semantic-fail.rs:50:21 | -LL | fn fe4(); - | ~~ +LL | extern "C" { + | ---------- in this `extern` block +... +LL | const async unsafe extern "C" fn fe5(); + | ^^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:50:42 + --> $DIR/fn-header-semantic-fail.rs:50:15 | LL | extern "C" { | ---------- in this `extern` block ... LL | const async unsafe extern "C" fn fe5(); - | ^^^ + | ^^^^^ help: remove this qualifier + +error: functions in `extern` blocks cannot have qualifiers + --> $DIR/fn-header-semantic-fail.rs:50:9 | -help: remove the qualifiers +LL | extern "C" { + | ---------- in this `extern` block +... +LL | const async unsafe extern "C" fn fe5(); + | ^^^^^ help: remove this qualifier + +error: functions in `extern` blocks cannot have qualifiers + --> $DIR/fn-header-semantic-fail.rs:50:28 | -LL | fn fe5(); - | ~~ +LL | extern "C" { + | ---------- in this `extern` block +... +LL | const async unsafe extern "C" fn fe5(); + | ^^^^^^^^^^ help: remove this qualifier error: functions cannot be both `const` and `async` --> $DIR/fn-header-semantic-fail.rs:50:9 @@ -148,6 +150,6 @@ LL | const async unsafe extern "C" fn fe5(); | | `async` because of this | `const` because of this -error: aborting due to 14 previous errors +error: aborting due to 17 previous errors For more information about this error, try `rustc --explain E0379`. diff --git a/tests/ui/parser/no-const-fn-in-extern-block.rs b/tests/ui/parser/no-const-fn-in-extern-block.rs index 1993124edc3..d6c578681cc 100644 --- a/tests/ui/parser/no-const-fn-in-extern-block.rs +++ b/tests/ui/parser/no-const-fn-in-extern-block.rs @@ -3,6 +3,7 @@ extern "C" { //~^ ERROR functions in `extern` blocks cannot have qualifiers const unsafe fn bar(); //~^ ERROR functions in `extern` blocks cannot have qualifiers + //~| ERROR functions in `extern` blocks cannot have qualifiers } fn main() {} diff --git a/tests/ui/parser/no-const-fn-in-extern-block.stderr b/tests/ui/parser/no-const-fn-in-extern-block.stderr index 4ac0e265501..948ce669112 100644 --- a/tests/ui/parser/no-const-fn-in-extern-block.stderr +++ b/tests/ui/parser/no-const-fn-in-extern-block.stderr @@ -1,29 +1,28 @@ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/no-const-fn-in-extern-block.rs:2:14 + --> $DIR/no-const-fn-in-extern-block.rs:2:5 | LL | extern "C" { | ---------- in this `extern` block LL | const fn foo(); - | ^^^ - | -help: remove the qualifiers - | -LL | fn foo(); - | ~~ + | ^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/no-const-fn-in-extern-block.rs:4:21 + --> $DIR/no-const-fn-in-extern-block.rs:4:11 | LL | extern "C" { | ---------- in this `extern` block ... LL | const unsafe fn bar(); - | ^^^ - | -help: remove the qualifiers + | ^^^^^^ help: remove this qualifier + +error: functions in `extern` blocks cannot have qualifiers + --> $DIR/no-const-fn-in-extern-block.rs:4:5 | -LL | fn bar(); - | ~~ +LL | extern "C" { + | ---------- in this `extern` block +... +LL | const unsafe fn bar(); + | ^^^^^ help: remove this qualifier -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/parser/unsafe-foreign-mod-2.stderr b/tests/ui/parser/unsafe-foreign-mod-2.stderr index 7cc2de141ae..fc05184f018 100644 --- a/tests/ui/parser/unsafe-foreign-mod-2.stderr +++ b/tests/ui/parser/unsafe-foreign-mod-2.stderr @@ -11,18 +11,13 @@ LL | extern "C" unsafe { | ^^^^^^ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/unsafe-foreign-mod-2.rs:4:15 + --> $DIR/unsafe-foreign-mod-2.rs:4:5 | LL | extern "C" unsafe { | ----------------- in this `extern` block ... LL | unsafe fn foo(); - | ^^^ - | -help: remove the qualifiers - | -LL | fn foo(); - | ~~ + | ^^^^^^ help: remove this qualifier error: aborting due to 3 previous errors diff --git a/tests/ui/proc-macro/auxiliary/api/mod.rs b/tests/ui/proc-macro/auxiliary/api/mod.rs index 199d097336a..45ef6922d28 100644 --- a/tests/ui/proc-macro/auxiliary/api/mod.rs +++ b/tests/ui/proc-macro/auxiliary/api/mod.rs @@ -5,8 +5,6 @@ #![crate_type = "proc-macro"] #![crate_name = "proc_macro_api_tests"] #![feature(proc_macro_span)] -#![feature(proc_macro_byte_character)] -#![feature(proc_macro_c_str_literals)] #![deny(dead_code)] // catch if a test function is never called extern crate proc_macro; diff --git a/tests/ui/unpretty/hir-tree.rs b/tests/ui/unpretty/hir-tree.rs new file mode 100644 index 00000000000..3388c60c425 --- /dev/null +++ b/tests/ui/unpretty/hir-tree.rs @@ -0,0 +1,10 @@ +//@ build-pass +//@ compile-flags: -o - -Zunpretty=hir-tree +//@ check-stdout +//@ dont-check-compiler-stdout +//@ dont-check-compiler-stderr +//@ regex-error-pattern: Hello, Rustaceans! + +fn main() { + println!("Hello, Rustaceans!"); +} |
