forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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 rust-lang#128753 - compiler-errors:arbitrary-upper, r=spastorino Don't arbitrarily choose one upper bound for hidden captured region error message You could argue that the error message is objectively worse, even though it's more accurate. I guess we could also add a note explaining like "cannot capture the intersection of two regions" or something, though I'm not sure if that is confusing due to being totally technical jargon. This addresses the fact that rust-lang#128752 says "add `+ 'b`" even though it does nothing to fix the issue. It doesn't fix the issue's root cause, though. r? `@spastorino`
- Loading branch information
Showing
6 changed files
with
68 additions
and
36 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/in-trait/cannot-capture-intersection.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 @@ | ||
#![feature(precise_capturing)] | ||
|
||
use std::future::Future; | ||
use std::pin::Pin; | ||
|
||
trait MyTrait { | ||
fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = i32>; | ||
} | ||
|
||
trait ErasedMyTrait { | ||
fn foo<'life0, 'life1, 'dynosaur>(&'life0 self, x: &'life1 i32) | ||
-> Pin<Box<dyn Future<Output = i32> + 'dynosaur>> | ||
where | ||
'life0: 'dynosaur, | ||
'life1: 'dynosaur; | ||
} | ||
|
||
struct DynMyTrait<T: ErasedMyTrait> { | ||
ptr: T, | ||
} | ||
|
||
impl<T: ErasedMyTrait> MyTrait for DynMyTrait<T> { | ||
fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = i32> { | ||
self.ptr.foo(x) | ||
//~^ ERROR hidden type for `impl Future<Output = i32>` captures lifetime that does not appear in bounds | ||
} | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/impl-trait/in-trait/cannot-capture-intersection.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,13 @@ | ||
error[E0700]: hidden type for `impl Future<Output = i32>` captures lifetime that does not appear in bounds | ||
--> $DIR/cannot-capture-intersection.rs:24:9 | ||
| | ||
LL | fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = i32> { | ||
| ------------------------- opaque type defined here | ||
LL | self.ptr.foo(x) | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: hidden type `Pin<Box<dyn Future<Output = i32>>>` captures lifetime `'_` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0700`. |
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