Enable new capture rules by default on edition 2024
This commit is contained in:
parent
acba7efe1b
commit
803772e81d
@ -1575,6 +1575,7 @@ fn lower_opaque_impl_trait(
|
||||
fn_kind.expect("expected RPITs to be lowered with a FnKind"),
|
||||
FnDeclKind::Impl | FnDeclKind::Trait
|
||||
) || self.tcx.features().lifetime_capture_rules_2024
|
||||
|| span.at_least_rust_2024()
|
||||
{
|
||||
// return-position impl trait in trait was decided to capture all
|
||||
// in-scope lifetimes, which we collect for all opaques during resolution.
|
||||
|
26
tests/ui/impl-trait/variance.e2024.stderr
Normal file
26
tests/ui/impl-trait/variance.e2024.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error: [*, o]
|
||||
--> $DIR/variance.rs:14:36
|
||||
|
|
||||
LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: [*, o]
|
||||
--> $DIR/variance.rs:19:32
|
||||
|
|
||||
LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: [o]
|
||||
--> $DIR/variance.rs:21:40
|
||||
|
|
||||
LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: [o]
|
||||
--> $DIR/variance.rs:26:36
|
||||
|
|
||||
LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
@ -1,23 +1,23 @@
|
||||
error: [*, o]
|
||||
--> $DIR/variance.rs:12:36
|
||||
--> $DIR/variance.rs:14:36
|
||||
|
|
||||
LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: [*, o]
|
||||
--> $DIR/variance.rs:16:32
|
||||
--> $DIR/variance.rs:19:32
|
||||
|
|
||||
LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: [o]
|
||||
--> $DIR/variance.rs:18:40
|
||||
--> $DIR/variance.rs:21:40
|
||||
|
|
||||
LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: [o]
|
||||
--> $DIR/variance.rs:22:36
|
||||
--> $DIR/variance.rs:26:36
|
||||
|
|
||||
LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,23 +1,23 @@
|
||||
error: [*]
|
||||
--> $DIR/variance.rs:12:36
|
||||
--> $DIR/variance.rs:14:36
|
||||
|
|
||||
LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: [*, o]
|
||||
--> $DIR/variance.rs:16:32
|
||||
--> $DIR/variance.rs:19:32
|
||||
|
|
||||
LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: []
|
||||
--> $DIR/variance.rs:18:40
|
||||
--> $DIR/variance.rs:21:40
|
||||
|
|
||||
LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: [o]
|
||||
--> $DIR/variance.rs:22:36
|
||||
--> $DIR/variance.rs:26:36
|
||||
|
|
||||
LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,4 +1,6 @@
|
||||
// revisions: old new
|
||||
// revisions: old new e2024
|
||||
//[e2024] edition: 2024
|
||||
//[e2024] compile-flags: -Z unstable-options
|
||||
|
||||
#![cfg_attr(new, feature(lifetime_capture_rules_2024))]
|
||||
|
||||
@ -12,12 +14,14 @@ impl<T> Captures<'_> for T {}
|
||||
fn not_captured_early<'a: 'a>() -> impl Sized {}
|
||||
//[old]~^ [*]
|
||||
//[new]~^^ [*, o]
|
||||
//[e2024]~^^^ [*, o]
|
||||
|
||||
fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} //~ [*, o]
|
||||
|
||||
fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
|
||||
//[old]~^ []
|
||||
//[new]~^^ [o]
|
||||
//[e2024]~^^^ [o]
|
||||
|
||||
fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} //~ [o]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user