Skip to content

Commit 128f560

Browse files
committed
ast::Attribute -> hir::Attribute
1 parent a625cb0 commit 128f560

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/attribute.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// SPDX-License-Identifier: MIT OR Apache-2.0
44

55
use rustc_ast::tokenstream::{self, TokenTree};
6-
use rustc_ast::{ast, token};
6+
use rustc_ast::{token, DelimArgs};
77
use rustc_data_structures::sync::Lrc;
88
use rustc_errors::{Diag, ErrorGuaranteed};
9-
use rustc_hir::HirId;
9+
use rustc_hir::{AttrArgs, AttrItem, AttrKind, Attribute, HirId};
1010
use rustc_middle::ty::TyCtxt;
1111
use rustc_span::symbol::Ident;
1212
use rustc_span::Span;
@@ -337,14 +337,14 @@ impl<'tcx> AttrParser<'tcx> {
337337

338338
fn parse_preempt_count(
339339
&self,
340-
attr: &ast::Attribute,
341-
item: &ast::AttrItem,
340+
attr: &Attribute,
341+
item: &AttrItem,
342342
) -> Result<PreemptionCount, ErrorGuaranteed> {
343343
let mut adjustment = None;
344344
let mut expectation = None;
345345
let mut unchecked = false;
346346

347-
let ast::AttrArgs::Delimited(ast::DelimArgs {
347+
let AttrArgs::Delimited(DelimArgs {
348348
dspan: delim_span,
349349
tokens: tts,
350350
..
@@ -396,7 +396,7 @@ impl<'tcx> AttrParser<'tcx> {
396396
})?;
397397

398398
if adjustment.is_none() && expectation.is_none() {
399-
self.error(item.args.span().unwrap(), |diag| {
399+
self.error(delim_span.entire(), |diag| {
400400
diag.help("at least one of `adjust` or `expect` property must be specified");
401401
})?;
402402
}
@@ -408,12 +408,11 @@ impl<'tcx> AttrParser<'tcx> {
408408
})
409409
}
410410

411-
fn parse(&self, attr: &ast::Attribute) -> Option<KlintAttribute> {
412-
let ast::AttrKind::Normal(normal_attr) = &attr.kind else {
411+
fn parse(&self, attr: &Attribute) -> Option<KlintAttribute> {
412+
let AttrKind::Normal(item) = &attr.kind else {
413413
return None;
414414
};
415-
let item = &normal_attr.item;
416-
if item.path.segments[0].ident.name != *crate::symbol::klint {
415+
if item.path.segments[0].name != *crate::symbol::klint {
417416
return None;
418417
};
419418
if item.path.segments.len() != 2 {
@@ -423,7 +422,7 @@ impl<'tcx> AttrParser<'tcx> {
423422
});
424423
return None;
425424
}
426-
match item.path.segments[1].ident.name {
425+
match item.path.segments[1].name {
427426
v if v == *crate::symbol::preempt_count => Some(KlintAttribute::PreemptionCount(
428427
self.parse_preempt_count(attr, item).ok()?,
429428
)),
@@ -438,7 +437,7 @@ impl<'tcx> AttrParser<'tcx> {
438437
self.tcx.node_span_lint(
439438
crate::INCORRECT_ATTRIBUTE,
440439
self.hir_id,
441-
item.path.segments[1].span(),
440+
item.path.segments[1].span,
442441
|lint| {
443442
lint.primary_message("unrecognized klint attribute");
444443
},
@@ -452,7 +451,7 @@ impl<'tcx> AttrParser<'tcx> {
452451
pub fn parse_klint_attribute(
453452
tcx: TyCtxt<'_>,
454453
hir_id: HirId,
455-
attr: &ast::Attribute,
454+
attr: &Attribute,
456455
) -> Option<KlintAttribute> {
457456
AttrParser { tcx, hir_id }.parse(attr)
458457
}

0 commit comments

Comments
 (0)