Remove hir::Item::attrs.
This commit is contained in:
parent
5474f17011
commit
c701872a6c
32 changed files with 104 additions and 76 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue