Skip to content

Commit

Permalink
Rollup merge of #68744 - JohnTitor:fix-ice-save-analysis, r=cramertj
Browse files Browse the repository at this point in the history
Do not ICE in `type-alias-impl-trait` with save-analysis

FIxes #68621
Fixes #68750
  • Loading branch information
Dylan-DPC committed Feb 3, 2020
2 parents 5e561c2 + ae22bf9 commit 95d1f6f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-63279.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// compile-flags: -Zsave-analysis

#![feature(type_alias_impl_trait)]

type Closure = impl FnOnce(); //~ ERROR: type mismatch resolving
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/type-alias-impl-trait/issue-63279.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:6:5: 6:28] as std::ops::FnOnce<()>>::Output == ()`
--> $DIR/issue-63279.rs:3:1
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:8:5: 8:28] as std::ops::FnOnce<()>>::Output == ()`
--> $DIR/issue-63279.rs:5:1
|
LL | type Closure = impl FnOnce();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found `()`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// compile-flags: -Zsave-analysis
// check-pass

#![feature(type_alias_impl_trait)]
Expand Down

0 comments on commit 95d1f6f

Please sign in to comment.