1
Fork 0

Handle unsafe_op_in_unsafe_fn properly in THIR unsafeck

This commit is contained in:
LeSeulArtichaut 2021-05-24 12:43:51 +02:00
parent ff2c947c00
commit b0835410bb

View file

@ -72,16 +72,20 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {} SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {}
SafetyContext::UnsafeFn => { SafetyContext::UnsafeFn => {
// unsafe_op_in_unsafe_fn is disallowed // unsafe_op_in_unsafe_fn is disallowed
struct_span_err!( self.tcx.struct_span_lint_hir(
self.tcx.sess, UNSAFE_OP_IN_UNSAFE_FN,
self.hir_context,
span, span,
E0133, |lint| {
"{} is unsafe and requires unsafe block", lint.build(&format!(
description, "{} is unsafe and requires unsafe block (error E0133)",
description,
))
.span_label(span, description)
.note(note)
.emit();
},
) )
.span_label(span, description)
.note(note)
.emit();
} }
SafetyContext::Safe => { SafetyContext::Safe => {
let fn_sugg = if unsafe_op_in_unsafe_fn_allowed { " function or" } else { "" }; let fn_sugg = if unsafe_op_in_unsafe_fn_allowed { " function or" } else { "" };