Skip to content

Commit bbfb857

Browse files
committed
Rename disjoint_capture_migration lint to rust_2021_incompatible_closure_captures
1 parent b09dad3 commit bbfb857

27 files changed

+180
-177
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,7 +2967,7 @@ declare_lint_pass! {
29672967
MISSING_ABI,
29682968
INVALID_DOC_ATTRIBUTES,
29692969
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2970-
DISJOINT_CAPTURE_MIGRATION,
2970+
RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
29712971
LEGACY_DERIVE_HELPERS,
29722972
PROC_MACRO_BACK_COMPAT,
29732973
OR_PATTERNS_BACK_COMPAT,
@@ -3002,7 +3002,7 @@ declare_lint! {
30023002
}
30033003

30043004
declare_lint! {
3005-
/// The `disjoint_capture_migration` lint detects variables that aren't completely
3005+
/// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely
30063006
/// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable.
30073007
/// It can also detect when a variable implements a trait, but one of its field does not and
30083008
/// the field is captured by a closure and used with the assumption that said field implements
@@ -3011,7 +3011,7 @@ declare_lint! {
30113011
/// ### Example of drop reorder
30123012
///
30133013
/// ```rust,compile_fail
3014-
/// # #![deny(disjoint_capture_migration)]
3014+
/// # #![deny(rust_2021_incompatible_closure_captures)]
30153015
/// # #![allow(unused)]
30163016
/// struct FancyInteger(i32);
30173017
///
@@ -3046,7 +3046,7 @@ declare_lint! {
30463046
/// ### Example of auto-trait
30473047
///
30483048
/// ```rust,compile_fail
3049-
/// #![deny(disjoint_capture_migration)]
3049+
/// #![deny(rust_2021_incompatible_closure_captures)]
30503050
/// use std::thread;
30513051
///
30523052
/// struct Pointer(*mut i32);
@@ -3068,7 +3068,7 @@ declare_lint! {
30683068
/// In the above example, only `fptr.0` is captured in Rust 2021.
30693069
/// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
30703070
/// field cannot be sent between thread safely.
3071-
pub DISJOINT_CAPTURE_MIGRATION,
3071+
pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
30723072
Allow,
30733073
"detects closures affected by Rust 2021 changes",
30743074
@future_incompatible = FutureIncompatibleInfo {

compiler/rustc_typeck/src/check/upvar.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
173173

174174
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
175175

176-
if should_do_disjoint_capture_migration_analysis(self.tcx, closure_hir_id) {
176+
if should_do_rust_2021_incompatible_closure_captures_analysis(self.tcx, closure_hir_id) {
177177
self.perform_2229_migration_anaysis(closure_def_id, body_id, capture_clause, span);
178178
}
179179

@@ -505,7 +505,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
505505
let local_def_id = closure_def_id.expect_local();
506506
let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
507507
self.tcx.struct_span_lint_hir(
508-
lint::builtin::DISJOINT_CAPTURE_MIGRATION,
508+
lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
509509
closure_hir_id,
510510
span,
511511
|lint| {
@@ -1829,8 +1829,9 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
18291829
tcx.hir().name(var_hir_id)
18301830
}
18311831

1832-
fn should_do_disjoint_capture_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool {
1833-
let (level, _) = tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_MIGRATION, closure_id);
1832+
fn should_do_rust_2021_incompatible_closure_captures_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool {
1833+
let (level, _) =
1834+
tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id);
18341835

18351836
!matches!(level, lint::Level::Allow)
18361837
}

src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// run-rustfix
2-
#![deny(disjoint_capture_migration)]
2+
#![deny(rust_2021_incompatible_closure_captures)]
33

44
use std::thread;
55

66
/* Test Send Trait Migration */
7-
struct SendPointer (*mut i32);
7+
struct SendPointer(*mut i32);
88
unsafe impl Send for SendPointer {}
99

1010
fn test_send_trait() {
@@ -18,8 +18,8 @@ fn test_send_trait() {
1818
}
1919

2020
/* Test Sync Trait Migration */
21-
struct CustomInt (*mut i32);
22-
struct SyncPointer (CustomInt);
21+
struct CustomInt(*mut i32);
22+
struct SyncPointer(CustomInt);
2323
unsafe impl Sync for SyncPointer {}
2424
unsafe impl Send for CustomInt {}
2525

@@ -38,7 +38,7 @@ fn test_sync_trait() {
3838
struct S(String);
3939
struct T(i32);
4040

41-
struct U(S,T);
41+
struct U(S, T);
4242

4343
impl Clone for U {
4444
fn clone(&self) -> Self {

src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// run-rustfix
2-
#![deny(disjoint_capture_migration)]
2+
#![deny(rust_2021_incompatible_closure_captures)]
33

44
use std::thread;
55

66
/* Test Send Trait Migration */
7-
struct SendPointer (*mut i32);
7+
struct SendPointer(*mut i32);
88
unsafe impl Send for SendPointer {}
99

1010
fn test_send_trait() {
@@ -18,8 +18,8 @@ fn test_send_trait() {
1818
}
1919

2020
/* Test Sync Trait Migration */
21-
struct CustomInt (*mut i32);
22-
struct SyncPointer (CustomInt);
21+
struct CustomInt(*mut i32);
22+
struct SyncPointer(CustomInt);
2323
unsafe impl Sync for SyncPointer {}
2424
unsafe impl Send for CustomInt {}
2525

@@ -38,7 +38,7 @@ fn test_sync_trait() {
3838
struct S(String);
3939
struct T(i32);
4040

41-
struct U(S,T);
41+
struct U(S, T);
4242

4343
impl Clone for U {
4444
fn clone(&self) -> Self {

src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ LL | | });
1212
note: the lint level is defined here
1313
--> $DIR/auto_traits.rs:2:9
1414
|
15-
LL | #![deny(disjoint_capture_migration)]
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
LL | #![deny(rust_2021_incompatible_closure_captures)]
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
1818
help: add a dummy let to cause `fptr` to be fully captured
1919
|

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![deny(disjoint_capture_migration)]
3+
#![deny(rust_2021_incompatible_closure_captures)]
44
//~^ NOTE: the lint level is defined here
55

66
// Test cases for types that implement a insignificant drop (stlib defined)
@@ -13,9 +13,9 @@ fn test1_all_need_migration() {
1313
let t2 = (String::new(), String::new());
1414

1515
let c = || { let _ = (&t, &t1, &t2);
16-
//~^ ERROR: drop order
17-
//~| NOTE: for more information, see
18-
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
16+
//~^ ERROR: drop order
17+
//~| NOTE: for more information, see
18+
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
1919

2020
let _t = t.0;
2121
let _t1 = t1.0;
@@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() {
3333
let t2 = (String::new(), String::new());
3434

3535
let c = || { let _ = (&t, &t1);
36-
//~^ ERROR: drop order
37-
//~| NOTE: for more information, see
38-
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
36+
//~^ ERROR: drop order
37+
//~| NOTE: for more information, see
38+
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
3939
let _t = t.0;
4040
let _t1 = t1.0;
4141
let _t2 = t2;
@@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() {
5050
let t = (String::new(), String::new());
5151
let t1 = (String::new(), String::new());
5252
let c = || { let _ = &t;
53-
//~^ ERROR: drop order
54-
//~| NOTE: for more information, see
55-
//~| HELP: add a dummy let to cause `t` to be fully captured
53+
//~^ ERROR: drop order
54+
//~| NOTE: for more information, see
55+
//~| HELP: add a dummy let to cause `t` to be fully captured
5656
let _t = t.0;
5757
println!("{}", t1.1);
5858
};
@@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() {
6969
let t1 = (0i32, 0i32);
7070

7171
let c = || { let _ = &t;
72-
//~^ ERROR: drop order
73-
//~| NOTE: for more information, see
74-
//~| HELP: add a dummy let to cause `t` to be fully captured
72+
//~^ ERROR: drop order
73+
//~| NOTE: for more information, see
74+
//~| HELP: add a dummy let to cause `t` to be fully captured
7575
let _t = t.0;
7676
let _t1 = t1.0;
7777
};
@@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() {
8888
let s = S(0i32, 0i32);
8989

9090
let c = || { let _ = &t;
91-
//~^ ERROR: drop order
92-
//~| NOTE: for more information, see
93-
//~| HELP: add a dummy let to cause `t` to be fully captured
91+
//~^ ERROR: drop order
92+
//~| NOTE: for more information, see
93+
//~| HELP: add a dummy let to cause `t` to be fully captured
9494
let _t = t.0;
9595
let _s = s.0;
9696
};
@@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
104104
let t = (String::new(), String::new());
105105
let t1 = (String::new(), String::new());
106106
let c = move || { let _ = (&t1, &t);
107-
//~^ ERROR: drop order
108-
//~| NOTE: for more information, see
109-
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
107+
//~^ ERROR: drop order
108+
//~| NOTE: for more information, see
109+
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
110110
println!("{} {}", t1.1, t.1);
111111
};
112112

@@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() {
120120
let t = (String::new(), String::new(), 0i32);
121121

122122
let c = || { let _ = &t;
123-
//~^ ERROR: drop order
124-
//~| NOTE: for more information, see
125-
//~| HELP: add a dummy let to cause `t` to be fully captured
123+
//~^ ERROR: drop order
124+
//~| NOTE: for more information, see
125+
//~| HELP: add a dummy let to cause `t` to be fully captured
126126
let _t = t.0;
127127
};
128128

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![deny(disjoint_capture_migration)]
3+
#![deny(rust_2021_incompatible_closure_captures)]
44
//~^ NOTE: the lint level is defined here
55

66
// Test cases for types that implement a insignificant drop (stlib defined)
@@ -13,9 +13,9 @@ fn test1_all_need_migration() {
1313
let t2 = (String::new(), String::new());
1414

1515
let c = || {
16-
//~^ ERROR: drop order
17-
//~| NOTE: for more information, see
18-
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
16+
//~^ ERROR: drop order
17+
//~| NOTE: for more information, see
18+
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
1919

2020
let _t = t.0;
2121
let _t1 = t1.0;
@@ -33,9 +33,9 @@ fn test2_only_precise_paths_need_migration() {
3333
let t2 = (String::new(), String::new());
3434

3535
let c = || {
36-
//~^ ERROR: drop order
37-
//~| NOTE: for more information, see
38-
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
36+
//~^ ERROR: drop order
37+
//~| NOTE: for more information, see
38+
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
3939
let _t = t.0;
4040
let _t1 = t1.0;
4141
let _t2 = t2;
@@ -50,9 +50,9 @@ fn test3_only_by_value_need_migration() {
5050
let t = (String::new(), String::new());
5151
let t1 = (String::new(), String::new());
5252
let c = || {
53-
//~^ ERROR: drop order
54-
//~| NOTE: for more information, see
55-
//~| HELP: add a dummy let to cause `t` to be fully captured
53+
//~^ ERROR: drop order
54+
//~| NOTE: for more information, see
55+
//~| HELP: add a dummy let to cause `t` to be fully captured
5656
let _t = t.0;
5757
println!("{}", t1.1);
5858
};
@@ -69,9 +69,9 @@ fn test4_only_non_copy_types_need_migration() {
6969
let t1 = (0i32, 0i32);
7070

7171
let c = || {
72-
//~^ ERROR: drop order
73-
//~| NOTE: for more information, see
74-
//~| HELP: add a dummy let to cause `t` to be fully captured
72+
//~^ ERROR: drop order
73+
//~| NOTE: for more information, see
74+
//~| HELP: add a dummy let to cause `t` to be fully captured
7575
let _t = t.0;
7676
let _t1 = t1.0;
7777
};
@@ -88,9 +88,9 @@ fn test5_only_drop_types_need_migration() {
8888
let s = S(0i32, 0i32);
8989

9090
let c = || {
91-
//~^ ERROR: drop order
92-
//~| NOTE: for more information, see
93-
//~| HELP: add a dummy let to cause `t` to be fully captured
91+
//~^ ERROR: drop order
92+
//~| NOTE: for more information, see
93+
//~| HELP: add a dummy let to cause `t` to be fully captured
9494
let _t = t.0;
9595
let _s = s.0;
9696
};
@@ -104,9 +104,9 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
104104
let t = (String::new(), String::new());
105105
let t1 = (String::new(), String::new());
106106
let c = move || {
107-
//~^ ERROR: drop order
108-
//~| NOTE: for more information, see
109-
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
107+
//~^ ERROR: drop order
108+
//~| NOTE: for more information, see
109+
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
110110
println!("{} {}", t1.1, t.1);
111111
};
112112

@@ -120,9 +120,9 @@ fn test7_drop_non_drop_aggregate_need_migration() {
120120
let t = (String::new(), String::new(), 0i32);
121121

122122
let c = || {
123-
//~^ ERROR: drop order
124-
//~| NOTE: for more information, see
125-
//~| HELP: add a dummy let to cause `t` to be fully captured
123+
//~^ ERROR: drop order
124+
//~| NOTE: for more information, see
125+
//~| HELP: add a dummy let to cause `t` to be fully captured
126126
let _t = t.0;
127127
};
128128

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ LL | | };
1414
note: the lint level is defined here
1515
--> $DIR/insignificant_drop.rs:3:9
1616
|
17-
LL | #![deny(disjoint_capture_migration)]
18-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
LL | #![deny(rust_2021_incompatible_closure_captures)]
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
2020
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
2121
|

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// run-rustfix
22

3-
#![deny(disjoint_capture_migration)]
3+
#![deny(rust_2021_incompatible_closure_captures)]
44
//~^ NOTE: the lint level is defined here
5-
65
#![feature(rustc_attrs)]
76
#![allow(unused)]
87

@@ -36,9 +35,9 @@ fn significant_drop_needs_migration() {
3635
let t = (SigDrop {}, SigDrop {});
3736

3837
let c = || { let _ = &t;
39-
//~^ ERROR: drop order
40-
//~| NOTE: for more information, see
41-
//~| HELP: add a dummy let to cause `t` to be fully captured
38+
//~^ ERROR: drop order
39+
//~| NOTE: for more information, see
40+
//~| HELP: add a dummy let to cause `t` to be fully captured
4241
let _t = t.0;
4342
};
4443

@@ -54,9 +53,9 @@ fn generic_struct_with_significant_drop_needs_migration() {
5453

5554
// move is used to force i32 to be copied instead of being a ref
5655
let c = move || { let _ = &t;
57-
//~^ ERROR: drop order
58-
//~| NOTE: for more information, see
59-
//~| HELP: add a dummy let to cause `t` to be fully captured
56+
//~^ ERROR: drop order
57+
//~| NOTE: for more information, see
58+
//~| HELP: add a dummy let to cause `t` to be fully captured
6059
let _t = t.1;
6160
};
6261

0 commit comments

Comments
 (0)