Skip to content

Commit d9eae17

Browse files
Auto merge of #149790 - JonathanBrouwer:attr-path-perf, r=<try>
[PERF] How much does lowering the spans in `AttrPath` matter?
2 parents 5bc3450 + 284989d commit d9eae17

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ pub fn parse_cfg_attr(
355355
span,
356356
attr_span: cfg_attr.span,
357357
template: CFG_ATTR_TEMPLATE,
358-
path: AttrPath::from_ast(&cfg_attr.get_normal_item().path, identity),
358+
path: AttrPath::from_ast(&cfg_attr.get_normal_item().path),
359359
description: ParsedDescription::Attribute,
360360
reason,
361361
suggestions: CFG_ATTR_TEMPLATE

compiler/rustc_attr_parsing/src/interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
311311
// }
312312
ast::AttrKind::Normal(n) => {
313313
attr_paths.push(PathParser(Cow::Borrowed(&n.item.path)));
314-
let attr_path = AttrPath::from_ast(&n.item.path, lower_span);
314+
let attr_path = AttrPath::from_ast(&n.item.path);
315315

316316
self.check_attribute_safety(
317317
&attr_path,

compiler/rustc_attr_parsing/src/validate_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub fn check_builtin_meta_item(
165165
if deny_unsafety && let Safety::Unsafe(unsafe_span) = meta.unsafety {
166166
psess.dcx().emit_err(errors::InvalidAttrUnsafe {
167167
span: unsafe_span,
168-
name: AttrPath::from_ast(&meta.path, identity),
168+
name: AttrPath::from_ast(&meta.path),
169169
});
170170
}
171171
}

compiler/rustc_hir/src/hir.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,15 +1193,10 @@ impl IntoDiagArg for AttrPath {
11931193
}
11941194

11951195
impl AttrPath {
1196-
pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1196+
pub fn from_ast(path: &ast::Path) -> Self {
11971197
AttrPath {
1198-
segments: path
1199-
.segments
1200-
.iter()
1201-
.map(|i| Ident { name: i.ident.name, span: lower_span(i.ident.span) })
1202-
.collect::<Vec<_>>()
1203-
.into_boxed_slice(),
1204-
span: lower_span(path.span),
1198+
segments: path.segments.iter().map(|i| i.ident).collect::<Vec<_>>().into_boxed_slice(),
1199+
span: path.span,
12051200
}
12061201
}
12071202
}

0 commit comments

Comments
 (0)