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.)
This commit is contained in:
Felix S. Klock II 2015-02-22 16:24:39 +01:00
parent f1ea2b3094
commit f9bbef7f44

View File

@ -1233,17 +1233,18 @@ pub fn finish_resolving_def_to_ty<'tcx>(this: &AstConv<'tcx>,
if segments.is_empty() {
opt_self_ty.expect("missing T in <T>::a::b::c")
} else {
tcx.sess.span_bug(span,
&format!("found module name used as a type: {}",
tcx.map.node_to_string(id.node)));
span_err!(tcx.sess, span, E0247, "found module name used as a type: {}",
tcx.map.node_to_string(id.node));
return this.tcx().types.err;
}
}
def::DefPrimTy(prim_ty) => {
prim_ty_to_ty(tcx, segments, prim_ty)
}
_ => {
span_fatal!(tcx.sess, span, E0248,
"found value name used as a type: {:?}", *def);
span_err!(tcx.sess, span, E0248,
"found value name used as a type: {:?}", *def);
return this.tcx().types.err;
}
};
@ -1278,10 +1279,11 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
match ast_ty_to_ty_cache.get(&ast_ty.id) {
Some(&ty::atttce_resolved(ty)) => return ty,
Some(&ty::atttce_unresolved) => {
span_fatal!(tcx.sess, ast_ty.span, E0246,
span_err!(tcx.sess, ast_ty.span, E0246,
"illegal recursive type; insert an enum \
or struct in the cycle, if this is \
desired");
return this.tcx().types.err;
}
None => { /* go on */ }
}