Skip to content

Commit 298ae8c

Browse files
Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_misc
1 parent 1e7ef03 commit 298ae8c

File tree

32 files changed

+121
-140
lines changed

32 files changed

+121
-140
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
156156
infcx.tcx,
157157
)
158158
});
159-
prev.ty = infcx.tcx.ty_error_with_guaranteed(guar);
159+
prev.ty = infcx.tcx.ty_error(guar);
160160
}
161161
// Pick a better span if there is one.
162162
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
@@ -248,7 +248,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
248248
origin: OpaqueTyOrigin,
249249
) -> Ty<'tcx> {
250250
if let Some(e) = self.tainted_by_errors() {
251-
return self.tcx.ty_error_with_guaranteed(e);
251+
return self.tcx.ty_error(e);
252252
}
253253

254254
let definition_ty = instantiated_ty
@@ -261,7 +261,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
261261
origin,
262262
instantiated_ty.span,
263263
) {
264-
return self.tcx.ty_error_with_guaranteed(guar);
264+
return self.tcx.ty_error(guar);
265265
}
266266

267267
// Only check this for TAIT. RPIT already supports `tests/ui/impl-trait/nested-return-type2.rs`
@@ -326,7 +326,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
326326
definition_ty
327327
} else {
328328
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
329-
self.tcx.ty_error_with_guaranteed(reported)
329+
self.tcx.ty_error(reported)
330330
}
331331
}
332332
}

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
276276
.sess
277277
.delay_span_bug(span, &format!("failed to normalize {:?}", ty));
278278
TypeOpOutput {
279-
output: self.infcx.tcx.ty_error_with_guaranteed(guar),
279+
output: self.infcx.tcx.ty_error(guar),
280280
constraints: None,
281281
error_info: None,
282282
}

compiler/rustc_borrowck/src/type_check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
239239
decl.hidden_type.span,
240240
&format!("could not resolve {:#?}", hidden_type.ty.kind()),
241241
);
242-
hidden_type.ty = infcx.tcx.ty_error_with_guaranteed(reported);
242+
hidden_type.ty = infcx.tcx.ty_error(reported);
243243
}
244244

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

764764
fn error(&mut self) -> Ty<'tcx> {
765765
self.errors_reported = true;
766-
self.tcx().ty_error()
766+
self.tcx().ty_error_misc()
767767
}
768768

769769
fn get_ambient_variance(&self, context: PlaceContext) -> ty::Variance {

compiler/rustc_hir_analysis/src/astconv/mod.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
429429
}
430430
if let (hir::TyKind::Infer, false) = (&ty.kind, self.astconv.allow_ty_infer()) {
431431
self.inferred_params.push(ty.span);
432-
tcx.ty_error().into()
432+
tcx.ty_error_misc().into()
433433
} else {
434434
self.astconv.ast_ty_to_ty(ty).into()
435435
}
@@ -502,14 +502,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
502502
_ => false,
503503
}) {
504504
// Avoid ICE #86756 when type error recovery goes awry.
505-
return tcx.ty_error().into();
505+
return tcx.ty_error_misc().into();
506506
}
507507
tcx.at(self.span).type_of(param.def_id).subst(tcx, substs).into()
508508
} else if infer_args {
509509
self.astconv.ty_infer(Some(param), self.span).into()
510510
} else {
511511
// We've already errored above about the mismatch.
512-
tcx.ty_error().into()
512+
tcx.ty_error_misc().into()
513513
}
514514
}
515515
GenericParamDefKind::Const { has_default } => {
@@ -1239,9 +1239,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12391239
}
12401240
let reported = err.emit();
12411241
term = match def_kind {
1242-
hir::def::DefKind::AssocTy => {
1243-
tcx.ty_error_with_guaranteed(reported).into()
1244-
}
1242+
hir::def::DefKind::AssocTy => tcx.ty_error(reported).into(),
12451243
hir::def::DefKind::AssocConst => tcx
12461244
.const_error_with_guaranteed(
12471245
tcx.type_of(assoc_item_def_id)
@@ -1397,7 +1395,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13971395
.map(|trait_ref| tcx.def_span(trait_ref));
13981396
let reported =
13991397
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
1400-
return tcx.ty_error_with_guaranteed(reported);
1398+
return tcx.ty_error(reported);
14011399
}
14021400

14031401
// Check that there are no gross object safety violations;
@@ -1414,7 +1412,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14141412
&object_safety_violations,
14151413
)
14161414
.emit();
1417-
return tcx.ty_error_with_guaranteed(reported);
1415+
return tcx.ty_error(reported);
14181416
}
14191417
}
14201418

@@ -1523,10 +1521,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15231521
if arg == dummy_self.into() {
15241522
let param = &generics.params[index];
15251523
missing_type_params.push(param.name);
1526-
return tcx.ty_error().into();
1524+
return tcx.ty_error_misc().into();
15271525
} else if arg.walk().any(|arg| arg == dummy_self.into()) {
15281526
references_self = true;
1529-
return tcx.ty_error().into();
1527+
return tcx.ty_error_misc().into();
15301528
}
15311529
arg
15321530
})
@@ -1588,7 +1586,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15881586
.iter()
15891587
.map(|arg| {
15901588
if arg.walk().any(|arg| arg == dummy_self.into()) {
1591-
return tcx.ty_error_with_guaranteed(guar).into();
1589+
return tcx.ty_error(guar).into();
15921590
}
15931591
arg
15941592
})
@@ -2474,7 +2472,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24742472
&[path_str],
24752473
item_segment.ident.name,
24762474
);
2477-
return tcx.ty_error_with_guaranteed(reported)
2475+
return tcx.ty_error(reported)
24782476
};
24792477

24802478
debug!("qpath_to_ty: self_type={:?}", self_ty);
@@ -2821,7 +2819,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
28212819
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
28222820
tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id))
28232821
}
2824-
Some(rbv::ResolvedArg::Error(guar)) => tcx.ty_error_with_guaranteed(guar),
2822+
Some(rbv::ResolvedArg::Error(guar)) => tcx.ty_error(guar),
28252823
arg => bug!("unexpected bound var resolution for {hir_id:?}: {arg:?}"),
28262824
}
28272825
}
@@ -2933,7 +2931,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29332931
{
29342932
err.span_note(impl_.self_ty.span, "not a concrete type");
29352933
}
2936-
tcx.ty_error_with_guaranteed(err.emit())
2934+
tcx.ty_error(err.emit())
29372935
} else {
29382936
ty
29392937
}
@@ -2986,7 +2984,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29862984
.sess
29872985
.delay_span_bug(path.span, "path with `Res::Err` but no error emitted");
29882986
self.set_tainted_by_errors(e);
2989-
self.tcx().ty_error_with_guaranteed(e)
2987+
self.tcx().ty_error(e)
29902988
}
29912989
_ => span_bug!(span, "unexpected resolution: {:?}", path.res),
29922990
}
@@ -3065,7 +3063,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
30653063
let ty = self.ast_ty_to_ty_inner(qself, false, true);
30663064
self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, qself, segment, false)
30673065
.map(|(ty, _, _)| ty)
3068-
.unwrap_or_else(|guar| tcx.ty_error_with_guaranteed(guar))
3066+
.unwrap_or_else(|guar| tcx.ty_error(guar))
30693067
}
30703068
&hir::TyKind::Path(hir::QPath::LangItem(lang_item, span, _)) => {
30713069
let def_id = tcx.require_lang_item(lang_item, Some(span));
@@ -3113,7 +3111,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
31133111
// handled specially and will not descend into this routine.
31143112
self.ty_infer(None, ast_ty.span)
31153113
}
3116-
hir::TyKind::Err => tcx.ty_error(),
3114+
hir::TyKind::Err => tcx.ty_error_misc(),
31173115
};
31183116

31193117
self.record_ty(ast_ty.hir_id, result_ty, ast_ty.span);

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
790790
return_span,
791791
format!("could not fully resolve: {ty} => {err:?}"),
792792
);
793-
collected_tys.insert(def_id, tcx.ty_error_with_guaranteed(reported));
793+
collected_tys.insert(def_id, tcx.ty_error(reported));
794794
}
795795
}
796796
}

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
499499
}
500500
_ => {}
501501
}
502-
self.tcx().ty_error_with_guaranteed(err.emit())
502+
self.tcx().ty_error(err.emit())
503503
}
504504
}
505505

compiler/rustc_hir_analysis/src/collect/type_of.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Ty<'_>>
320320
match self_ty.find_self_aliases() {
321321
spans if spans.len() > 0 => {
322322
let guar = tcx.sess.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: () });
323-
tcx.ty_error_with_guaranteed(guar)
323+
tcx.ty_error(guar)
324324
},
325325
_ => icx.to_ty(*self_ty),
326326
}
@@ -600,10 +600,8 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
600600
// ```
601601
let tables = self.tcx.typeck(item_def_id);
602602
if let Some(guar) = tables.tainted_by_errors {
603-
self.found = Some(ty::OpaqueHiddenType {
604-
span: DUMMY_SP,
605-
ty: self.tcx.ty_error_with_guaranteed(guar),
606-
});
603+
self.found =
604+
Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error(guar) });
607605
return;
608606
}
609607
let Some(&typeck_hidden_ty) = tables.concrete_opaque_types.get(&self.def_id) else {
@@ -622,7 +620,7 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
622620
if let Some(prev) = &mut self.found {
623621
if concrete_type.ty != prev.ty && !(concrete_type, prev.ty).references_error() {
624622
let guar = prev.report_mismatch(&concrete_type, self.tcx);
625-
prev.ty = self.tcx.ty_error_with_guaranteed(guar);
623+
prev.ty = self.tcx.ty_error(guar);
626624
}
627625
} else {
628626
self.found = Some(concrete_type);
@@ -709,7 +707,7 @@ fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> T
709707
_ => "item",
710708
},
711709
});
712-
return tcx.ty_error_with_guaranteed(reported);
710+
return tcx.ty_error(reported);
713711
};
714712

715713
// Only check against typeck if we didn't already error
@@ -821,7 +819,7 @@ fn find_opaque_ty_constraints_for_rpit(
821819
// Some error in the
822820
// owner fn prevented us from populating
823821
// the `concrete_opaque_types` table.
824-
tcx.ty_error_with_guaranteed(guar)
822+
tcx.ty_error(guar)
825823
} else {
826824
table.concrete_opaque_types.get(&def_id).map(|ty| ty.ty).unwrap_or_else(|| {
827825
// We failed to resolve the opaque type or it

compiler/rustc_hir_typeck/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
438438

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

441-
return self.tcx.ty_error_with_guaranteed(err);
441+
return self.tcx.ty_error(err);
442442
}
443443
};
444444

compiler/rustc_hir_typeck/src/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
800800
guar: ErrorGuaranteed,
801801
) -> ty::PolyFnSig<'tcx> {
802802
let astconv: &dyn AstConv<'_> = self;
803-
let err_ty = self.tcx.ty_error_with_guaranteed(guar);
803+
let err_ty = self.tcx.ty_error(guar);
804804

805805
let supplied_arguments = decl.inputs.iter().map(|a| {
806806
// Convert the types that the user supplied (if any), but ignore them.

compiler/rustc_hir_typeck/src/coercion.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
177177
let _ = self.commit_if_ok(|_| {
178178
self.at(&self.cause, self.param_env).define_opaque_types(true).eq(a, b)
179179
});
180-
return success(vec![], self.fcx.tcx.ty_error_with_guaranteed(guar), vec![]);
180+
return success(vec![], self.fcx.tcx.ty_error(guar), vec![]);
181181
}
182182

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

998998
let (adjustments, _) = self.register_infer_ok_obligations(ok);
999999
self.apply_adjustments(expr, adjustments);
1000-
Ok(if let Err(guar) = expr_ty.error_reported() {
1001-
self.tcx.ty_error_with_guaranteed(guar)
1002-
} else {
1003-
target
1004-
})
1000+
Ok(if let Err(guar) = expr_ty.error_reported() { self.tcx.ty_error(guar) } else { target })
10051001
}
10061002

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

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

16251621
let reported = err.emit_unless(unsized_return);
16261622

1627-
self.final_ty = Some(fcx.tcx.ty_error_with_guaranteed(reported));
1623+
self.final_ty = Some(fcx.tcx.ty_error(reported));
16281624
}
16291625
}
16301626
}

0 commit comments

Comments
 (0)