diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-23 08:00:02 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-23 08:00:02 +0000 |
| commit | 59e285ff34796585a61a711e11a056c2999368ea (patch) | |
| tree | 691718510295b821f8bcb848053a2f27ff9344ac /src | |
| parent | e237aaef25db05a7f18c1a32b248fdaa06ff8669 (diff) | |
Report diagnostics at the actually actionable site
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/impl-trait/unactionable_diagnostic.fixed | 25 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/unactionable_diagnostic.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/unactionable_diagnostic.stderr | 10 |
3 files changed, 38 insertions, 11 deletions
diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.fixed b/src/test/ui/impl-trait/unactionable_diagnostic.fixed new file mode 100644 index 00000000000..6c2505177fe --- /dev/null +++ b/src/test/ui/impl-trait/unactionable_diagnostic.fixed @@ -0,0 +1,25 @@ +// run-rustfix + +pub trait Trait {} + +pub struct Foo; + +impl Trait for Foo {} + +fn foo<'x, P>( + _post: P, + x: &'x Foo, +) -> &'x impl Trait { + x +} + +pub fn bar<'t, T: 't>( + //~^ HELP: consider adding an explicit lifetime bound... + post: T, + x: &'t Foo, +) -> &'t impl Trait { + foo(post, x) + //~^ ERROR: the parameter type `T` may not live long enough +} + +fn main() {} diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.rs b/src/test/ui/impl-trait/unactionable_diagnostic.rs index 016d7c3b7ef..bce35cbdd0d 100644 --- a/src/test/ui/impl-trait/unactionable_diagnostic.rs +++ b/src/test/ui/impl-trait/unactionable_diagnostic.rs @@ -1,23 +1,25 @@ -trait Trait {} +// run-rustfix -struct Foo; +pub trait Trait {} + +pub struct Foo; impl Trait for Foo {} fn foo<'x, P>( - post: P, + _post: P, x: &'x Foo, ) -> &'x impl Trait { - //~^ HELP: consider adding an explicit lifetime bound... x } -fn bar<'t, T>( +pub fn bar<'t, T>( + //~^ HELP: consider adding an explicit lifetime bound... post: T, x: &'t Foo, ) -> &'t impl Trait { foo(post, x) - //~^ ERROR: the opaque type `foo<T>::{opaque#0}` may not live long enough + //~^ ERROR: the parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/ui/impl-trait/unactionable_diagnostic.stderr b/src/test/ui/impl-trait/unactionable_diagnostic.stderr index c9b3f612544..a32004cda1a 100644 --- a/src/test/ui/impl-trait/unactionable_diagnostic.stderr +++ b/src/test/ui/impl-trait/unactionable_diagnostic.stderr @@ -1,13 +1,13 @@ -error[E0309]: the opaque type `foo<T>::{opaque#0}` may not live long enough - --> $DIR/unactionable_diagnostic.rs:19:5 +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/unactionable_diagnostic.rs:21:5 | LL | foo(post, x) - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | -LL | ) -> &'x impl Trait + 't { - | ++++ +LL | pub fn bar<'t, T: 't>( + | ++++ error: aborting due to previous error |
