-
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.
Rollup merge of #127619 - compiler-errors:precise-capturing-better-su…
…gg, r=oli-obk Suggest using precise capturing for hidden type that captures region Adjusts the "add `+ '_`" suggestion for opaques to instead suggest adding or reusing the `+ use<>` in the opaque. r? oli-obk or please re-roll if you're busy!
- Loading branch information
Showing
6 changed files
with
242 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
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
30 changes: 30 additions & 0 deletions
30
tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.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,30 @@ | ||
#![feature(precise_capturing)] | ||
|
||
fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { | ||
//~^ HELP add `'a` to the `use<...>` bound | ||
x | ||
//~^ ERROR hidden type for | ||
} | ||
|
||
fn param<'a, T>(x: &'a ()) -> impl Sized + use<T> { | ||
//~^ HELP add `'a` to the `use<...>` bound | ||
x | ||
//~^ ERROR hidden type for | ||
} | ||
|
||
fn empty<'a>(x: &'a ()) -> impl Sized + use<> { | ||
//~^ HELP add `'a` to the `use<...>` bound | ||
x | ||
//~^ ERROR hidden type for | ||
} | ||
|
||
trait Captures<'a> {} | ||
impl<T> Captures<'_> for T {} | ||
|
||
fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captures<'captured> { | ||
//~^ HELP add a `use<...>` bound | ||
x | ||
//~^ ERROR hidden type for | ||
} | ||
|
||
fn main() {} |
67 changes: 67 additions & 0 deletions
67
tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.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,67 @@ | ||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/hidden-type-suggestion.rs:5:5 | ||
| | ||
LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { | ||
| -- -------------------- opaque type defined here | ||
| | | ||
| hidden type `&'a ()` captures the lifetime `'a` as defined here | ||
LL | | ||
LL | x | ||
| ^ | ||
| | ||
help: add `'a` to the `use<...>` bound to explicitly capture it | ||
| | ||
LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b, 'a> { | ||
| ++++ | ||
|
||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/hidden-type-suggestion.rs:11:5 | ||
| | ||
LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<T> { | ||
| -- ------------------- opaque type defined here | ||
| | | ||
| hidden type `&'a ()` captures the lifetime `'a` as defined here | ||
LL | | ||
LL | x | ||
| ^ | ||
| | ||
help: add `'a` to the `use<...>` bound to explicitly capture it | ||
| | ||
LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<'a, T> { | ||
| +++ | ||
|
||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/hidden-type-suggestion.rs:17:5 | ||
| | ||
LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<> { | ||
| -- ------------------ opaque type defined here | ||
| | | ||
| hidden type `&'a ()` captures the lifetime `'a` as defined here | ||
LL | | ||
LL | x | ||
| ^ | ||
| | ||
help: add `'a` to the `use<...>` bound to explicitly capture it | ||
| | ||
LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<'a> { | ||
| ++ | ||
|
||
error[E0700]: hidden type for `impl Captures<'captured>` captures lifetime that does not appear in bounds | ||
--> $DIR/hidden-type-suggestion.rs:26:5 | ||
| | ||
LL | fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captures<'captured> { | ||
| -- ------------------------ opaque type defined here | ||
| | | ||
| hidden type `&'a ()` captures the lifetime `'a` as defined here | ||
LL | | ||
LL | x | ||
| ^ | ||
| | ||
help: add a `use<...>` bound to explicitly capture `'a` | ||
| | ||
LL | fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captures<'captured> + use<'captured, 'a, Captured> { | ||
| ++++++++++++++++++++++++++++++ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0700`. |