-
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.
Check elaborated projections from dyn don't mention unconstrained lat…
…e bound lifetimes
- Loading branch information
1 parent
14f303b
commit ae5f58d
Showing
5 changed files
with
86 additions
and
14 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
24 changes: 24 additions & 0 deletions
24
tests/ui/traits/object/elaborated-predicates-unconstrained-late-bound.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,24 @@ | ||
// Make sure that when elaborating the principal of a dyn trait for projection predicates | ||
// we don't end up in a situation where we have an unconstrained late-bound lifetime in | ||
// the output of a projection. | ||
|
||
// Fix for <https://github.com/rust-lang/rust/issues/130347>. | ||
|
||
trait A<T>: B<T = T> {} | ||
|
||
trait B { | ||
type T; | ||
} | ||
|
||
struct Erase<T: ?Sized + B>(T::T); | ||
|
||
fn main() { | ||
let x = { | ||
let x = String::from("hello"); | ||
|
||
Erase::<dyn for<'a> A<&'a _>>(x.as_str()) | ||
//~^ ERROR binding for associated type `T` references lifetime `'a`, which does not appear in the trait input types | ||
}; | ||
|
||
dbg!(x.0); | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/ui/traits/object/elaborated-predicates-unconstrained-late-bound.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,9 @@ | ||
error[E0582]: binding for associated type `T` references lifetime `'a`, which does not appear in the trait input types | ||
--> $DIR/elaborated-predicates-unconstrained-late-bound.rs:19:21 | ||
| | ||
LL | Erase::<dyn for<'a> A<&'a _>>(x.as_str()) | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0582`. |
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