-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #130367 - compiler-errors:super-unconstrained, r=<try>
Check elaborated projections from dyn don't mention unconstrained late bound lifetimes Check that the projections that are *not* explicitly written but which we deduce from elaborating the principal of a `dyn` *also* do not reference unconstrained late-bound lifetimes, just like the ones that the user writes by hand. Fixes #130347
- Loading branch information
Showing
8 changed files
with
149 additions
and
18 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
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
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); | ||
} |
12 changes: 12 additions & 0 deletions
12
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,12 @@ | ||
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 | trait A<T>: B<T = T> {} | ||
| ----- due to this supertrait | ||
... | ||
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