diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2021-10-05 13:32:03 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2021-10-13 10:53:44 +0000 |
| commit | 888ba509eaf9791ea35c16c04305bdb106a65dfa (patch) | |
| tree | 708c61ce1848eb2995de97b02615519d6ef97a2e /src | |
| parent | be399635a2618660d62fa7ce207d747ac56eae95 (diff) | |
| download | rust-888ba509eaf9791ea35c16c04305bdb106a65dfa.tar.gz rust-888ba509eaf9791ea35c16c04305bdb106a65dfa.zip | |
Re-use logic for adding a suggestion when a lifetime bound is missing on an impl trait
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/impl-trait/hidden-lifetimes.stderr | 10 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/region-escape-via-bound.stderr | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/hidden-lifetimes.stderr b/src/test/ui/impl-trait/hidden-lifetimes.stderr index ba192aa4ab2..60d3409a8ac 100644 --- a/src/test/ui/impl-trait/hidden-lifetimes.stderr +++ b/src/test/ui/impl-trait/hidden-lifetimes.stderr @@ -5,6 +5,11 @@ LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { | -- ^^^^^^^^^^^^^^ | | | hidden type `&'a mut &'b T` captures the lifetime `'b` as defined here + | +help: to declare that the `impl Trait` captures 'b, you can add an explicit `'b` lifetime bound + | +LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b { + | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds --> $DIR/hidden-lifetimes.rs:45:70 @@ -13,6 +18,11 @@ LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl S | -- ^^^^^^^^^^^^^^ | | | hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here + | +help: to declare that the `impl Trait` captures 'b, you can add an explicit `'b` lifetime bound + | +LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + 'b { + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/impl-trait/region-escape-via-bound.stderr b/src/test/ui/impl-trait/region-escape-via-bound.stderr index b9359455278..9dc2ea5bc82 100644 --- a/src/test/ui/impl-trait/region-escape-via-bound.stderr +++ b/src/test/ui/impl-trait/region-escape-via-bound.stderr @@ -6,6 +6,11 @@ LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y> LL | LL | where 'x: 'y | -- hidden type `Cell<&'x u32>` captures the lifetime `'x` as defined here + | +help: to declare that the `impl Trait` captures 'x, you can add an explicit `'x` lifetime bound + | +LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y> + 'x + | ++++ error: aborting due to previous error |
