Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84dd6df

Browse files
committedMar 23, 2023
Auto merge of rust-lang#109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#108954 (rustdoc: handle generics better when matching notable traits) - rust-lang#109203 (refactor/feat: refactor identifier parsing a bit) - rust-lang#109213 (Eagerly intern and check CrateNum/StableCrateId collisions) - rust-lang#109358 (rustc: Remove unused `Session` argument from some attribute functions) - rust-lang#109359 (Update stdarch) - rust-lang#109378 (Remove Ty::is_region_ptr) - rust-lang#109423 (Use region-erased self type during IAT selection) - rust-lang#109447 (new solver cleanup + implement coherence) - rust-lang#109501 (make link clickable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents cf81181 + 783f3a1 commit 84dd6df

File tree

106 files changed

+903
-586
lines changed

Some content is hidden

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

106 files changed

+903
-586
lines changed
 

‎Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5294,6 +5294,7 @@ name = "rustc_span"
52945294
version = "0.0.0"
52955295
dependencies = [
52965296
"cfg-if",
5297+
"indexmap",
52975298
"md-5",
52985299
"rustc_arena",
52995300
"rustc_data_structures",

‎compiler/rustc_ast/src/attr/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ impl Attribute {
180180
self.doc_str().map_or(false, |s| comments::may_have_doc_links(s.as_str()))
181181
}
182182

183+
pub fn is_proc_macro_attr(&self) -> bool {
184+
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
185+
.iter()
186+
.any(|kind| self.has_name(*kind))
187+
}
188+
183189
/// Extracts the MetaItem from inside this Attribute.
184190
pub fn meta(&self) -> Option<MetaItem> {
185191
match &self.kind {
@@ -627,6 +633,22 @@ pub fn mk_attr_name_value_str(
627633
mk_attr(g, style, path, args, span)
628634
}
629635

636+
pub fn filter_by_name(attrs: &[Attribute], name: Symbol) -> impl Iterator<Item = &Attribute> {
637+
attrs.iter().filter(move |attr| attr.has_name(name))
638+
}
639+
640+
pub fn find_by_name(attrs: &[Attribute], name: Symbol) -> Option<&Attribute> {
641+
filter_by_name(attrs, name).next()
642+
}
643+
644+
pub fn first_attr_value_str_by_name(attrs: &[Attribute], name: Symbol) -> Option<Symbol> {
645+
find_by_name(attrs, name).and_then(|attr| attr.value_str())
646+
}
647+
648+
pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
649+
find_by_name(attrs, name).is_some()
650+
}
651+
630652
pub fn list_contains_name(items: &[NestedMetaItem], name: Symbol) -> bool {
631653
items.iter().any(|item| item.has_name(name))
632654
}

0 commit comments

Comments
 (0)
This repository has been archived.