Skip to content

Commit b083541

Browse files
Handle unsafe_op_in_unsafe_fn properly in THIR unsafeck
1 parent ff2c947 commit b083541

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

compiler/rustc_mir_build/src/check_unsafety.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,20 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
7272
SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {}
7373
SafetyContext::UnsafeFn => {
7474
// unsafe_op_in_unsafe_fn is disallowed
75-
struct_span_err!(
76-
self.tcx.sess,
75+
self.tcx.struct_span_lint_hir(
76+
UNSAFE_OP_IN_UNSAFE_FN,
77+
self.hir_context,
7778
span,
78-
E0133,
79-
"{} is unsafe and requires unsafe block",
80-
description,
79+
|lint| {
80+
lint.build(&format!(
81+
"{} is unsafe and requires unsafe block (error E0133)",
82+
description,
83+
))
84+
.span_label(span, description)
85+
.note(note)
86+
.emit();
87+
},
8188
)
82-
.span_label(span, description)
83-
.note(note)
84-
.emit();
8589
}
8690
SafetyContext::Safe => {
8791
let fn_sugg = if unsafe_op_in_unsafe_fn_allowed { " function or" } else { "" };

0 commit comments

Comments
 (0)