Rename disjoint_capture_migration lint to rust_2021_incompatible_closure_captures

This commit is contained in:
Ryan Levick 2021-06-29 15:35:15 +02:00
parent b09dad3edd
commit bbfb8579ff
27 changed files with 180 additions and 177 deletions

View File

@ -2967,7 +2967,7 @@ declare_lint_pass! {
MISSING_ABI,
INVALID_DOC_ATTRIBUTES,
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
DISJOINT_CAPTURE_MIGRATION,
RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
LEGACY_DERIVE_HELPERS,
PROC_MACRO_BACK_COMPAT,
OR_PATTERNS_BACK_COMPAT,
@ -3002,7 +3002,7 @@ declare_lint! {
}
declare_lint! {
/// The `disjoint_capture_migration` lint detects variables that aren't completely
/// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely
/// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable.
/// It can also detect when a variable implements a trait, but one of its field does not and
/// the field is captured by a closure and used with the assumption that said field implements
@ -3011,7 +3011,7 @@ declare_lint! {
/// ### Example of drop reorder
///
/// ```rust,compile_fail
/// # #![deny(disjoint_capture_migration)]
/// # #![deny(rust_2021_incompatible_closure_captures)]
/// # #![allow(unused)]
/// struct FancyInteger(i32);
///
@ -3046,7 +3046,7 @@ declare_lint! {
/// ### Example of auto-trait
///
/// ```rust,compile_fail
/// #![deny(disjoint_capture_migration)]
/// #![deny(rust_2021_incompatible_closure_captures)]
/// use std::thread;
///
/// struct Pointer(*mut i32);
@ -3068,7 +3068,7 @@ declare_lint! {
/// In the above example, only `fptr.0` is captured in Rust 2021.
/// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
/// field cannot be sent between thread safely.
pub DISJOINT_CAPTURE_MIGRATION,
pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
Allow,
"detects closures affected by Rust 2021 changes",
@future_incompatible = FutureIncompatibleInfo {

View File

@ -173,7 +173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
if should_do_disjoint_capture_migration_analysis(self.tcx, closure_hir_id) {
if should_do_rust_2021_incompatible_closure_captures_analysis(self.tcx, closure_hir_id) {
self.perform_2229_migration_anaysis(closure_def_id, body_id, capture_clause, span);
}
@ -505,7 +505,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let local_def_id = closure_def_id.expect_local();
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
self.tcx.struct_span_lint_hir(
lint::builtin::DISJOINT_CAPTURE_MIGRATION,
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
closure_hir_id,
span,
|lint| {
@ -1829,8 +1829,9 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
tcx.hir().name(var_hir_id)
}
fn should_do_disjoint_capture_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool {
let (level, _) = tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_MIGRATION, closure_id);
fn should_do_rust_2021_incompatible_closure_captures_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool {
let (level, _) =
tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id);
!matches!(level, lint::Level::Allow)
}

View File

@ -1,10 +1,10 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
use std::thread;
/* Test Send Trait Migration */
struct SendPointer (*mut i32);
struct SendPointer(*mut i32);
unsafe impl Send for SendPointer {}
fn test_send_trait() {
@ -18,8 +18,8 @@ fn test_send_trait() {
}
/* Test Sync Trait Migration */
struct CustomInt (*mut i32);
struct SyncPointer (CustomInt);
struct CustomInt(*mut i32);
struct SyncPointer(CustomInt);
unsafe impl Sync for SyncPointer {}
unsafe impl Send for CustomInt {}
@ -38,7 +38,7 @@ fn test_sync_trait() {
struct S(String);
struct T(i32);
struct U(S,T);
struct U(S, T);
impl Clone for U {
fn clone(&self) -> Self {

View File

@ -1,10 +1,10 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
use std::thread;
/* Test Send Trait Migration */
struct SendPointer (*mut i32);
struct SendPointer(*mut i32);
unsafe impl Send for SendPointer {}
fn test_send_trait() {
@ -18,8 +18,8 @@ fn test_send_trait() {
}
/* Test Sync Trait Migration */
struct CustomInt (*mut i32);
struct SyncPointer (CustomInt);
struct CustomInt(*mut i32);
struct SyncPointer(CustomInt);
unsafe impl Sync for SyncPointer {}
unsafe impl Send for CustomInt {}
@ -38,7 +38,7 @@ fn test_sync_trait() {
struct S(String);
struct T(i32);
struct U(S,T);
struct U(S, T);
impl Clone for U {
fn clone(&self) -> Self {

View File

@ -12,8 +12,8 @@ LL | | });
note: the lint level is defined here
--> $DIR/auto_traits.rs:2:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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 `fptr` to be fully captured
|

View File

@ -1,6 +1,6 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
// Test cases for types that implement a insignificant drop (stlib defined)
@ -13,9 +13,9 @@ fn test1_all_need_migration() {
let t2 = (String::new(), String::new());
let c = || { let _ = (&t, &t1, &t2);
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0;
let _t1 = t1.0;
@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (String::new(), String::new());
let c = || { let _ = (&t, &t1);
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() {
let t = (String::new(), String::new());
let t1 = (String::new(), String::new());
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{}", t1.1);
};
@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() {
let t1 = (0i32, 0i32);
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _t1 = t1.0;
};
@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() {
let s = S(0i32, 0i32);
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _s = s.0;
};
@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
let t = (String::new(), String::new());
let t1 = (String::new(), String::new());
let c = move || { let _ = (&t1, &t);
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{} {}", t1.1, t.1);
};
@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() {
let t = (String::new(), String::new(), 0i32);
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};

View File

@ -1,6 +1,6 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
// Test cases for types that implement a insignificant drop (stlib defined)
@ -13,9 +13,9 @@ fn test1_all_need_migration() {
let t2 = (String::new(), String::new());
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0;
let _t1 = t1.0;
@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (String::new(), String::new());
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() {
let t = (String::new(), String::new());
let t1 = (String::new(), String::new());
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{}", t1.1);
};
@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() {
let t1 = (0i32, 0i32);
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _t1 = t1.0;
};
@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() {
let s = S(0i32, 0i32);
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _s = s.0;
};
@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
let t = (String::new(), String::new());
let t1 = (String::new(), String::new());
let c = move || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{} {}", t1.1, t.1);
};
@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() {
let t = (String::new(), String::new(), 0i32);
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};

View File

@ -14,8 +14,8 @@ LL | | };
note: the lint level is defined here
--> $DIR/insignificant_drop.rs:3:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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`, `t1`, `t2` to be fully captured
|

View File

@ -1,8 +1,7 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
#![feature(rustc_attrs)]
#![allow(unused)]
@ -36,9 +35,9 @@ fn significant_drop_needs_migration() {
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
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};
@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() {
// 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
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1;
};

View File

@ -1,8 +1,7 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
#![feature(rustc_attrs)]
#![allow(unused)]
@ -36,9 +35,9 @@ fn significant_drop_needs_migration() {
let t = (SigDrop {}, SigDrop {});
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};
@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() {
// move is used to force i32 to be copied instead of being a ref
let c = move || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1;
};

View File

@ -1,5 +1,5 @@
error: drop order will change in Rust 2021
--> $DIR/insignificant_drop_attr_migrations.rs:38:13
--> $DIR/insignificant_drop_attr_migrations.rs:37:13
|
LL | let c = || {
| _____________^
@ -13,8 +13,8 @@ LL | | };
note: the lint level is defined here
--> $DIR/insignificant_drop_attr_migrations.rs:3:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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
|
@ -27,7 +27,7 @@ LL | };
|
error: drop order will change in Rust 2021
--> $DIR/insignificant_drop_attr_migrations.rs:56:13
--> $DIR/insignificant_drop_attr_migrations.rs:55:13
|
LL | let c = move || {
| _____________^

View File

@ -1,6 +1,6 @@
// run-pass
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
#![feature(rustc_attrs)]
#![allow(unused)]

View File

@ -1,10 +1,10 @@
// run-pass
#![warn(disjoint_capture_migration)]
#![warn(rust_2021_incompatible_closure_captures)]
fn main() {
if let a = "" {
//~^ WARNING: irrefutable `if let` pattern
//~^ WARNING: irrefutable `if let` pattern
drop(|_: ()| drop(a));
}
}

View File

@ -1,5 +1,5 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
// Test the two possible cases for automated migartion using rustfix

View File

@ -1,5 +1,5 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
// Test the two possible cases for automated migartion using rustfix

View File

@ -13,8 +13,8 @@ LL | | };
note: the lint level is defined here
--> $DIR/migrations_rustfix.rs:2:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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
|

View File

@ -1,16 +1,20 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(fn_traits)]
#![feature(never_type)]
use std::panic;
fn foo_diverges() -> ! { panic!() }
fn foo_diverges() -> ! {
panic!()
}
fn assert_panics<F>(f: F) where F: FnOnce() {
fn assert_panics<F>(f: F)
where
F: FnOnce(),
{
let f = panic::AssertUnwindSafe(f);
let result = panic::catch_unwind(move || { let _ = &f;
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation
@ -23,7 +27,8 @@ fn assert_panics<F>(f: F) where F: FnOnce() {
}
fn test_fn_ptr_panic<T>(mut t: T)
where T: Fn() -> !
where
T: Fn() -> !,
{
let as_fn = <T as Fn<()>>::call;
assert_panics(|| as_fn(&t, ()));

View File

@ -1,16 +1,20 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(fn_traits)]
#![feature(never_type)]
use std::panic;
fn foo_diverges() -> ! { panic!() }
fn foo_diverges() -> ! {
panic!()
}
fn assert_panics<F>(f: F) where F: FnOnce() {
fn assert_panics<F>(f: F)
where
F: FnOnce(),
{
let f = panic::AssertUnwindSafe(f);
let result = panic::catch_unwind(move || {
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation
@ -23,7 +27,8 @@ fn assert_panics<F>(f: F) where F: FnOnce() {
}
fn test_fn_ptr_panic<T>(mut t: T)
where T: Fn() -> !
where
T: Fn() -> !,
{
let as_fn = <T as Fn<()>>::call;
assert_panics(|| as_fn(&t, ()));

View File

@ -1,5 +1,5 @@
error: `UnwindSafe`, `RefUnwindSafe` trait implementation will change in Rust 2021
--> $DIR/mir_calls_to_shims.rs:15:38
--> $DIR/mir_calls_to_shims.rs:19:38
|
LL | let result = panic::catch_unwind(move || {
| ______________________________________^
@ -12,8 +12,8 @@ LL | | });
note: the lint level is defined here
--> $DIR/mir_calls_to_shims.rs:3:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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 `f` to be fully captured
|

View File

@ -2,8 +2,7 @@
// Set of test cases that don't need migrations
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
// Copy types as copied by the closure instead of being moved into the closure
// Therefore their drop order isn't tied to the closure and won't be requiring any
@ -53,7 +52,6 @@ fn test4_insignificant_drop_non_drop_aggregate() {
c();
}
struct Foo(i32);
impl Drop for Foo {
fn drop(&mut self) {
@ -80,5 +78,4 @@ fn main() {
test3_only_copy_types_move_closure();
test4_insignificant_drop_non_drop_aggregate();
test5_significant_drop_non_drop_aggregate();
}

View File

@ -1,6 +1,6 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
#[derive(Debug)]
struct Foo(i32);
@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
let t = ConstainsDropField(Foo(10), Foo(20));
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _t = &t.1;
};
@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
struct S;
impl Drop for S {
fn drop(&mut self) {
}
fn drop(&mut self) {}
}
struct T(S, S);
@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() {
let u = U(T(S, S), T(S, S));
let c = || { let _ = &u;
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `u` to be fully captured
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `u` to be fully captured
let _x = u.0.0;
let _x = u.0.1;
let _x = u.1.0;

View File

@ -1,6 +1,6 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
#[derive(Debug)]
struct Foo(i32);
@ -17,8 +17,8 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
let t = ConstainsDropField(Foo(10), Foo(20));
let c = || {
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _t = &t.1;
};
@ -28,8 +28,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
struct S;
impl Drop for S {
fn drop(&mut self) {
}
fn drop(&mut self) {}
}
struct T(S, S);
@ -40,8 +39,8 @@ fn test_precise_analysis_long_path_missing() {
let u = U(T(S, S), T(S, S));
let c = || {
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `u` to be fully captured
//~^ ERROR: drop order
//~| HELP: add a dummy let to cause `u` to be fully captured
let _x = u.0.0;
let _x = u.0.1;
let _x = u.1.0;

View File

@ -13,8 +13,8 @@ LL | | };
note: the lint level is defined here
--> $DIR/precise.rs:3:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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
|
@ -27,7 +27,7 @@ LL | };
|
error: drop order will change in Rust 2021
--> $DIR/precise.rs:42:13
--> $DIR/precise.rs:41:13
|
LL | let c = || {
| _____________^

View File

@ -1,6 +1,6 @@
// run-pass
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
#[derive(Debug)]
struct Foo(i32);
@ -73,8 +73,7 @@ fn test_precise_analysis_parent_captured_2() {
struct S;
impl Drop for S {
fn drop(&mut self) {
}
fn drop(&mut self) {}
}
struct T(S, S);

View File

@ -1,5 +1,5 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
// Test cases for types that implement a significant drop (user defined)
@ -23,9 +23,9 @@ fn test1_all_need_migration() {
let t2 = (Foo(0), Foo(0));
let c = || { let _ = (&t, &t1, &t2);
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2.0;
@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (Foo(0), Foo(0));
let c = || { let _ = (&t, &t1);
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() {
let t = (Foo(0), Foo(0));
let t1 = (Foo(0), Foo(0));
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{:?}", t1.1);
};
@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() {
let t = ConstainsDropField(Foo(0), Foo(0));
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};
@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() {
let t = (Foo(0), Foo(0), 0i32);
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};
@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() {
let t = (Foo(0), String::new());
let c = || { let _ = &t;
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1;
};
@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
let t1 = (Foo(0), Foo(0), Foo(0));
let c = move || { let _ = (&t1, &t);
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{:?} {:?}", t1.1, t.1);
};

View File

@ -1,5 +1,5 @@
// run-rustfix
#![deny(disjoint_capture_migration)]
#![deny(rust_2021_incompatible_closure_captures)]
//~^ NOTE: the lint level is defined here
// Test cases for types that implement a significant drop (user defined)
@ -23,9 +23,9 @@ fn test1_all_need_migration() {
let t2 = (Foo(0), Foo(0));
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2.0;
@ -42,9 +42,9 @@ fn test2_only_precise_paths_need_migration() {
let t2 = (Foo(0), Foo(0));
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
@ -59,9 +59,9 @@ fn test3_only_by_value_need_migration() {
let t = (Foo(0), Foo(0));
let t1 = (Foo(0), Foo(0));
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{:?}", t1.1);
};
@ -77,9 +77,9 @@ fn test4_type_contains_drop_need_migration() {
let t = ConstainsDropField(Foo(0), Foo(0));
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};
@ -93,9 +93,9 @@ fn test5_drop_non_drop_aggregate_need_migration() {
let t = (Foo(0), Foo(0), 0i32);
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};
@ -107,9 +107,9 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() {
let t = (Foo(0), String::new());
let c = || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.1;
};
@ -123,9 +123,9 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
let t1 = (Foo(0), Foo(0), Foo(0));
let c = move || {
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
//~^ ERROR: drop order
//~| NOTE: for more information, see
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{:?} {:?}", t1.1, t.1);
};

View File

@ -14,8 +14,8 @@ LL | | };
note: the lint level is defined here
--> $DIR/significant_drop.rs:2:9
|
LL | #![deny(disjoint_capture_migration)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
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`, `t1`, `t2` to be fully captured
|