Handle unsafe_op_in_unsafe_fn
properly in THIR unsafeck
This commit is contained in:
parent
ff2c947c00
commit
b0835410bb
1 changed files with 12 additions and 8 deletions
|
@ -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 { "" };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue