Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a91ff6

Browse files
committedNov 5, 2024·
Auto merge of rust-lang#132661 - matthiaskrgr:rollup-npytbl6, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#132259 (rustc_codegen_llvm: Add a new 'pc' option to branch-protection) - rust-lang#132409 (CI: switch 7 linux jobs to free runners) - rust-lang#132498 (Suggest fixing typos and let bindings at the same time) - rust-lang#132524 (chore(style): sync submodule exclusion list between tidy and rustfmt) - rust-lang#132567 (Properly suggest `E::assoc` when we encounter `E::Variant::assoc`) - rust-lang#132571 (add const_eval_select macro to reduce redundancy) - rust-lang#132637 (Do not filter empty lint passes & re-do CTFE pass) - rust-lang#132642 (Add documentation on `ast::Attribute`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bc5cf99 + 4346249 commit 4a91ff6

Some content is hidden

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

45 files changed

+761
-528
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ jobs:
110110
# less disk space.
111111
- name: free up disk space
112112
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
113-
if: contains(matrix.os, 'ubuntu')
114-
with:
115-
# Removing packages with APT saves ~5 GiB, but takes several
116-
# minutes (and potentially removes important packages).
117-
large-packages: false
113+
if: matrix.free_disk
118114

119115
# Rust Log Analyzer can't currently detect the PR number of a GitHub
120116
# Actions build on its own, so a hint in the log message is needed to

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,35 @@ impl Attribute {
136136
}
137137
}
138138

139+
/// Returns a list of meta items if the attribute is delimited with parenthesis:
140+
///
141+
/// ```text
142+
/// #[attr(a, b = "c")] // Returns `Some()`.
143+
/// #[attr = ""] // Returns `None`.
144+
/// #[attr] // Returns `None`.
145+
/// ```
139146
pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
140147
match &self.kind {
141148
AttrKind::Normal(normal) => normal.item.meta_item_list(),
142149
AttrKind::DocComment(..) => None,
143150
}
144151
}
145152

153+
/// Returns the string value in:
154+
///
155+
/// ```text
156+
/// #[attribute = "value"]
157+
/// ^^^^^^^
158+
/// ```
159+
///
160+
/// It returns `None` in any other cases, including doc comments if they
161+
/// are not under the form `#[doc = "..."]`.
162+
///
163+
/// It also returns `None` for:
164+
///
165+
/// ```text
166+
/// #[attr("value")]
167+
/// ```
146168
pub fn value_str(&self) -> Option<Symbol> {
147169
match &self.kind {
148170
AttrKind::Normal(normal) => normal.item.value_str(),
@@ -232,6 +254,18 @@ impl AttrItem {
232254
}
233255
}
234256

257+
/// Returns the string value in:
258+
///
259+
/// ```text
260+
/// #[attribute = "value"]
261+
/// ^^^^^^^
262+
/// ```
263+
///
264+
/// It returns `None` in any other cases like:
265+
///
266+
/// ```text
267+
/// #[attr("value")]
268+
/// ```
235269
fn value_str(&self) -> Option<Symbol> {
236270
match &self.args {
237271
AttrArgs::Eq(_, args) => args.value_str(),
@@ -315,6 +349,18 @@ impl MetaItem {
315349
Some(self.name_value_literal()?.span)
316350
}
317351

352+
/// Returns the string value in:
353+
///
354+
/// ```text
355+
/// #[attribute = "value"]
356+
/// ^^^^^^^
357+
/// ```
358+
///
359+
/// It returns `None` in any other cases like:
360+
///
361+
/// ```text
362+
/// #[attr("value")]
363+
/// ```
318364
pub fn value_str(&self) -> Option<Symbol> {
319365
match &self.kind {
320366
MetaItemKind::NameValue(v) => v.kind.str(),

0 commit comments

Comments
 (0)
Please sign in to comment.