Enable new capture rules by default on edition 2024 · rust-lang/rust@803772e (original) (raw)

File tree

5 files changed

lines changed

5 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1575,6 +1575,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1575 1575 fn_kind.expect("expected RPITs to be lowered with a FnKind"),
1576 1576 FnDeclKind::Impl | FnDeclKind::Trait
1577 1577 ) |
1578 + |
1578 1579 {
1579 1580 // return-position impl trait in trait was decided to capture all
1580 1581 // in-scope lifetimes, which we collect for all opaques during resolution.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
1 +error: [*, o]
2 + --> $DIR/variance.rs:14:36
3 + |
4 +LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
5 + | ^^^^^^^^^^
6 +
7 +error: [*, o]
8 + --> $DIR/variance.rs:19:32
9 + |
10 +LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
11 + | ^^^^^^^^^^^^^^^^^^^^^^^^^
12 +
13 +error: [o]
14 + --> $DIR/variance.rs:21:40
15 + |
16 +LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
17 + | ^^^^^^^^^^
18 +
19 +error: [o]
20 + --> $DIR/variance.rs:26:36
21 + |
22 +LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
23 + | ^^^^^^^^^^^^^^^^^^^^^^^^^
24 +
25 +error: aborting due to 4 previous errors
26 +
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
1 1 error: [*, o]
2 - --> $DIR/variance.rs:12:36
2 + --> $DIR/variance.rs:14:36
3 3 |
4 4 LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
5 5 | ^^^^^^^^^^
6 6
7 7 error: [*, o]
8 - --> $DIR/variance.rs:16:32
8 + --> $DIR/variance.rs:19:32
9 9 |
10 10 LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
11 11 | ^^^^^^^^^^^^^^^^^^^^^^^^^
12 12
13 13 error: [o]
14 - --> $DIR/variance.rs🔞40
14 + --> $DIR/variance.rs:21:40
15 15 |
16 16 LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
17 17 | ^^^^^^^^^^
18 18
19 19 error: [o]
20 - --> $DIR/variance.rs:22:36
20 + --> $DIR/variance.rs:26:36
21 21 |
22 22 LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
23 23 | ^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
1 1 error: [*]
2 - --> $DIR/variance.rs:12:36
2 + --> $DIR/variance.rs:14:36
3 3 |
4 4 LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
5 5 | ^^^^^^^^^^
6 6
7 7 error: [*, o]
8 - --> $DIR/variance.rs:16:32
8 + --> $DIR/variance.rs:19:32
9 9 |
10 10 LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
11 11 | ^^^^^^^^^^^^^^^^^^^^^^^^^
12 12
13 13 error: []
14 - --> $DIR/variance.rs🔞40
14 + --> $DIR/variance.rs:21:40
15 15 |
16 16 LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
17 17 | ^^^^^^^^^^
18 18
19 19 error: [o]
20 - --> $DIR/variance.rs:22:36
20 + --> $DIR/variance.rs:26:36
21 21 |
22 22 LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
23 23 | ^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
1 -// revisions: old new
1 +// revisions: old new e2024
2 +//[e2024] edition: 2024
3 +//[e2024] compile-flags: -Z unstable-options
2 4
3 5 #![cfg_attr(new, feature(lifetime_capture_rules_2024))]
4 6
@@ -12,12 +14,14 @@ impl Captures<'_> for T {}
12 14 fn not_captured_early<'a: 'a>() -> impl Sized {}
13 15 //[old]~^ [*]
14 16 //[new]~^^ [*, o]
17 +//[e2024]~^^^ [*, o]
15 18
16 19 fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} //~ [*, o]
17 20
18 21 fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
19 22 //[old]~^ []
20 23 //[new]~^^ [o]
24 +//[e2024]~^^^ [o]
21 25
22 26 fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} //~ [o]
23 27