1- use hir:: { BlockCheckMode , ExprKind , Node } ;
21use rustc_data_structures:: fx:: FxHashSet ;
32use rustc_errors:: struct_span_err;
43use rustc_hir as hir;
54use rustc_hir:: def_id:: { DefId , LocalDefId } ;
65use rustc_hir:: hir_id:: HirId ;
76use rustc_hir:: intravisit;
7+ use rustc_hir:: { BlockCheckMode , ExprKind , Node } ;
88use rustc_middle:: mir:: visit:: { MutatingUseContext , PlaceContext , Visitor } ;
99use rustc_middle:: mir:: * ;
1010use rustc_middle:: ty:: query:: Providers ;
@@ -521,10 +521,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
521521 match kind {
522522 UnsafetyViolationKind :: General => {
523523 // once
524- // Mutable statics always require an unsafe block
525- let unsafe_fn_msg = if unsafe_op_in_unsafe_fn_allowed ( tcx, lint_root)
526- && details != UnsafetyViolationDetails :: UseOfMutableStatic
527- {
524+ let unsafe_fn_msg = if unsafe_op_in_unsafe_fn_allowed ( tcx, lint_root) {
528525 " function or"
529526 } else {
530527 ""
@@ -542,12 +539,14 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: LocalDefId) {
542539 let note_non_inherited = tcx. hir ( ) . parent_iter ( lint_root) . find ( |( id, node) | {
543540 if let Node :: Expr ( block) = node
544541 && let ExprKind :: Block ( block, _) = block. kind
545- && let BlockCheckMode :: UnsafeBlock ( _) = block. rules {
546- true
547- }
542+ && let BlockCheckMode :: UnsafeBlock ( _) = block. rules
543+ {
544+ true
545+ }
548546 else if let Some ( sig) = tcx. hir ( ) . fn_sig_by_hir_id ( * id)
549- && sig. header . is_unsafe ( ) {
550- true
547+ && sig. header . is_unsafe ( )
548+ {
549+ true
551550 } else {
552551 false
553552 }
0 commit comments