Skip to content

Commit

Permalink
use ErrorGuaranteed from emit
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev authored and Amanieu committed Jul 25, 2024
1 parent 82f78f1 commit 1133ccd
Showing 1 changed file with 6 additions and 8 deletions.
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 @@ -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),
Expand All @@ -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)
}
}
}
Expand All @@ -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),
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit 1133ccd

Please sign in to comment.