-
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.
Don't arbitrarily choose one upper bound for hidden captured region
- Loading branch information
1 parent
60d1465
commit c656ce7
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