Rollup merge of #68744 - JohnTitor:fix-ice-save-analysis, r=cramertj

Do not ICE in `type-alias-impl-trait` with save-analysis

FIxes #68621
Fixes #68750
This commit is contained in:
Dylan DPC 2020-02-03 18:58:30 +01:00 committed by GitHub
commit 95d1f6ffcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 4 deletions

View file

@ -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 {

View file

@ -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() {}

View file

@ -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

View file

@ -1,3 +1,5 @@
// compile-flags: -Zsave-analysis
#![feature(type_alias_impl_trait)]
type Closure = impl FnOnce(); //~ ERROR: type mismatch resolving

View file

@ -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 `()`

View file

@ -1,3 +1,4 @@
// compile-flags: -Zsave-analysis
// check-pass
#![feature(type_alias_impl_trait)]