From c701872a6cd9c3c5b0ef766dc237ff93bc3cc8d9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 24 Jan 2021 13:17:54 +0100 Subject: Remove hir::Item::attrs. --- compiler/rustc_passes/src/entry.rs | 14 ++++++++------ compiler/rustc_passes/src/stability.rs | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'compiler/rustc_passes/src') diff --git a/compiler/rustc_passes/src/entry.rs b/compiler/rustc_passes/src/entry.rs index eb05d8b6bee..57848208f94 100644 --- a/compiler/rustc_passes/src/entry.rs +++ b/compiler/rustc_passes/src/entry.rs @@ -80,10 +80,11 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(LocalDefId, EntryFnType) // Beware, this is duplicated in `librustc_builtin_macros/test_harness.rs` // (with `ast::Item`), so make sure to keep them in sync. -fn entry_point_type(sess: &Session, item: &Item<'_>, at_root: bool) -> EntryPointType { - if sess.contains_name(&item.attrs, sym::start) { +fn entry_point_type(ctxt: &EntryContext<'_, '_>, item: &Item<'_>, at_root: bool) -> EntryPointType { + let attrs = ctxt.map.attrs(item.hir_id()); + if ctxt.session.contains_name(attrs, sym::start) { EntryPointType::Start - } else if sess.contains_name(&item.attrs, sym::main) { + } else if ctxt.session.contains_name(attrs, sym::main) { EntryPointType::MainAttr } else if item.ident.name == sym::main { if at_root { @@ -103,13 +104,14 @@ fn throw_attr_err(sess: &Session, span: Span, attr: &str) { } fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) { - match entry_point_type(&ctxt.session, item, at_root) { + match entry_point_type(ctxt, item, at_root) { EntryPointType::None => (), _ if !matches!(item.kind, ItemKind::Fn(..)) => { - if let Some(attr) = ctxt.session.find_by_name(item.attrs, sym::start) { + let attrs = ctxt.map.attrs(item.hir_id()); + if let Some(attr) = ctxt.session.find_by_name(attrs, sym::start) { throw_attr_err(&ctxt.session, attr.span, "start"); } - if let Some(attr) = ctxt.session.find_by_name(item.attrs, sym::main) { + if let Some(attr) = ctxt.session.find_by_name(attrs, sym::main) { throw_attr_err(&ctxt.session, attr.span, "main"); } } diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 76b6d2758a5..3e957aabd77 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -751,8 +751,9 @@ impl Visitor<'tcx> for Checker<'tcx> { // error if all involved types and traits are stable, because // it will have no effect. // See: https://github.com/rust-lang/rust/issues/55436 + let attrs = self.tcx.hir().attrs(item.hir_id()); if let (Some((Stability { level: attr::Unstable { .. }, .. }, span)), _) = - attr::find_stability(&self.tcx.sess, &item.attrs, item.span) + attr::find_stability(&self.tcx.sess, attrs, item.span) { let mut c = CheckTraitImplStable { tcx: self.tcx, fully_stable: true }; c.visit_ty(self_ty); -- cgit 1.4.1-3-g733a5