forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 2
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#115559 - lcnr:implied-bounds-unconstrained,…
… r=aliemjay implied bounds: do not ICE on unconstrained region vars fixes rust-lang#112832 see tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs for a minimal example showing why this is necessary. r? types cc ``@compiler-errors`` ``@aliemjay`` https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/assoc.20type.20bound.20in.20super.20trait
- Loading branch information
Showing
3 changed files
with
53 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// check-pass | ||
|
||
// Regression test for #112832. | ||
pub trait QueryDb { | ||
type Db; | ||
} | ||
|
||
pub struct QueryTable<Q, DB> { | ||
db: DB, | ||
storage: Q, | ||
} | ||
|
||
// We normalize `<Q as QueryDb>::Db` to `<Q as AsyncQueryFunction<'d>>::SendDb` | ||
// using the where-bound. 'd is an unconstrained region variable which previously | ||
// triggered an assert. | ||
impl<Q> QueryTable<Q, <Q as QueryDb>::Db> where Q: for<'d> AsyncQueryFunction<'d> {} | ||
|
||
pub trait AsyncQueryFunction<'d>: QueryDb<Db = <Self as AsyncQueryFunction<'d>>::SendDb> { | ||
type SendDb: 'd; | ||
} | ||
|
||
pub trait QueryStorageOpsAsync<Q> | ||
where | ||
Q: for<'d> AsyncQueryFunction<'d>, | ||
{ | ||
} | ||
|
||
fn main() {} |
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,20 @@ | ||
// check-pass | ||
|
||
// Another minimized regression test for #112832. | ||
trait Trait { | ||
type Assoc; | ||
} | ||
|
||
trait Sub<'a>: Trait<Assoc = <Self as Sub<'a>>::SubAssoc> { | ||
type SubAssoc; | ||
} | ||
|
||
// By using the where-clause we normalize `<T as Trait>::Assoc` to | ||
// `<T as Sub<'a>>::SubAssoc` where `'a` is an unconstrained region | ||
// variable. | ||
fn foo<T>(x: <T as Trait>::Assoc) | ||
where | ||
for<'a> T: Sub<'a>, | ||
{} | ||
|
||
fn main() {} |