mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
never consider unsafe blocks unused if they would be required with unsafe_op_in_unsafe_fn
This commit is contained in:
parent
4493a0f472
commit
ee3fc9dff8
@ -566,7 +566,7 @@ impl Drop for DiagnosticBuilderInner<'_> {
|
||||
),
|
||||
));
|
||||
handler.emit_diagnostic(&mut self.diagnostic);
|
||||
panic!();
|
||||
panic!("error was constructed but not emitted");
|
||||
}
|
||||
}
|
||||
// `.emit()` was previously called, or maybe we're during `.cancel()`.
|
||||
|
@ -75,10 +75,10 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
|
||||
match self.safety_context {
|
||||
SafetyContext::BuiltinUnsafeBlock => {}
|
||||
SafetyContext::UnsafeBlock { ref mut used, .. } => {
|
||||
if !self.body_unsafety.is_unsafe() || !unsafe_op_in_unsafe_fn_allowed {
|
||||
// Mark this block as useful
|
||||
*used = true;
|
||||
}
|
||||
// Mark this block as useful (even inside `unsafe fn`, where it is technically
|
||||
// redundant -- but we want to eventually enable `unsafe_op_in_unsafe_fn` by
|
||||
// default which will require those blocks).
|
||||
*used = true;
|
||||
}
|
||||
SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {}
|
||||
SafetyContext::UnsafeFn => {
|
||||
|
@ -5,9 +5,9 @@ use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::hir_id::HirId;
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::{lint, mir::*};
|
||||
use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
|
||||
use rustc_session::lint::Level;
|
||||
|
||||
@ -259,7 +259,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
|
||||
violations: impl IntoIterator<Item = &'a UnsafetyViolation>,
|
||||
new_used_unsafe_blocks: impl IntoIterator<Item = (HirId, UsedUnsafeBlockData)>,
|
||||
) {
|
||||
use UsedUnsafeBlockData::{AllAllowedInUnsafeFn, SomeDisallowedInUnsafeFn};
|
||||
use UsedUnsafeBlockData::*;
|
||||
|
||||
let update_entry = |this: &mut Self, hir_id, new_usage| {
|
||||
match this.used_unsafe_blocks.entry(hir_id) {
|
||||
@ -299,15 +299,11 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
|
||||
}
|
||||
}),
|
||||
Safety::BuiltinUnsafe => {}
|
||||
Safety::ExplicitUnsafe(hir_id) => violations.into_iter().for_each(|violation| {
|
||||
Safety::ExplicitUnsafe(hir_id) => violations.into_iter().for_each(|_violation| {
|
||||
update_entry(
|
||||
self,
|
||||
hir_id,
|
||||
match self.tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, violation.lint_root).0
|
||||
{
|
||||
Level::Allow => AllAllowedInUnsafeFn(violation.lint_root),
|
||||
_ => SomeDisallowedInUnsafeFn,
|
||||
},
|
||||
SomeDisallowedInUnsafeFn,
|
||||
)
|
||||
}),
|
||||
};
|
||||
@ -522,6 +518,11 @@ fn unsafety_check_result<'tcx>(
|
||||
}
|
||||
|
||||
fn report_unused_unsafe(tcx: TyCtxt<'_>, kind: UnusedUnsafe, id: HirId) {
|
||||
if matches!(kind, UnusedUnsafe::InUnsafeFn(..)) {
|
||||
// We do *not* warn here, these unsafe blocks are actually required when
|
||||
// `unsafe_op_in_unsafe_fn` is warn or higher.
|
||||
return;
|
||||
}
|
||||
let span = tcx.sess.source_map().guess_head_span(tcx.hir().span(id));
|
||||
tcx.struct_span_lint_hir(UNUSED_UNSAFE, id, span, |lint| {
|
||||
let msg = "unnecessary `unsafe` block";
|
||||
@ -535,25 +536,7 @@ fn report_unused_unsafe(tcx: TyCtxt<'_>, kind: UnusedUnsafe, id: HirId) {
|
||||
"because it's nested under this `unsafe` block",
|
||||
);
|
||||
}
|
||||
UnusedUnsafe::InUnsafeFn(id, usage_lint_root) => {
|
||||
db.span_label(
|
||||
tcx.sess.source_map().guess_head_span(tcx.hir().span(id)),
|
||||
"because it's nested under this `unsafe` fn",
|
||||
)
|
||||
.note(
|
||||
"this `unsafe` block does contain unsafe operations, \
|
||||
but those are already allowed in an `unsafe fn`",
|
||||
);
|
||||
let (level, source) =
|
||||
tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, usage_lint_root);
|
||||
assert_eq!(level, Level::Allow);
|
||||
lint::explain_lint_level_source(
|
||||
UNSAFE_OP_IN_UNSAFE_FN,
|
||||
Level::Allow,
|
||||
source,
|
||||
&mut db,
|
||||
);
|
||||
}
|
||||
UnusedUnsafe::InUnsafeFn(_id, _usage_lint_root) => unreachable!(),
|
||||
}
|
||||
|
||||
db.emit();
|
||||
|
@ -22,7 +22,7 @@ fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
|
||||
fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
|
||||
fn bad4() { unsafe { callback(||{}) } } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe fn bad5() { unsafe { unsf() } }
|
||||
fn bad6() {
|
||||
unsafe { // don't put the warning here
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
@ -31,7 +31,7 @@ fn bad6() {
|
||||
}
|
||||
}
|
||||
unsafe fn bad7() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsf()
|
||||
}
|
||||
|
@ -30,14 +30,6 @@ error: unnecessary `unsafe` block
|
||||
LL | fn bad4() { unsafe { callback(||{}) } }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe-thir.rs:25:20
|
||||
|
|
||||
LL | unsafe fn bad5() { unsafe { unsf() } }
|
||||
| ---------------- ^^^^^^ unnecessary `unsafe` block
|
||||
| |
|
||||
| because it's nested under this `unsafe` fn
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe-thir.rs:28:9
|
||||
|
|
||||
@ -54,13 +46,5 @@ LL | unsafe {
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe-thir.rs:34:5
|
||||
|
|
||||
LL | unsafe fn bad7() {
|
||||
| ---------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
@ -28,17 +28,6 @@ error: unnecessary `unsafe` block
|
||||
LL | fn bad4() { unsafe { callback(||{}) } }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:30:20
|
||||
|
|
||||
LL | unsafe fn bad5() { unsafe { unsf() } }
|
||||
| ---------------- ^^^^^^ unnecessary `unsafe` block
|
||||
| |
|
||||
| because it's nested under this `unsafe` fn
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
= note: `#[allow(unsafe_op_in_unsafe_fn)]` on by default
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:32:5
|
||||
|
|
||||
@ -51,17 +40,6 @@ error: unnecessary `unsafe` block
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:40:9
|
||||
|
|
||||
LL | unsafe fn bad7() {
|
||||
| ---------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:74:9
|
||||
|
|
||||
@ -272,91 +250,32 @@ error: unnecessary `unsafe` block
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:197:13
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:194:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:198:13
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:199:13
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:205:9
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:203:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:207:13
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | unsf();
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:208:13
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:209:13
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:220:17
|
||||
@ -398,19 +317,12 @@ LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:254:9
|
||||
--> $DIR/lint-unused-unsafe.rs:255:13
|
||||
|
|
||||
LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
| ----------------------------------------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:252:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:268:13
|
||||
@ -630,91 +542,32 @@ error: unnecessary `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:409:24
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:406:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:410:24
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:411:24
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:417:20
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:415:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:419:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | unsf();
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:420:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:421:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:432:28
|
||||
@ -756,19 +609,12 @@ LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:466:20
|
||||
--> $DIR/lint-unused-unsafe.rs:467:24
|
||||
|
|
||||
LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
| ----------------------------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:464:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:480:24
|
||||
@ -988,91 +834,32 @@ error: unnecessary `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:622:24
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
LL | let _ = || unsafe { let _ = || unsf(); };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:619:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:623:24
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { let _ = || unsf(); };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:624:24
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { let _ = || unsf(); };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:630:20
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:628:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:632:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | let _ = || unsf();
|
||||
LL | let _ = || unsafe { let _ = || unsf(); };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:633:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { let _ = || unsf(); };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:634:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { let _ = || unsf(); };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:645:28
|
||||
@ -1114,19 +901,12 @@ LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:679:20
|
||||
--> $DIR/lint-unused-unsafe.rs:680:24
|
||||
|
|
||||
LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
| ----------------------------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:677:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:693:24
|
||||
@ -1256,91 +1036,32 @@ error: unnecessary `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:784:28
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:781:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:785:28
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:786:28
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:792:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:790:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:794:28
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | unsf();
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:795:28
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:796:28
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:807:32
|
||||
@ -1382,19 +1103,12 @@ LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:841:24
|
||||
--> $DIR/lint-unused-unsafe.rs:842:28
|
||||
|
|
||||
LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
| ----------------------------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:839:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:855:28
|
||||
@ -1524,91 +1238,32 @@ error: unnecessary `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:942:28
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:939:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:943:28
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:944:28
|
||||
|
|
||||
LL | unsafe fn granularity_2() {
|
||||
| ------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:950:24
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:948:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:952:28
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | unsf();
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:953:28
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:954:28
|
||||
|
|
||||
LL | unsafe fn top_level_used_2() {
|
||||
| ---------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = || unsafe { unsf() };
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:965:32
|
||||
@ -1650,19 +1305,12 @@ LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:999:24
|
||||
--> $DIR/lint-unused-unsafe.rs:1000:28
|
||||
|
|
||||
LL | unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
| ----------------------------------------------- because it's nested under this `unsafe` fn
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:997:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1013:28
|
||||
@ -1672,21 +1320,6 @@ LL | let _ = || unsafe {
|
||||
LL | let _ = || unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1044:9
|
||||
|
|
||||
LL | unsafe fn multiple_unsafe_op_in_unsafe_fn_allows() {
|
||||
| -------------------------------------------------- because it's nested under this `unsafe` fn
|
||||
LL | unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:1045:21
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1059:29
|
||||
|
|
||||
@ -1726,87 +1359,32 @@ error: unnecessary `unsafe` block
|
||||
LL | let _ = async { unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1074:33
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-unused-unsafe.rs:1071:17
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1075:33
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1076:33
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1078:29
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = async { unsafe {
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1080:33
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | let _ = async { unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
LL | let _ = async { unsf() };
|
||||
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1081:33
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
LL | let _ = async { unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1082:33
|
||||
|
|
||||
LL | async unsafe fn async_blocks() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
LL | let _ = async { unsafe {
|
||||
| ------ because it's nested under this `unsafe` block
|
||||
...
|
||||
LL | let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/lint-unused-unsafe.rs:1092:22
|
||||
@ -1820,5 +1398,5 @@ error: unnecessary `unsafe` block
|
||||
LL | let _x: [(); unsafe { unsafe { size() } }] = [];
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: aborting due to 201 previous errors
|
||||
error: aborting due to 174 previous errors
|
||||
|
||||
|
@ -27,7 +27,7 @@ fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
|
||||
fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
|
||||
fn bad4() { unsafe { callback(||{}) } } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe fn bad5() { unsafe { unsf() } }
|
||||
fn bad6() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { // don't put the warning here
|
||||
@ -37,7 +37,7 @@ fn bad6() {
|
||||
}
|
||||
unsafe fn bad7() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe {
|
||||
unsf()
|
||||
}
|
||||
}
|
||||
@ -194,15 +194,15 @@ mod additional_tests {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granularity_2() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { unsf() }
|
||||
unsafe { unsf() }
|
||||
unsafe { unsf() }
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn top_level_used_2() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe {
|
||||
unsf();
|
||||
unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe { unsf() } //~ ERROR: unnecessary `unsafe` block
|
||||
@ -251,8 +251,8 @@ mod additional_tests {
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe {
|
||||
unsafe {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
#[deny(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
unsf();
|
||||
@ -406,15 +406,15 @@ mod additional_tests_closures {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granularity_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() };
|
||||
let _ = || unsafe { unsf() };
|
||||
let _ = || unsafe { unsf() };
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn top_level_used_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
unsf();
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
@ -463,8 +463,8 @@ mod additional_tests_closures {
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
#[deny(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
unsf();
|
||||
@ -619,15 +619,15 @@ mod additional_tests_even_more_closures {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granularity_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { let _ = || unsf(); }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { let _ = || unsf(); }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { let _ = || unsf(); }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { let _ = || unsf(); };
|
||||
let _ = || unsafe { let _ = || unsf(); };
|
||||
let _ = || unsafe { let _ = || unsf(); };
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn top_level_used_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
let _ = || unsf();
|
||||
let _ = || unsafe { let _ = || unsf(); }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { let _ = || unsf(); }; //~ ERROR: unnecessary `unsafe` block
|
||||
@ -676,8 +676,8 @@ mod additional_tests_even_more_closures {
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
#[deny(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
let _ = || unsf();
|
||||
@ -781,15 +781,15 @@ mod item_likes {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granularity_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() };
|
||||
let _ = || unsafe { unsf() };
|
||||
let _ = || unsafe { unsf() };
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn top_level_used_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
unsf();
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
@ -838,8 +838,8 @@ mod item_likes {
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
#[deny(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
unsf();
|
||||
@ -939,15 +939,15 @@ mod item_likes {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granularity_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() };
|
||||
let _ = || unsafe { unsf() };
|
||||
let _ = || unsafe { unsf() };
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn top_level_used_2() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
unsf();
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe { unsf() }; //~ ERROR: unnecessary `unsafe` block
|
||||
@ -996,8 +996,8 @@ mod item_likes {
|
||||
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn granular_disallow_op_in_unsafe_fn_3() {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe {
|
||||
let _ = || unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
#[deny(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
unsf();
|
||||
@ -1041,7 +1041,7 @@ mod additional_tests_extra {
|
||||
|
||||
#[warn(unsafe_op_in_unsafe_fn)]
|
||||
unsafe fn multiple_unsafe_op_in_unsafe_fn_allows() {
|
||||
unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
unsafe {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
unsf();
|
||||
@ -1071,11 +1071,11 @@ mod additional_tests_extra {
|
||||
#[allow(unsafe_op_in_unsafe_fn)]
|
||||
{
|
||||
let _ = async { unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }}; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }}; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }}; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }};
|
||||
}};
|
||||
let _ = async { unsafe { //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = async { unsafe {
|
||||
let _ = async { unsf() };
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }}; //~ ERROR: unnecessary `unsafe` block
|
||||
let _ = async { unsafe { let _ = async { unsf() }; }}; //~ ERROR: unnecessary `unsafe` block
|
||||
|
@ -81,40 +81,8 @@ error: unnecessary `unsafe` block
|
||||
LL | unsafe { unsafe { unsf() } }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:60:5
|
||||
|
|
||||
LL | unsafe fn allow_level() {
|
||||
| ----------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:53:9
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:72:9
|
||||
|
|
||||
LL | unsafe fn nested_allow_level() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
|
||||
= note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:65:13
|
||||
|
|
||||
LL | #[allow(unsafe_op_in_unsafe_fn)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0133]: call to unsafe function is unsafe and requires unsafe block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:78:5
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:76:5
|
||||
|
|
||||
LL | unsf();
|
||||
| ^^^^^^ call to unsafe function
|
||||
@ -122,13 +90,13 @@ LL | unsf();
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:83:9
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:81:9
|
||||
|
|
||||
LL | unsf();
|
||||
| ^^^^^^ call to unsafe function
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0133`.
|
||||
|
@ -58,7 +58,6 @@ unsafe fn allow_level() {
|
||||
VOID = ();
|
||||
|
||||
unsafe { unsf() }
|
||||
//~^ ERROR unnecessary `unsafe` block
|
||||
}
|
||||
|
||||
unsafe fn nested_allow_level() {
|
||||
@ -70,7 +69,6 @@ unsafe fn nested_allow_level() {
|
||||
VOID = ();
|
||||
|
||||
unsafe { unsf() }
|
||||
//~^ ERROR unnecessary `unsafe` block
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,26 +83,8 @@ LL | unsafe { unsafe { unsf() } }
|
||||
| |
|
||||
| because it's nested under this `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:60:5
|
||||
|
|
||||
LL | unsafe fn allow_level() {
|
||||
| ----------------------- because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error: unnecessary `unsafe` block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:72:9
|
||||
|
|
||||
LL | unsafe fn nested_allow_level() {
|
||||
| ------------------------------ because it's nested under this `unsafe` fn
|
||||
...
|
||||
LL | unsafe { unsf() }
|
||||
| ^^^^^^ unnecessary `unsafe` block
|
||||
|
||||
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:78:5
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:76:5
|
||||
|
|
||||
LL | unsf();
|
||||
| ^^^^^^ call to unsafe function
|
||||
@ -110,13 +92,13 @@ LL | unsf();
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe function or block
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:83:9
|
||||
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:81:9
|
||||
|
|
||||
LL | unsf();
|
||||
| ^^^^^^ call to unsafe function
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0133`.
|
||||
|
Loading…
Reference in New Issue
Block a user