Skip to content

Commit 9d8058f

Browse files
committed
Do not ICE in type-alias-impl-trait with save-analysis
1 parent 64184a3 commit 9d8058f

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,11 @@ fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
837837
return tcx.has_typeck_tables(outer_def_id);
838838
}
839839

840-
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
841-
primary_body_of(tcx, id).is_some()
840+
if let Some(id) = tcx.hir().as_local_hir_id(def_id) {
841+
primary_body_of(tcx, id).is_some()
842+
} else {
843+
false
844+
}
842845
}
843846

844847
fn used_trait_imports(tcx: TyCtxt<'_>, def_id: DefId) -> &DefIdSet {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// compile-flags: -Zsave-analysis
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
trait Trait {}
6+
7+
trait Service {
8+
type Future: Trait;
9+
}
10+
11+
struct Struct;
12+
13+
impl Service for Struct {
14+
type Future = impl Trait; //~ ERROR: could not find defining uses
15+
}
16+
17+
fn main() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: could not find defining uses
2+
--> $DIR/issue-68621.rs:14:5
3+
|
4+
LL | type Future = impl Trait;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)