Skip to content

Commit 94e8a42

Browse files
committed
[beta-1.91] Add more context to the temporary lifetime extension FCW
Mention in the FCW that the lifetime extension behavior was wrong since 1.88/1.89.
1 parent f2f881b commit 94e8a42

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
16071607
tcx.node_span_lint(MACRO_EXTENDED_TEMPORARY_SCOPES, lint_root, labels, |diag| {
16081608
diag.primary_message("temporary lifetime will be shortened in Rust 1.92");
16091609
diag.note("consider using a `let` binding to create a longer lived value");
1610+
diag.note("Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.");
16101611
});
16111612
}
16121613
}

tests/ui/lifetimes/lint-macro-extended-temporary-scopes/extended-super-let-bindings.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LL | println!("{:?}{}", (), { format_args!("{:?}", ()) });
99
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1010
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
1111
= note: consider using a `let` binding to create a longer lived value
12+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
1213
= note: `#[warn(macro_extended_temporary_scopes)]` (part of `#[warn(future_incompatible)]`) on by default
1314

1415
warning: 1 warning emitted

tests/ui/lifetimes/lint-macro-extended-temporary-scopes/macro-extended-temporary-scopes.e2021.stderr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LL | println!("{:?}{:?}", (), if cond() { &format!("") } else { "" });
99
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1010
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
1111
= note: consider using a `let` binding to create a longer lived value
12+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
1213
= note: `#[warn(macro_extended_temporary_scopes)]` (part of `#[warn(future_incompatible)]`) on by default
1314
= note: this warning originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
1415

@@ -23,6 +24,7 @@ LL | println!("{:?}{:?}", (), if cond() { &"".to_string() } else { "" });
2324
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2425
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
2526
= note: consider using a `let` binding to create a longer lived value
27+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
2628

