Skip to content

use ErrorGuaranteed from emit #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading