diff options
Diffstat (limited to 'src')
2 files changed, 45 insertions, 17 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed index 0787ac7c77b..d0fad7b07df 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed @@ -9,7 +9,7 @@ struct InsignificantDropPoint { x: i32, - y: Mutex<T>, + y: Mutex<i32>, } impl Drop for InsignificantDropPoint { @@ -17,7 +17,7 @@ impl Drop for InsignificantDropPoint { fn drop(&mut self) {} } -struct SigDrop { x: () } +struct SigDrop; impl Drop for SigDrop { fn drop(&mut self) {} @@ -45,9 +45,10 @@ fn insign_dtor() { // `SigDrop` implements drop and therefore needs to be migrated. fn significant_drop_needs_migration() { - let t = (SigDrop { x: () }, SigDrop { x: () }); + let t = (SigDrop {}, SigDrop {}); let c = || { + let _ = &t; //~^ ERROR: drop order //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `t` to be fully captured @@ -64,10 +65,11 @@ fn significant_drop_needs_migration() { // consdered to have an significant drop. Since the elements // of `GenericStruct` implement drop, migration is required. fn generic_struct_with_significant_drop_needs_migration() { - let t = Wrapper(GenericStruct(SigDrop { x: () }, SigDrop { x: () }), 5); + let t = Wrapper(GenericStruct(SigDrop {}, SigDrop {}), 5); // move is used to force i32 to be copied instead of being a ref let c = move || { + let _ = &t; //~^ ERROR: drop order //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `t` to be fully captured diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr index 80289d6289d..c20bd572af8 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr @@ -1,19 +1,45 @@ -error[E0107]: missing generics for struct `Mutex` - --> $DIR/insignificant_drop_attr_migrations.rs:12:8 +error: changes to closure capture in Rust 2021 will affect drop order + --> $DIR/insignificant_drop_attr_migrations.rs:50:13 | -LL | y: Mutex, - | ^^^^^ expected 1 generic argument +LL | let c = || { + | ^^ +... +LL | let _t = t.0; + | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0` +... +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure | -note: struct defined here, with 1 generic parameter: `T` - --> $SRC_DIR/std/src/sync/mutex.rs:LL:COL +note: the lint level is defined here + --> $DIR/insignificant_drop_attr_migrations.rs:3:9 | -LL | pub struct Mutex<T: ?Sized> { - | ^^^^^ - -help: add missing generic argument +LL | #![deny(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> +help: add a dummy let to cause `t` to be fully captured + | +LL ~ let c = || { +LL + let _ = &t; + | + +error: changes to closure capture in Rust 2021 will affect drop order + --> $DIR/insignificant_drop_attr_migrations.rs:70:13 + | +LL | let c = move || { + | ^^^^^^^ +... +LL | let _t = t.1; + | --- in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1` +... +LL | } + | - in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure + | + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html> +help: add a dummy let to cause `t` to be fully captured + | +LL ~ let c = move || { +LL + let _ = &t; | -LL | y: Mutex<T>, - | ~~~~~~~~ -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0107`. |
