Skip to content

Commit ebf024b

Browse files
Suggest const_fn_transmute instead of const_fn
1 parent a6008fa commit ebf024b

File tree

1 file changed

+8
-1
lines changed
  • compiler/rustc_mir/src/transform/check_consts

1 file changed

+8
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,14 @@ impl NonConstOp for Transmute {
489489
}
490490

491491
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
492-
mcf_emit_error(ccx, span, "can only call `transmute` from const items, not `const fn`");
492+
feature_err(
493+
&ccx.tcx.sess.parse_sess,
494+
sym::const_fn_transmute,
495+
span,
496+
&format!("`transmute` is not allowed in {}s", ccx.const_kind()),
497+
)
498+
.note("`transmute` is only allowed in constants and statics for now")
499+
.emit();
493500
}
494501
}
495502

0 commit comments

Comments
 (0)