Skip to content

Commit a1468ae

Browse files
committed
Do not ICE on unmet trait alias impl bounds
1 parent 9a7cc6c commit a1468ae

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
714714
);
715715
}
716716
Some(Node::Item(hir::Item {
717-
ident, kind: hir::ItemKind::Trait(..), ..
717+
ident,
718+
kind: hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..),
719+
..
718720
})) => {
719721
skip_list.insert(p);
720722
let entry = spanned_predicates.entry(ident.span);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Regression test for #108132: do not ICE upon unmet trait alias constraint in generic impl
2+
3+
#![feature(trait_alias)]
4+
5+
trait IteratorAlias = Iterator;
6+
7+
struct Foo<I>(I);
8+
9+
impl<I: IteratorAlias> Foo<I> {
10+
fn f() {}
11+
}
12+
13+
fn main() {
14+
Foo::<()>::f() //~ trait bounds were not satisfied
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0599]: the function or associated item `f` exists for struct `Foo<()>`, but its trait bounds were not satisfied
2+
--> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:14:16
3+
|
4+
LL | struct Foo<I>(I);
5+
| ------------- function or associated item `f` not found for this struct
6+
...
7+
LL | Foo::<()>::f()
8+
| ^ function or associated item cannot be called on `Foo<()>` due to unsatisfied trait bounds
9+
|
10+
note: trait bound `(): Iterator` was not satisfied
11+
--> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:5:23
12+
|
13+
LL | trait IteratorAlias = Iterator;
14+
| ------------- ^^^^^^^^ unsatisfied trait bound introduced here
15+
note: trait bound `(): IteratorAlias` was not satisfied
16+
--> $DIR/issue-108132-unmet-trait-alias-bound-on-generic-impl.rs:9:9
17+
|
18+
LL | impl<I: IteratorAlias> Foo<I> {
19+
| ^^^^^^^^^^^^^ ------
20+
| |
21+
| unsatisfied trait bound introduced here
22+
23+
error: aborting due to previous error
24+
25+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)