Skip to content

Commit 20f111f

Browse files
authored
Rollup merge of #148839 - luca3s:rtsan_ice_fix, r=WaffleLapkin
fix rtsan_nonblocking_async lint closure ICE Fixes #148750, which i introduced in #147935. I also added the bug report to the tests.
2 parents 06b18db + 1bfad01 commit 20f111f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,18 @@ fn check_result(
469469
})
470470
}
471471

472-
// warn for nonblocking async fn.
472+
// warn for nonblocking async functions, blocks and closures.
473473
// This doesn't behave as expected, because the executor can run blocking code without the sanitizer noticing.
474474
if codegen_fn_attrs.sanitizers.rtsan_setting == RtsanSetting::Nonblocking
475475
&& let Some(sanitize_span) = interesting_spans.sanitize
476-
// async function
477-
&& (tcx.asyncness(did).is_async() || (tcx.is_closure_like(did.into())
476+
// async fn
477+
&& (tcx.asyncness(did).is_async()
478478
// async block
479-
&& (tcx.coroutine_is_async(did.into())
480-
// async closure
481-
|| tcx.coroutine_is_async(tcx.coroutine_for_closure(did)))))
479+
|| tcx.is_coroutine(did.into())
480+
// async closure
481+
|| (tcx.is_closure_like(did.into())
482+
&& tcx.hir_node_by_def_id(did).expect_closure().kind
483+
!= rustc_hir::ClosureKind::Closure))
482484
{
483485
let hir_id = tcx.local_def_id_to_hir_id(did);
484486
tcx.node_span_lint(

tests/ui/sanitize-attr/invalid-sanitize.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ fn test() {
3737
#[sanitize(realtime = "nonblocking")] //~ WARN: the async executor can run blocking code, without realtime sanitizer catching it [rtsan_nonblocking_async]
3838
async || {}
3939
};
40+
41+
let _regular_closure = {
42+
#[sanitize(realtime = "nonblocking")] // no warning on a regular closure
43+
|| 0
44+
};
4045
}

0 commit comments

Comments
 (0)