Skip to content

Commit e6a6271

Browse files
committed
omit unused args warnings for intrinsics without body
1 parent 65d7296 commit e6a6271

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/rustc_passes/src/liveness.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,18 @@ impl<'tcx> Liveness<'_, 'tcx> {
15211521
}
15221522

15231523
fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
1524+
let fn_attrs = self.ir.tcx.hir().attrs(body.value.hir_id);
1525+
let is_intrinsic = fn_attrs.iter().any(|attr| attr.has_name(sym::rustc_intrinsic));
1526+
if is_intrinsic {
1527+
let has_body = match &body.value.kind {
1528+
rustc_hir::ExprKind::Block(block, _) => !block.stmts.is_empty() || block.expr.is_some(),
1529+
_ => false,
1530+
};
1531+
if has_body {
1532+
return;
1533+
}
1534+
}
1535+
15241536
for p in body.params {
15251537
self.check_unused_vars_in_pat(
15261538
p.pat,

0 commit comments

Comments
 (0)