Skip to content

Commit 95d1f6f

Browse files
authored
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
2 parents 5e561c2 + ae22bf9 commit 95d1f6f

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

src/librustc_typeck/check/mod.rs

+5-2
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 {
+17
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() {}
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+

src/test/ui/type-alias-impl-trait/issue-63279.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// compile-flags: -Zsave-analysis
2+
13
#![feature(type_alias_impl_trait)]
24

35
type Closure = impl FnOnce(); //~ ERROR: type mismatch resolving

src/test/ui/type-alias-impl-trait/issue-63279.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:6:5: 6:28] as std::ops::FnOnce<()>>::Output == ()`
2-
--> $DIR/issue-63279.rs:3:1
1+
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:8:5: 8:28] as std::ops::FnOnce<()>>::Output == ()`
2+
--> $DIR/issue-63279.rs:5:1
33
|
44
LL | type Closure = impl FnOnce();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found `()`

src/test/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// compile-flags: -Zsave-analysis
12
// check-pass
23

34
#![feature(type_alias_impl_trait)]

0 commit comments

Comments
 (0)