Skip to content

Commit 1bfc0b5

Browse files
committed
fixup the entire compiler to use hir::Attribute
1 parent 46e2505 commit 1bfc0b5

File tree

99 files changed

+477
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+477
-415
lines changed

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Functions dealing with attributes and meta items.
22
3+
use std::fmt::Debug;
34
use std::iter;
45
use std::sync::atomic::{AtomicU32, Ordering};
56

compiler/rustc_ast/src/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_span::Symbol;
22
use rustc_span::symbol::sym;
33

4-
use crate::{Attribute, attr};
4+
use crate::attr::{self, AttributeExt};
55

66
#[derive(Debug)]
77
pub enum EntryPointType {
@@ -37,7 +37,7 @@ pub enum EntryPointType {
3737
}
3838

3939
pub fn entry_point_type(
40-
attrs: &[Attribute],
40+
attrs: &[impl AttributeExt],
4141
at_root: bool,
4242
name: Option<Symbol>,
4343
) -> EntryPointType {

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::assert_matches::assert_matches;
22

3+
use rustc_ast::attr::AttributeExt;
34
use rustc_ast::ptr::P as AstP;
45
use rustc_ast::*;
56
use rustc_data_structures::stack::ensure_sufficient_stack;

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_ast::attr::AttributeExt;
12
use rustc_ast::ptr::P;
23
use rustc_ast::visit::AssocCtxt;
34
use rustc_ast::*;

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25122512

25132513
fn stmt_let_pat(
25142514
&mut self,
2515-
attrs: Option<&'hir [Attribute]>,
2515+
attrs: Option<&'hir [hir::Attribute]>,
25162516
span: Span,
25172517
init: Option<&'hir hir::Expr<'hir>>,
25182518
pat: &'hir hir::Pat<'hir>,

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use std::mem;
2020
use std::ops::{Deref, DerefMut};
2121

22+
use attr::AttributeExt;
2223
use itertools::{Either, Itertools};
2324
use rustc_ast::ptr::P;
2425
use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list};
@@ -383,7 +384,7 @@ impl<'a> AstValidator<'a> {
383384
sym::forbid,
384385
sym::warn,
385386
];
386-
!arr.contains(&attr.name_or_empty()) && rustc_attr::is_builtin_attr(attr)
387+
!arr.contains(&attr.name_or_empty()) && rustc_attr::is_builtin_attr(*attr)
387388
})
388389
.for_each(|attr| {
389390
if attr.is_doc_comment() {

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_ast as ast;
2+
use rustc_ast::attr::AttributeExt;
23
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
34
use rustc_ast::{NodeId, PatKind, attr, token};
45
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue};

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod item;
88

99
use std::borrow::Cow;
1010

11-
use rustc_ast::attr::AttrIdGenerator;
11+
use rustc_ast::attr::{AttrIdGenerator, AttributeExt};
1212
use rustc_ast::ptr::P;
1313
use rustc_ast::token::{
1414
self, BinOpToken, CommentKind, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind,
@@ -17,9 +17,9 @@ use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
1717
use rustc_ast::util::classify;
1818
use rustc_ast::util::comments::{Comment, CommentStyle};
1919
use rustc_ast::{
20-
self as ast, AttrArgs, AttrArgsEq, BindingMode, BlockCheckMode, ByRef, DelimArgs, GenericArg,
21-
GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass,
22-
InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr,
20+
self as ast, AttrArgs, BindingMode, BlockCheckMode, ByRef, DelimArgs, GenericArg, GenericBound,
21+
InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass, InlineAsmTemplatePiece, PatKind,
22+
RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr,
2323
};
2424
use rustc_span::edition::Edition;
2525
use rustc_span::source_map::{SourceMap, Spanned};
@@ -640,20 +640,13 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
640640
AttrArgs::Empty => {
641641
self.print_path(&item.path, false, 0);
642642
}
643-
AttrArgs::Eq(_, AttrArgsEq::Ast(expr)) => {
643+
AttrArgs::Eq(_, expr) => {
644644
self.print_path(&item.path, false, 0);
645645
self.space();
646646
self.word_space("=");
647647
let token_str = self.expr_to_string(expr);
648648
self.word(token_str);
649649
}
650-
AttrArgs::Eq(_, AttrArgsEq::Hir(lit)) => {
651-
self.print_path(&item.path, false, 0);
652-
self.space();
653-
self.word_space("=");
654-
let token_str = self.meta_item_lit_to_string(lit);
655-
self.word(token_str);
656-
}
657650
}
658651
self.end();
659652
}

0 commit comments

Comments
 (0)