Skip to content

Commit

Permalink
Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_misc
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Feb 22, 2023
1 parent 1e7ef03 commit 298ae8c
Show file tree
Hide file tree
Showing 32 changed files with 121 additions and 140 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
infcx.tcx,
)
});
prev.ty = infcx.tcx.ty_error_with_guaranteed(guar);
prev.ty = infcx.tcx.ty_error(guar);
}
// Pick a better span if there is one.
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
Expand Down Expand Up @@ -248,7 +248,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
origin: OpaqueTyOrigin,
) -> Ty<'tcx> {
if let Some(e) = self.tainted_by_errors() {
return self.tcx.ty_error_with_guaranteed(e);
return self.tcx.ty_error(e);
}

let definition_ty = instantiated_ty
Expand All @@ -261,7 +261,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
origin,
instantiated_ty.span,
) {
return self.tcx.ty_error_with_guaranteed(guar);
return self.tcx.ty_error(guar);
}

// Only check this for TAIT. RPIT already supports `tests/ui/impl-trait/nested-return-type2.rs`
Expand Down Expand Up @@ -326,7 +326,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
definition_ty
} else {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
self.tcx.ty_error_with_guaranteed(reported)
self.tcx.ty_error(reported)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
.sess
.delay_span_bug(span, &format!("failed to normalize {:?}", ty));
TypeOpOutput {
output: self.infcx.tcx.ty_error_with_guaranteed(guar),
output: self.infcx.tcx.ty_error(guar),
constraints: None,
error_info: None,
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
decl.hidden_type.span,
&format!("could not resolve {:#?}", hidden_type.ty.kind()),
);
hidden_type.ty = infcx.tcx.ty_error_with_guaranteed(reported);
hidden_type.ty = infcx.tcx.ty_error(reported);
}

(opaque_type_key, (hidden_type, decl.origin))
Expand Down Expand Up @@ -531,7 +531,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
if place_ty.variant_index.is_none() {
if let Err(guar) = place_ty.ty.error_reported() {
assert!(self.errors_reported);
return PlaceTy::from_ty(self.tcx().ty_error_with_guaranteed(guar));
return PlaceTy::from_ty(self.tcx().ty_error(guar));
}
}
place_ty = self.sanitize_projection(place_ty, elem, place, location, context);
Expand Down Expand Up @@ -763,7 +763,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {

fn error(&mut self) -> Ty<'tcx> {
self.errors_reported = true;
self.tcx().ty_error()
self.tcx().ty_error_misc()
}

fn get_ambient_variance(&self, context: PlaceContext) -> ty::Variance {
Expand Down
32 changes: 15 additions & 17 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
if let (hir::TyKind::Infer, false) = (&ty.kind, self.astconv.allow_ty_infer()) {
self.inferred_params.push(ty.span);
tcx.ty_error().into()
tcx.ty_error_misc().into()
} else {
self.astconv.ast_ty_to_ty(ty).into()
}
Expand Down Expand Up @@ -502,14 +502,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
_ => false,
}) {
// Avoid ICE #86756 when type error recovery goes awry.
return tcx.ty_error().into();
return tcx.ty_error_misc().into();
}
tcx.at(self.span).type_of(param.def_id).subst(tcx, substs).into()
} else if infer_args {
self.astconv.ty_infer(Some(param), self.span).into()
} else {
// We've already errored above about the mismatch.
tcx.ty_error().into()
tcx.ty_error_misc().into()
}
}
GenericParamDefKind::Const { has_default } => {
Expand Down Expand Up @@ -1239,9 +1239,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
let reported = err.emit();
term = match def_kind {
hir::def::DefKind::AssocTy => {
tcx.ty_error_with_guaranteed(reported).into()
}
hir::def::DefKind::AssocTy => tcx.ty_error(reported).into(),
hir::def::DefKind::AssocConst => tcx
.const_error_with_guaranteed(
tcx.type_of(assoc_item_def_id)
Expand Down Expand Up @@ -1397,7 +1395,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.map(|trait_ref| tcx.def_span(trait_ref));
let reported =
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
return tcx.ty_error_with_guaranteed(reported);
return tcx.ty_error(reported);
}

// Check that there are no gross object safety violations;
Expand All @@ -1414,7 +1412,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&object_safety_violations,
)
.emit();
return tcx.ty_error_with_guaranteed(reported);
return tcx.ty_error(reported);
}
}

Expand Down Expand Up @@ -1523,10 +1521,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
if arg == dummy_self.into() {
let param = &generics.params[index];
missing_type_params.push(param.name);
return tcx.ty_error().into();
return tcx.ty_error_misc().into();
} else if arg.walk().any(|arg| arg == dummy_self.into()) {
references_self = true;
return tcx.ty_error().into();
return tcx.ty_error_misc().into();
}
arg
})
Expand Down Expand Up @@ -1588,7 +1586,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.iter()
.map(|arg| {
if arg.walk().any(|arg| arg == dummy_self.into()) {
return tcx.ty_error_with_guaranteed(guar).into();
return tcx.ty_error(guar).into();
}
arg
})
Expand Down Expand Up @@ -2474,7 +2472,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&[path_str],
item_segment.ident.name,
);
return tcx.ty_error_with_guaranteed(reported)
return tcx.ty_error(reported)
};

debug!("qpath_to_ty: self_type={:?}", self_ty);
Expand Down Expand Up @@ -2821,7 +2819,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id))
}
Some(rbv::ResolvedArg::Error(guar)) => tcx.ty_error_with_guaranteed(guar),
Some(rbv::ResolvedArg::Error(guar)) => tcx.ty_error(guar),
arg => bug!("unexpected bound var resolution for {hir_id:?}: {arg:?}"),
}
}
Expand Down Expand Up @@ -2933,7 +2931,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
{
err.span_note(impl_.self_ty.span, "not a concrete type");
}
tcx.ty_error_with_guaranteed(err.emit())
tcx.ty_error(err.emit())
} else {
ty
}
Expand Down Expand Up @@ -2986,7 +2984,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.sess
.delay_span_bug(path.span, "path with `Res::Err` but no error emitted");
self.set_tainted_by_errors(e);
self.tcx().ty_error_with_guaranteed(e)
self.tcx().ty_error(e)
}
_ => span_bug!(span, "unexpected resolution: {:?}", path.res),
}
Expand Down Expand Up @@ -3065,7 +3063,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(|guar| tcx.ty_error_with_guaranteed(guar))
.unwrap_or_else(|guar| tcx.ty_error(guar))
}
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
let def_id = tcx.require_lang_item(lang_item, Some(span));
Expand Down Expand Up @@ -3113,7 +3111,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// handled specially and will not descend into this routine.
self.ty_infer(None, ast_ty.span)
}
hir::TyKind::Err => tcx.ty_error(),
hir::TyKind::Err => tcx.ty_error_misc(),
};

self.record_ty(ast_ty.hir_id, result_ty, ast_ty.span);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
return_span,
format!("could not fully resolve: {ty} => {err:?}"),
);
collected_tys.insert(def_id, tcx.ty_error_with_guaranteed(reported));
collected_tys.insert(def_id, tcx.ty_error(reported));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
}
_ => {}
}
self.tcx().ty_error_with_guaranteed(err.emit())
self.tcx().ty_error(err.emit())
}
}

Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
match self_ty.find_self_aliases() {
spans if spans.len() > 0 => {
let guar = tcx.sess.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: () });
tcx.ty_error_with_guaranteed(guar)
tcx.ty_error(guar)
},
_ => icx.to_ty(*self_ty),
}
Expand Down Expand Up @@ -600,10 +600,8 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
// ```
let tables = self.tcx.typeck(item_def_id);
if let Some(guar) = tables.tainted_by_errors {
self.found = Some(ty::OpaqueHiddenType {
span: DUMMY_SP,
ty: self.tcx.ty_error_with_guaranteed(guar),
});
self.found =
Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error(guar) });
return;
}
let Some(&typeck_hidden_ty) = tables.concrete_opaque_types.get(&self.def_id) else {
Expand All @@ -622,7 +620,7 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
if let Some(prev) = &mut self.found {
if concrete_type.ty != prev.ty && !(concrete_type, prev.ty).references_error() {
let guar = prev.report_mismatch(&concrete_type, self.tcx);
prev.ty = self.tcx.ty_error_with_guaranteed(guar);
prev.ty = self.tcx.ty_error(guar);
}
} else {
self.found = Some(concrete_type);
Expand Down Expand Up @@ -709,7 +707,7 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
_ => "item",
},
});
return tcx.ty_error_with_guaranteed(reported);
return tcx.ty_error(reported);
};

// Only check against typeck if we didn't already error
Expand Down Expand Up @@ -821,7 +819,7 @@ fn find_opaque_ty_constraints_for_rpit(
// Some error in the
// owner fn prevented us from populating
// the `concrete_opaque_types` table.
tcx.ty_error_with_guaranteed(guar)
tcx.ty_error(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
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let err = self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);

return self.tcx.ty_error_with_guaranteed(err);
return self.tcx.ty_error(err);
}
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
guar: ErrorGuaranteed,
) -> ty::PolyFnSig<'tcx> {
let astconv: &dyn AstConv<'_> = self;
let err_ty = self.tcx.ty_error_with_guaranteed(guar);
let err_ty = self.tcx.ty_error(guar);

let supplied_arguments = decl.inputs.iter().map(|a| {
// Convert the types that the user supplied (if any), but ignore them.
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
let _ = self.commit_if_ok(|_| {
self.at(&self.cause, self.param_env).define_opaque_types(true).eq(a, b)
});
return success(vec![], self.fcx.tcx.ty_error_with_guaranteed(guar), vec![]);
return success(vec![], self.fcx.tcx.ty_error(guar), vec![]);
}

// Coercing from `!` to any type is allowed:
Expand Down Expand Up @@ -997,11 +997,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let (adjustments, _) = self.register_infer_ok_obligations(ok);
self.apply_adjustments(expr, adjustments);
Ok(if let Err(guar) = expr_ty.error_reported() {
self.tcx.ty_error_with_guaranteed(guar)
} else {
target
})
Ok(if let Err(guar) = expr_ty.error_reported() { self.tcx.ty_error(guar) } else { target })
}

/// Same as `try_coerce()`, but without side-effects.
Expand Down Expand Up @@ -1439,7 +1435,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
// If we see any error types, just propagate that error
// upwards.
if let Err(guar) = (expression_ty, self.merged_ty()).error_reported() {
self.final_ty = Some(fcx.tcx.ty_error_with_guaranteed(guar));
self.final_ty = Some(fcx.tcx.ty_error(guar));
return;
}

Expand Down Expand Up @@ -1624,7 +1620,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {

let reported = err.emit_unless(unsized_return);

self.final_ty = Some(fcx.tcx.ty_error_with_guaranteed(reported));
self.final_ty = Some(fcx.tcx.ty_error(reported));
}
}
}
Expand Down
Loading

0 comments on commit 298ae8c

Please sign in to comment.