Skip to content

Commit f80fe5b

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 f1e767f commit f80fe5b

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
@@ -1212,17 +1212,18 @@ pub fn finish_resolving_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12121212
if segments.is_empty() {
12131213
opt_self_ty.expect("missing T in <T>::a::b::c")
12141214
} else {
1215-
tcx.sess.span_bug(span,
1216-
&format!("found module name used as a type: {}",
1217-
tcx.map.node_to_string(id.node)));
1215+
span_err!(tcx.sess, span, E0247, "found module name used as a type: {}",
1216+
tcx.map.node_to_string(id.node));
1217+
return this.tcx().types.err;
12181218
}
12191219
}
12201220
def::DefPrimTy(prim_ty) => {
12211221
prim_ty_to_ty(tcx, segments, prim_ty)
12221222
}
12231223
_ => {
1224-
span_fatal!(tcx.sess, span, E0248,
1225-
"found value name used as a type: {:?}", *def);
1224+
span_err!(tcx.sess, span, E0248,
1225+
"found value name used as a type: {:?}", *def);
1226+
return this.tcx().types.err;
12261227
}
12271228
};
12281229

@@ -1257,10 +1258,11 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
12571258
match ast_ty_to_ty_cache.get(&ast_ty.id) {
12581259
Some(&ty::atttce_resolved(ty)) => return ty,
12591260
Some(&ty::atttce_unresolved) => {
1260-
span_fatal!(tcx.sess, ast_ty.span, E0246,
1261+
span_err!(tcx.sess, ast_ty.span, E0246,
12611262
"illegal recursive type; insert an enum \
12621263
or struct in the cycle, if this is \
12631264
desired");
1265+
return this.tcx().types.err;
12641266
}
12651267
None => { /* go on */ }
12661268
}

0 commit comments

Comments
 (0)