Skip to content

Commit f9bbef7

Browse files
committed
Avoid fatal errors in astconv; just err and return ty_err instead.
This allows computation to proceed and find further errors. (However, this is also annoying at times when the subsequent errors are just reporting that a ty_err occurred. I have thoughts on ways to fix this that I will experiment with separately.)
1 parent f1ea2b3 commit f9bbef7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,17 +1233,18 @@ pub fn finish_resolving_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12331233
if segments.is_empty() {
12341234
opt_self_ty.expect("missing T in <T>::a::b::c")
12351235
} else {
1236-
tcx.sess.span_bug(span,
1237-
&format!("found module name used as a type: {}",
1238-
tcx.map.node_to_string(id.node)));
1236+
span_err!(tcx.sess, span, E0247, "found module name used as a type: {}",
1237+
tcx.map.node_to_string(id.node));
1238+
return this.tcx().types.err;
12391239
}
12401240
}
12411241
def::DefPrimTy(prim_ty) => {
12421242
prim_ty_to_ty(tcx, segments, prim_ty)
12431243
}
12441244
_ => {
1245-
span_fatal!(tcx.sess, span, E0248,
1246-
"found value name used as a type: {:?}", *def);
1245+
span_err!(tcx.sess, span, E0248,
1246+
"found value name used as a type: {:?}", *def);
1247+
return this.tcx().types.err;
12471248
}
12481249
};
12491250

@@ -1278,10 +1279,11 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
12781279
match ast_ty_to_ty_cache.get(&ast_ty.id) {
12791280
Some(&ty::atttce_resolved(ty)) => return ty,
12801281
Some(&ty::atttce_unresolved) => {
1281-
span_fatal!(tcx.sess, ast_ty.span, E0246,
1282+
span_err!(tcx.sess, ast_ty.span, E0246,
12821283
"illegal recursive type; insert an enum \
12831284
or struct in the cycle, if this is \
12841285
desired");
1286+
return this.tcx().types.err;
12851287
}
12861288
None => { /* go on */ }
12871289
}

0 commit comments

Comments
 (0)