Skip to content

Commit 1513904

Browse files
Remove default build_error impl
Now all structured errors must have their own error code
1 parent bed7b29 commit 1513904

File tree

1 file changed

+12
-29
lines changed
  • compiler/rustc_mir/src/transform/check_consts

1 file changed

+12
-29
lines changed

compiler/rustc_mir/src/transform/check_consts/ops.rs

+12-29
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,7 @@ pub trait NonConstOp: std::fmt::Debug {
3838
DiagnosticImportance::Primary
3939
}
4040

41-
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
42-
let mut err = struct_span_err!(
43-
ccx.tcx.sess,
44-
span,
45-
E0019,
46-
"{} contains unimplemented expression type",
47-
ccx.const_kind()
48-
);
49-
50-
if let Status::Unstable(gate) = self.status_in_item(ccx) {
51-
if !ccx.tcx.features().enabled(gate) && nightly_options::is_nightly_build() {
52-
err.help(&format!("add `#![feature({})]` to the crate attributes to enable", gate));
53-
}
54-
}
55-
56-
if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
57-
err.note(
58-
"A function call isn't allowed in the const's initialization expression \
59-
because the expression's value must be known at compile-time.",
60-
);
61-
err.note(
62-
"Remember: you can't use a function call inside a const's initialization \
63-
expression! However, you can use it anywhere else.",
64-
);
65-
}
66-
67-
err
68-
}
41+
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
6942
}
7043

7144
#[derive(Debug)]
@@ -215,7 +188,17 @@ impl NonConstOp for HeapAllocation {
215188

216189
#[derive(Debug)]
217190
pub struct InlineAsm;
218-
impl NonConstOp for InlineAsm {}
191+
impl NonConstOp for InlineAsm {
192+
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
193+
struct_span_err!(
194+
ccx.tcx.sess,
195+
span,
196+
E0019,
197+
"{} contains unimplemented expression type",
198+
ccx.const_kind()
199+
)
200+
}
201+
}
219202

220203
#[derive(Debug)]
221204
pub struct LiveDrop {

0 commit comments

Comments
 (0)