-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1529c66
commit 052de1d
Showing
4 changed files
with
207 additions
and
15 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
29 changes: 29 additions & 0 deletions
29
tests/ui/impl-trait/precise-capturing/overcaptures-2024.fixed
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,29 @@ | ||
//@ run-rustfix | ||
|
||
#![feature(precise_capturing)] | ||
#![allow(unused, incomplete_features)] | ||
#![deny(impl_trait_overcaptures)] | ||
|
||
fn named<'a>(x: &'a i32) -> impl use<> Sized { *x } | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
|
||
fn implicit(x: &i32) -> impl use<> Sized { *x } | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
|
||
struct W; | ||
impl W { | ||
fn hello(&self, x: &i32) -> impl use<'_> Sized + '_ { self } | ||
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024 | ||
} | ||
|
||
trait Higher<'a> { | ||
type Output; | ||
} | ||
impl Higher<'_> for () { | ||
type Output = (); | ||
} | ||
|
||
fn hrtb() -> impl for<'a> Higher<'a, Output = impl use<> Sized> {} | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
|
||
fn main() {} |
29 changes: 29 additions & 0 deletions
29
tests/ui/impl-trait/precise-capturing/overcaptures-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,29 @@ | ||
//@ run-rustfix | ||
|
||
#![feature(precise_capturing)] | ||
#![allow(unused, incomplete_features)] | ||
#![deny(impl_trait_overcaptures)] | ||
|
||
fn named<'a>(x: &'a i32) -> impl Sized { *x } | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
|
||
fn implicit(x: &i32) -> impl Sized { *x } | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
|
||
struct W; | ||
impl W { | ||
fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ||
//~^ ERROR `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024 | ||
} | ||
|
||
trait Higher<'a> { | ||
type Output; | ||
} | ||
impl Higher<'_> for () { | ||
type Output = (); | ||
} | ||
|
||
fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
|
||
fn main() {} |
75 changes: 75 additions & 0 deletions
75
tests/ui/impl-trait/precise-capturing/overcaptures-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,75 @@ | ||
error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
--> $DIR/overcaptures-2024.rs:7:29 | ||
| | ||
LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ||
| ^^^^^^^^^^ | ||
| | ||
note: specifically, this lifetime is in scope but not mentioned in the type's bounds | ||
--> $DIR/overcaptures-2024.rs:7:10 | ||
| | ||
LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ||
| ^^ | ||
= note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 | ||
note: the lint level is defined here | ||
--> $DIR/overcaptures-2024.rs:5:9 | ||
| | ||
LL | #![deny(impl_trait_overcaptures)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
help: use the precise capturing `use<...>` syntax to make the captures explicit | ||
| | ||
LL | fn named<'a>(x: &'a i32) -> impl use<> Sized { *x } | ||
| +++++ | ||
|
||
error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
--> $DIR/overcaptures-2024.rs:10:25 | ||
| | ||
LL | fn implicit(x: &i32) -> impl Sized { *x } | ||
| ^^^^^^^^^^ | ||
| | ||
note: specifically, this lifetime is in scope but not mentioned in the type's bounds | ||
--> $DIR/overcaptures-2024.rs:10:16 | ||
| | ||
LL | fn implicit(x: &i32) -> impl Sized { *x } | ||
| ^ | ||
= note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 | ||
help: use the precise capturing `use<...>` syntax to make the captures explicit | ||
| | ||
LL | fn implicit(x: &i32) -> impl use<> Sized { *x } | ||
| +++++ | ||
|
||
error: `impl Sized + '_` will capture more lifetimes than possibly intended in edition 2024 | ||
--> $DIR/overcaptures-2024.rs:15:33 | ||
| | ||
LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: specifically, this lifetime is in scope but not mentioned in the type's bounds | ||
--> $DIR/overcaptures-2024.rs:15:24 | ||
| | ||
LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ||
| ^ | ||
= note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 | ||
help: use the precise capturing `use<...>` syntax to make the captures explicit | ||
| | ||
LL | fn hello(&self, x: &i32) -> impl use<'_> Sized + '_ { self } | ||
| +++++++ | ||
|
||
error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
--> $DIR/overcaptures-2024.rs:26:47 | ||
| | ||
LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ||
| ^^^^^^^^^^ | ||
| | ||
note: specifically, this lifetime is in scope but not mentioned in the type's bounds | ||
--> $DIR/overcaptures-2024.rs:26:23 | ||
| | ||
LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ||
| ^^ | ||
= note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 | ||
help: use the precise capturing `use<...>` syntax to make the captures explicit | ||
| | ||
LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl use<> Sized> {} | ||
| +++++ | ||
|
||
error: aborting due to 4 previous errors | ||
|