Skip to content

Commit

Permalink
omit unused args warnings for intrinsics without body
Browse files Browse the repository at this point in the history
  • Loading branch information
vayunbiyani committed Jan 21, 2025
1 parent 65d7296 commit e6a6271
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,18 @@ impl<'tcx> Liveness<'_, 'tcx> {
}

fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
let fn_attrs = self.ir.tcx.hir().attrs(body.value.hir_id);
let is_intrinsic = fn_attrs.iter().any(|attr| attr.has_name(sym::rustc_intrinsic));
if is_intrinsic {
let has_body = match &body.value.kind {
rustc_hir::ExprKind::Block(block, _) => !block.stmts.is_empty() || block.expr.is_some(),
_ => false,
};
if has_body {
return;
}
}

for p in body.params {
self.check_unused_vars_in_pat(
p.pat,
Expand Down

0 comments on commit e6a6271

Please sign in to comment.