2729
warning: temporary lifetime will be shortened in Rust 1.92
2830
--> $DIR/macro-extended-temporary-scopes.rs:39:43
@@ -35,6 +37,7 @@ LL | println!("{:?}{:?}", (), if cond() { &("string".to_owned() + "string")
3537
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3638
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
3739
= note: consider using a `let` binding to create a longer lived value
40+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
3841

3942
warning: temporary lifetime will be shortened in Rust 1.92
4043
--> $DIR/macro-extended-temporary-scopes.rs:58:17
@@ -48,6 +51,7 @@ LL | }
4851
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4952
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
5053
= note: consider using a `let` binding to create a longer lived value
54+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
5155

5256
warning: temporary lifetime will be shortened in Rust 1.92
5357
--> $DIR/macro-extended-temporary-scopes.rs:54:14
@@ -61,6 +65,7 @@ LL | } else {
6165
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6266
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
6367
= note: consider using a `let` binding to create a longer lived value
68+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
6469

6570
warning: temporary lifetime will be shortened in Rust 1.92
6671
--> $DIR/macro-extended-temporary-scopes.rs:50:14
@@ -74,6 +79,7 @@ LL | } else if cond() {
7479
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
7580
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
7681
= note: consider using a `let` binding to create a longer lived value
82+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
7783

7884
warning: temporary lifetime will be shortened in Rust 1.92
7985
--> $DIR/macro-extended-temporary-scopes.rs:46:14
@@ -87,6 +93,7 @@ LL | } else if cond() {
8793
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8894
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
8995
= note: consider using a `let` binding to create a longer lived value
96+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
9097

9198
warning: 7 warnings emitted
9299

tests/ui/lifetimes/lint-macro-extended-temporary-scopes/macro-extended-temporary-scopes.e2024.stderr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LL | println!("{:?}{:?}", { &temp() }, ());
99
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1010
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
1111
= note: consider using a `let` binding to create a longer lived value
12+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
1213
= note: `#[warn(macro_extended_temporary_scopes)]` (part of `#[warn(future_incompatible)]`) on by default
1314

1415
warning: temporary lifetime will be shortened in Rust 1.92
@@ -22,6 +23,7 @@ LL | println!("{:?}{:?}", (), if cond() { &format!("") } else { "" });
2223
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2324
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
2425
= note: consider using a `let` binding to create a longer lived value
26+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
2527
= note: this warning originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
2628

2729
warning: temporary lifetime will be shortened in Rust 1.92
@@ -35,6 +37,7 @@ LL | println!("{:?}{:?}", (), if cond() { &"".to_string() } else { "" });
3537
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3638
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
3739
= note: consider using a `let` binding to create a longer lived value
40+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
3841

3942
warning: temporary lifetime will be shortened in Rust 1.92
4043
--> $DIR/macro-extended-temporary-scopes.rs:39:43
@@ -47,6 +50,7 @@ LL | println!("{:?}{:?}", (), if cond() { &("string".to_owned() + "string")
4750
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4851
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
4952
= note: consider using a `let` binding to create a longer lived value
53+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
5054

5155
warning: temporary lifetime will be shortened in Rust 1.92
5256
--> $DIR/macro-extended-temporary-scopes.rs:58:17
@@ -60,6 +64,7 @@ LL | }
6064
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
6165
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
6266
= note: consider using a `let` binding to create a longer lived value
67+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
6368

6469
warning: temporary lifetime will be shortened in Rust 1.92
6570
--> $DIR/macro-extended-temporary-scopes.rs:54:14
@@ -73,6 +78,7 @@ LL | } else {
7378
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
7479
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
7580
= note: consider using a `let` binding to create a longer lived value
81+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
7682

7783
warning: temporary lifetime will be shortened in Rust 1.92
7884
--> $DIR/macro-extended-temporary-scopes.rs:50:14
@@ -86,6 +92,7 @@ LL | } else if cond() {
8692
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8793
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
8894
= note: consider using a `let` binding to create a longer lived value
95+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
8996

9097
warning: temporary lifetime will be shortened in Rust 1.92
9198
--> $DIR/macro-extended-temporary-scopes.rs:46:14
@@ -99,6 +106,7 @@ LL | } else if cond() {
99106
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
100107
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
101108
= note: consider using a `let` binding to create a longer lived value
109+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
102110

103111
warning: temporary lifetime will be shortened in Rust 1.92
104112
--> $DIR/macro-extended-temporary-scopes.rs:65:18
@@ -111,6 +119,7 @@ LL | pin!(pin!({ &temp() }));
111119
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
112120
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
113121
= note: consider using a `let` binding to create a longer lived value
122+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
114123

115124
warning: temporary lifetime will be shortened in Rust 1.92
116125
--> $DIR/macro-extended-temporary-scopes.rs:96:13
@@ -123,6 +132,7 @@ LL | pin!({ &(1 / 0) });
123132
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
124133
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
125134
= note: consider using a `let` binding to create a longer lived value
135+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
126136

127137
warning: temporary lifetime will be shortened in Rust 1.92
128138
--> $DIR/macro-extended-temporary-scopes.rs:99:17
@@ -135,6 +145,7 @@ LL | pin!({ &mut [()] });
135145
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
136146
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
137147
= note: consider using a `let` binding to create a longer lived value
148+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
138149

139150
warning: temporary lifetime will be shortened in Rust 1.92
140151
--> $DIR/macro-extended-temporary-scopes.rs:102:13
@@ -147,6 +158,7 @@ LL | pin!({ &Some(String::new()) });
147158
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
148159
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
149160
= note: consider using a `let` binding to create a longer lived value
161+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
150162

151163
warning: temporary lifetime will be shortened in Rust 1.92
152164
--> $DIR/macro-extended-temporary-scopes.rs:105:13
@@ -159,6 +171,7 @@ LL | pin!({ &(|| ())() });
159171
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
160172
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
161173
= note: consider using a `let` binding to create a longer lived value
174+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
162175

163176
warning: temporary lifetime will be shortened in Rust 1.92
164177
--> $DIR/macro-extended-temporary-scopes.rs:108:13
@@ -171,6 +184,7 @@ LL | pin!({ &|| &local });
171184
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
172185
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
173186
= note: consider using a `let` binding to create a longer lived value
187+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
174188

175189
warning: temporary lifetime will be shortened in Rust 1.92
176190
--> $DIR/macro-extended-temporary-scopes.rs:111:13
@@ -183,6 +197,7 @@ LL | pin!({ &CONST_STRING });
183197
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
184198
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
185199
= note: consider using a `let` binding to create a longer lived value
200+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
186201

187202
warning: 15 warnings emitted
188203

tests/ui/lifetimes/lint-macro-extended-temporary-scopes/user-defined-macros.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ LL | wrap!(String::new())
1010
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1111
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
1212
= note: consider using a `let` binding to create a longer lived value
13+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
1314
= note: `#[warn(macro_extended_temporary_scopes)]` (part of `#[warn(future_incompatible)]`) on by default
1415

1516
warning: temporary lifetime will be shortened in Rust 1.92
@@ -27,6 +28,7 @@ LL | print_with_internal_wrap!();
2728
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2829
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
2930
= note: consider using a `let` binding to create a longer lived value
31+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
3032
= note: this warning originates in the macro `print_with_internal_wrap` (in Nightly builds, run with -Z macro-backtrace for more info)
3133

3234
warning: temporary lifetime will be shortened in Rust 1.92
@@ -41,6 +43,7 @@ LL | external_macros::wrap!(String::new())
4143
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4244
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
4345
= note: consider using a `let` binding to create a longer lived value
46+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
4447

4548
warning: temporary lifetime will be shortened in Rust 1.92
4649
--> $DIR/user-defined-macros.rs:52:5
@@ -54,6 +57,7 @@ LL | external_macros::print_with_internal_wrap!();
5457
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5558
= note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
5659
= note: consider using a `let` binding to create a longer lived value
60+
= note: Some temporaries were previously incorrectly lifetime-extended since Rust 1.89 in formatting macros, and since Rust 1.88 in `pin!()`.
5761
= note: this warning originates in the macro `external_macros::print_with_internal_wrap` (in Nightly builds, run with -Z macro-backtrace for more info)
5862

5963
warning: 4 warnings emitted

0 commit comments

Comments
 (0)