forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#116952 - compiler-errors:lifetime_capture_rul…
…es_2024, r=TaKO8Ki Implement 2024-edition lifetime capture rules RFC Implements rust-lang/rfcs#3498.
- Loading branch information
Showing
11 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -933,6 +933,7 @@ symbols! { | |
lib, | ||
libc, | ||
lifetime, | ||
lifetime_capture_rules_2024, | ||
lifetimes, | ||
likely, | ||
line, | ||
|
6 changes: 6 additions & 0 deletions
6
tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn foo(x: &Vec<i32>) -> impl Sized { | ||
x | ||
//~^ ERROR hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/feature-gate-lifetime-capture-rules-2024.rs:2:5 | ||
| | ||
LL | fn foo(x: &Vec<i32>) -> impl Sized { | ||
| --------- ---------- opaque type defined here | ||
| | | ||
| hidden type `&Vec<i32>` captures the anonymous lifetime defined here | ||
LL | x | ||
| ^ | ||
| | ||
help: to declare that `impl Sized` captures `'_`, you can add an explicit `'_` lifetime bound | ||
| | ||
LL | fn foo(x: &Vec<i32>) -> impl Sized + '_ { | ||
| ++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0700`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// known-bug: #117647 | ||
|
||
#![feature(lifetime_capture_rules_2024)] | ||
#![feature(rustc_attrs)] | ||
#![allow(internal_features)] | ||
#![rustc_variance_of_opaques] | ||
|
||
use std::ops::Deref; | ||
|
||
fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | ||
Box::new(x) | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level | ||
--> $DIR/implicit-capture-late.rs:10:36 | ||
| | ||
LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | ||
| ^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0657`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
8 changes: 4 additions & 4 deletions
8
tests/ui/impl-trait/variance.stderr → tests/ui/impl-trait/variance.old.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters