File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,18 @@ fn expr_has_unnecessary_safety_comment<'tcx>(
263
263
expr : & ' tcx hir:: Expr < ' tcx > ,
264
264
comment_pos : BytePos ,
265
265
) -> Option < Span > {
266
+ if cx. tcx . hir ( ) . parent_iter ( expr. hir_id ) . any ( |( _, ref node) | {
267
+ matches ! (
268
+ node,
269
+ Node :: Block ( & Block {
270
+ rules: BlockCheckMode :: UnsafeBlock ( UnsafeSource :: UserProvided ) ,
271
+ ..
272
+ } ) ,
273
+ )
274
+ } ) {
275
+ return None ;
276
+ }
277
+
266
278
// this should roughly be the reverse of `block_parents_have_safety_comment`
267
279
if for_each_expr_with_closures ( cx, expr, |expr| match expr. kind {
268
280
hir:: ExprKind :: Block (
Original file line number Diff line number Diff line change @@ -48,4 +48,21 @@ fn unnecessary_on_stmt_and_expr() -> u32 {
48
48
24
49
49
}
50
50
51
+ mod issue_10084 {
52
+ unsafe fn bar ( ) -> i32 {
53
+ 42
54
+ }
55
+
56
+ macro_rules! foo {
57
+ ( ) => {
58
+ // SAFETY: This is necessary
59
+ unsafe { bar( ) }
60
+ } ;
61
+ }
62
+
63
+ fn main ( ) {
64
+ foo ! ( ) ;
65
+ }
66
+ }
67
+
51
68
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments