-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make precise capturing suggestion machine-applicable only if it has n…
…ot APITs
- Loading branch information
1 parent
81eef2d
commit 0dc6c1e
Showing
4 changed files
with
61 additions
and
1 deletion.
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
13 changes: 13 additions & 0 deletions
13
tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.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,13 @@ | ||
//@ run-rustfix | ||
//@ rustfix-only-machine-applicable | ||
|
||
// Make sure that simple overcapture suggestions remain machine applicable. | ||
|
||
#![allow(unused)] | ||
#![deny(impl_trait_overcaptures)] | ||
|
||
fn named<'a>(x: &'a i32) -> impl Sized + use<> { *x } | ||
//~^ ERROR `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
//~| WARN this changes meaning in Rust 2024 | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.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,13 @@ | ||
//@ run-rustfix | ||
//@ rustfix-only-machine-applicable | ||
|
||
// Make sure that simple overcapture suggestions remain machine applicable. | ||
|
||
#![allow(unused)] | ||
#![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 | ||
//~| WARN this changes meaning in Rust 2024 | ||
|
||
fn main() {} |
26 changes: 26 additions & 0 deletions
26
tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.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,26 @@ | ||
error: `impl Sized` will capture more lifetimes than possibly intended in edition 2024 | ||
--> $DIR/overcaptures-2024-machine-applicable.rs:9:29 | ||
| | ||
LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ||
| ^^^^^^^^^^ | ||
| | ||
= warning: this changes meaning in Rust 2024 | ||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rpit-lifetime-capture.html> | ||
note: specifically, this lifetime is in scope but not mentioned in the type's bounds | ||
--> $DIR/overcaptures-2024-machine-applicable.rs:9: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-machine-applicable.rs:7: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 Sized + use<> { *x } | ||
| +++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|