From 69c4e813fe1887883a55ff59c30443ee8299399b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 5 Mar 2024 12:16:22 +0000 Subject: Use `hir::Node` helper methods instead of repeat the same impl multiple times There already were inconsistencies, so this ensures we don't introduce subtle surprising bugs --- compiler/rustc_passes/src/check_attr.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'compiler/rustc_passes') diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index eb2399f7a64..1254ae8cfc8 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -609,13 +609,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { && !self.tcx.sess.target.is_like_wasm && !self.tcx.sess.opts.actually_rustdoc { - let hir::Node::Item(item) = self.tcx.hir_node(hir_id) else { - unreachable!(); - }; - let hir::ItemKind::Fn(sig, _, _) = item.kind else { - // target is `Fn` - unreachable!(); - }; + let sig = self.tcx.hir_node(hir_id).fn_sig().unwrap(); self.dcx().emit_err(errors::LangItemWithTargetFeature { attr_span: attr.span, -- cgit 1.4.1-3-g733a5