Skip to content

Commit 5f4fd5f

Browse files
committed
UPDATE - migrate constant.rs to new diagnostics infrastructure
1 parent 10d0a58 commit 5f4fd5f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

compiler/rustc_codegen_ssa/src/errors.rs

+14
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,17 @@ pub struct MetadataObjectFileWrite {
554554
pub struct InvalidWindowsSubsystem {
555555
pub subsystem: Symbol,
556556
}
557+
558+
#[derive(Diagnostic)]
559+
#[diag(codegen_ssa_erroneous_constant)]
560+
pub struct ErroneousConstant {
561+
#[primary_span]
562+
pub span: Span,
563+
}
564+
565+
#[derive(Diagnostic)]
566+
#[diag(codegen_ssa_shuffle_indices_evaluation)]
567+
pub struct ShuffleIndicesEvaluation {
568+
#[primary_span]
569+
pub span: Span,
570+
}

compiler/rustc_codegen_ssa/src/mir/constant.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::errors;
12
use crate::mir::operand::OperandRef;
23
use crate::traits::*;
34
use rustc_middle::mir;
@@ -42,7 +43,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
4243
};
4344

4445
self.cx.tcx().const_eval_resolve(ty::ParamEnv::reveal_all(), uv, None).map_err(|err| {
45-
self.cx.tcx().sess.span_err(constant.span, "erroneous constant encountered");
46+
self.cx.tcx().sess.emit_err(errors::ErroneousConstant { span: constant.span });
4647
err
4748
})
4849
}
@@ -80,7 +81,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
8081
(llval, c.ty())
8182
})
8283
.unwrap_or_else(|_| {
83-
bx.tcx().sess.span_err(span, "could not evaluate shuffle_indices at compile time");
84+
bx.tcx().sess.emit_err(errors::ShuffleIndicesEvaluation { span });
8485
// We've errored, so we don't have to produce working code.
8586
let ty = self.monomorphize(ty);
8687
let llty = bx.backend_type(bx.layout_of(ty));

compiler/rustc_error_messages/locales/en-US/codegen_ssa.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,7 @@ codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple time
193193
codegen_ssa_metadata_object_file_write = error writing metadata object file: {$error}
194194
195195
codegen_ssa_invalid_windows_subsystem = invalid windows subsystem `{$subsystem}`, only `windows` and `console` are allowed
196+
197+
codegen_ssa_erroneous_constant = erroneous constant encountered
198+
199+
codegen_ssa_shuffle_indices_evaluation = could not evaluate shuffle_indices at compile time

0 commit comments

Comments
 (0)