forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure that outer opaques capture inner opaques's lifetimes even w…
…ith precise capturing syntax
- Loading branch information
1 parent
a2a1206
commit 70746d0
Showing
5 changed files
with
102 additions
and
69 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
15 changes: 15 additions & 0 deletions
15
tests/ui/impl-trait/precise-capturing/capturing-implicit.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,15 @@ | ||
//@ edition: 2024 | ||
//@ compile-flags: -Zunstable-options | ||
|
||
#![feature(rustc_attrs)] | ||
#![feature(type_alias_impl_trait)] | ||
#![rustc_variance_of_opaques] | ||
|
||
fn foo(x: &()) -> impl IntoIterator<Item = impl Sized> + use<> { | ||
//~^ ERROR ['_: o] | ||
//~| ERROR ['_: o] | ||
//~| ERROR `impl Trait` captures lifetime parameter | ||
[*x] | ||
} | ||
|
||
fn main() {} |
22 changes: 22 additions & 0 deletions
22
tests/ui/impl-trait/precise-capturing/capturing-implicit.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,22 @@ | ||
error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list | ||
--> $DIR/capturing-implicit.rs:8:11 | ||
| | ||
LL | fn foo(x: &()) -> impl IntoIterator<Item = impl Sized> + use<> { | ||
| ^ -------------------------------------------- lifetime captured due to being mentioned in the bounds of the `impl Trait` | ||
| | | ||
| this lifetime parameter is captured | ||
|
||
error: ['_: o] | ||
--> $DIR/capturing-implicit.rs:8:19 | ||
| | ||
LL | fn foo(x: &()) -> impl IntoIterator<Item = impl Sized> + use<> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: ['_: o] | ||
--> $DIR/capturing-implicit.rs:8:44 | ||
| | ||
LL | fn foo(x: &()) -> impl IntoIterator<Item = impl Sized> + use<> { | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|