Skip to content

Commit

Permalink
Do not ICE in type-alias-impl-trait with save-analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Feb 1, 2020
1 parent 64184a3 commit 9d8058f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -837,8 +837,11 @@ fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
return tcx.has_typeck_tables(outer_def_id);
}

let id = tcx.hir().as_local_hir_id(def_id).unwrap();
primary_body_of(tcx, id).is_some()
if let Some(id) = tcx.hir().as_local_hir_id(def_id) {
primary_body_of(tcx, id).is_some()
} else {
false
}
}

fn used_trait_imports(tcx: TyCtxt<'_>, def_id: DefId) -> &DefIdSet {
Expand Down
17 changes: 17 additions & 0 deletions src/test/ui/save-analysis/issue-68621.rs
@@ -0,0 +1,17 @@
// compile-flags: -Zsave-analysis

#![feature(type_alias_impl_trait)]

trait Trait {}

trait Service {
type Future: Trait;
}

struct Struct;

impl Service for Struct {
type Future = impl Trait; //~ ERROR: could not find defining uses
}

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/save-analysis/issue-68621.stderr
@@ -0,0 +1,8 @@
error: could not find defining uses
--> $DIR/issue-68621.rs:14:5
|
LL | type Future = impl Trait;
| ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

0 comments on commit 9d8058f

Please sign in to comment.