mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rename disjoint_capture_migration lint to rust_2021_incompatible_closure_captures
This commit is contained in:
parent
b09dad3edd
commit
bbfb8579ff
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -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 || {
|
||||
| _____________^
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-pass
|
||||
|
||||
#![deny(disjoint_capture_migration)]
|
||||
#![deny(rust_2021_incompatible_closure_captures)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(unused)]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-pass
|
||||
|
||||
#![warn(disjoint_capture_migration)]
|
||||
#![warn(rust_2021_incompatible_closure_captures)]
|
||||
|
||||
fn main() {
|
||||
if let a = "" {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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, ()));
|
||||
|
@ -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, ()));
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![deny(disjoint_capture_migration)]
|
||||
#![deny(rust_2021_incompatible_closure_captures)]
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo(i32);
|
||||
@ -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);
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-rustfix
|
||||
|
||||
#![deny(disjoint_capture_migration)]
|
||||
#![deny(rust_2021_incompatible_closure_captures)]
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo(i32);
|
||||
@ -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);
|
||||
|
@ -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 = || {
|
||||
| _____________^
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user