File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 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>(
263263 expr : & ' tcx hir:: Expr < ' tcx > ,
264264 comment_pos : BytePos ,
265265) -> 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+
266278 // this should roughly be the reverse of `block_parents_have_safety_comment`
267279 if for_each_expr_with_closures ( cx, expr, |expr| match expr. kind {
268280 hir:: ExprKind :: Block (
Original file line number Diff line number Diff line change @@ -48,4 +48,21 @@ fn unnecessary_on_stmt_and_expr() -> u32 {
4848 24
4949}
5050
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+
5168fn main ( ) { }
You can’t perform that action at this time.
0 commit comments