Use ty_error_with_guaranteed in many more places
This commit is contained in:
parent
fdbc4329cb
commit
1e7ef03b40
16 changed files with 306 additions and 226 deletions
|
@ -518,8 +518,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("const parameter types cannot be generic");
|
||||
if ty.references_error() {
|
||||
return tcx.const_error(ty).into();
|
||||
if let Err(guar) = ty.error_reported() {
|
||||
return tcx.const_error_with_guaranteed(ty, guar).into();
|
||||
}
|
||||
if !infer_args && has_default {
|
||||
tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into()
|
||||
|
@ -1579,7 +1579,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
false
|
||||
});
|
||||
if references_self {
|
||||
tcx.sess
|
||||
let guar = tcx
|
||||
.sess
|
||||
.delay_span_bug(span, "trait object projection bounds reference `Self`");
|
||||
let substs: Vec<_> = b
|
||||
.projection_ty
|
||||
|
@ -1587,7 +1588,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
.iter()
|
||||
.map(|arg| {
|
||||
if arg.walk().any(|arg| arg == dummy_self.into()) {
|
||||
return tcx.ty_error().into();
|
||||
return tcx.ty_error_with_guaranteed(guar).into();
|
||||
}
|
||||
arg
|
||||
})
|
||||
|
@ -3064,7 +3065,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let ty = self.ast_ty_to_ty_inner(qself, false, true);
|
||||
self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, qself, segment, false)
|
||||
.map(|(ty, _, _)| ty)
|
||||
.unwrap_or_else(|_| tcx.ty_error())
|
||||
.unwrap_or_else(|guar| tcx.ty_error_with_guaranteed(guar))
|
||||
}
|
||||
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
|
||||
let def_id = tcx.require_lang_item(lang_item, Some(span));
|
||||
|
|
|
@ -319,8 +319,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
|
|||
ItemKind::Impl(hir::Impl { self_ty, .. }) => {
|
||||
match self_ty.find_self_aliases() {
|
||||
spans if spans.len() > 0 => {
|
||||
tcx.sess.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: (), });
|
||||
tcx.ty_error()
|
||||
let guar = tcx.sess.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: () });
|
||||
tcx.ty_error_with_guaranteed(guar)
|
||||
},
|
||||
_ => icx.to_ty(*self_ty),
|
||||
}
|
||||
|
@ -599,8 +599,11 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
|
|||
// // constant does not contain interior mutability.
|
||||
// ```
|
||||
let tables = self.tcx.typeck(item_def_id);
|
||||
if let Some(_) = tables.tainted_by_errors {
|
||||
self.found = Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error() });
|
||||
if let Some(guar) = tables.tainted_by_errors {
|
||||
self.found = Some(ty::OpaqueHiddenType {
|
||||
span: DUMMY_SP,
|
||||
ty: self.tcx.ty_error_with_guaranteed(guar),
|
||||
});
|
||||
return;
|
||||
}
|
||||
let Some(&typeck_hidden_ty) = tables.concrete_opaque_types.get(&self.def_id) else {
|
||||
|
@ -618,8 +621,8 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
|
|||
debug!(?concrete_type, "found constraint");
|
||||
if let Some(prev) = &mut self.found {
|
||||
if concrete_type.ty != prev.ty && !(concrete_type, prev.ty).references_error() {
|
||||
prev.report_mismatch(&concrete_type, self.tcx);
|
||||
prev.ty = self.tcx.ty_error();
|
||||
let guar = prev.report_mismatch(&concrete_type, self.tcx);
|
||||
prev.ty = self.tcx.ty_error_with_guaranteed(guar);
|
||||
}
|
||||
} else {
|
||||
self.found = Some(concrete_type);
|
||||
|
@ -814,11 +817,11 @@ fn find_opaque_ty_constraints_for_rpit(
|
|||
|
||||
concrete.map(|concrete| concrete.ty).unwrap_or_else(|| {
|
||||
let table = tcx.typeck(owner_def_id);
|
||||
if let Some(_) = table.tainted_by_errors {
|
||||
if let Some(guar) = table.tainted_by_errors {
|
||||
// Some error in the
|
||||
// owner fn prevented us from populating
|
||||
// the `concrete_opaque_types` table.
|
||||
tcx.ty_error()
|
||||
tcx.ty_error_with_guaranteed(guar)
|
||||
} else {
|
||||
table.concrete_opaque_types.get(&def_id).map(|ty| ty.ty).unwrap_or_else(|| {
|
||||
// We failed to resolve the opaque type or it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue