From be66415e11234832b0ba10007d7445aef6213cb6 Mon Sep 17 00:00:00 2001 From: Folkert Date: Thu, 25 Jul 2024 10:29:59 +0200 Subject: [PATCH] use `ErrorGuaranteed` from emit --- compiler/rustc_hir_analysis/src/collect/type_of.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 75826936c09f..8b5a8500f71e 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -68,7 +68,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { ty::Error(_) => ty, ty::FnDef(..) => ty, _ => { - tcx.dcx() + let guar = tcx + .dcx() .struct_span_err(op_sp, "invalid `sym` operand") .with_span_label( tcx.def_span(anon_const.def_id), @@ -77,7 +78,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { .with_help("`sym` operands must refer to either a function or a static") .emit(); - Ty::new_error_with_message(tcx, span, format!("invalid type for `sym` operand")) + Ty::new_error(tcx, guar) } } } @@ -91,7 +92,8 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { ty::Error(_) => ty, ty::Int(_) | ty::Uint(_) => ty, _ => { - tcx.dcx() + let guar = tcx + .dcx() .struct_span_err(op_sp, "invalid type for `const` operand") .with_span_label( tcx.def_span(anon_const.def_id), @@ -100,11 +102,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { .with_help("`const` operands must be of an integer type") .emit(); - Ty::new_error_with_message( - tcx, - span, - format!("invalid type for `const` operand"), - ) + Ty::new_error(tcx, guar) } } }