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 1b2f75b

Browse files
committedApr 17, 2025
Auto merge of #139980 - matthiaskrgr:rollup-lctmfww, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #138528 (deref patterns: implement implicit deref patterns) - #138934 (support config extensions) - #139393 (rustdoc-json: Output target feature information) - #139553 (sync::mpsc: prevent double free on `Drop`) - #139615 (Remove `name_or_empty`) - #139853 (Disable combining LLD with external llvm-config) - #139913 (rustdoc/clean: Fix lowering of fn params (fixes correctness & HIR vs. middle parity regressions)) - #139942 (Ignore aix for tests/ui/erros/pic-linker.rs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a15cce2 + c4cacd2 commit 1b2f75b

File tree

118 files changed

+2205
-641
lines changed

Some content is hidden

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

118 files changed

+2205
-641
lines changed
 

‎bootstrap.example.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
2020
#profile = <none>
2121

22+
# Inherits configuration values from different configuration files (a.k.a. config extensions).
23+
# Supports absolute paths, and uses the current directory (where the bootstrap was invoked)
24+
# as the base if the given path is not absolute.
25+
#
26+
# The overriding logic follows a right-to-left order. For example, in `include = ["a.toml", "b.toml"]`,
27+
# extension `b.toml` overrides `a.toml`. Also, parent extensions always overrides the inner ones.
28+
#include = []
29+
2230
# Keeps track of major changes made to this configuration.
2331
#
2432
# This value also represents ID of the PR that caused major changes. Meaning,

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ impl MetaItem {
305305
if let [PathSegment { ident, .. }] = self.path.segments[..] { Some(ident) } else { None }
306306
}
307307

308-
pub fn name_or_empty(&self) -> Symbol {
309-
self.ident().unwrap_or_else(Ident::empty).name
308+
pub fn name(&self) -> Option<Symbol> {
309+
self.ident().map(|ident| ident.name)
310310
}
311311

312312
pub fn has_name(&self, name: Symbol) -> bool {
@@ -511,13 +511,14 @@ impl MetaItemInner {
511511
}
512512
}
513513

514-
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
514+
/// For a single-segment meta item, returns its identifier; otherwise, returns `None`.
515515
pub fn ident(&self) -> Option<Ident> {
516516
self.meta_item().and_then(|meta_item| meta_item.ident())
517517
}
518518

519-
pub fn name_or_empty(&self) -> Symbol {
520-
self.ident().unwrap_or_else(Ident::empty).name
519+
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
520+
pub fn name(&self) -> Option<Symbol> {
521+
self.ident().map(|ident| ident.name)
521522
}
522523

523524
/// Returns `true` if this list item is a MetaItem with a name of `name`.
@@ -738,9 +739,9 @@ pub trait AttributeExt: Debug {
738739
fn id(&self) -> AttrId;
739740

740741
/// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
741-
/// return the name of the attribute, else return the empty identifier.
742-
fn name_or_empty(&self) -> Symbol {
743-
self.ident().unwrap_or_else(Ident::empty).name
742+
/// return the name of the attribute; otherwise, returns `None`.
743+
fn name(&self) -> Option<Symbol> {
744+
self.ident().map(|ident| ident.name)
744745
}
745746

746747
/// Get the meta item list, `#[attr(meta item list)]`
@@ -752,7 +753,7 @@ pub trait AttributeExt: Debug {
752753
/// Gets the span of the value literal, as string, when using `#[attr = value]`
753754
fn value_span(&self) -> Option<Span>;
754755

755-
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
756+
/// For a single-segment attribute, returns its ident; otherwise, returns `None`.
756757
fn ident(&self) -> Option<Ident>;
757758

758759
/// Checks whether the path of this attribute matches the name.
@@ -770,6 +771,11 @@ pub trait AttributeExt: Debug {
770771
self.ident().map(|x| x.name == name).unwrap_or(false)
771772
}
772773

774+
#[inline]
775+
fn has_any_name(&self, names: &[Symbol]) -> bool {
776+
names.iter().any(|&name| self.has_name(name))
777+
}
778+
773779
/// get the span of the entire attribute
774780
fn span(&self) -> Span;
775781

@@ -813,8 +819,8 @@ impl Attribute {
813819
AttributeExt::id(self)
814820
}
815821

816-
pub fn name_or_empty(&self) -> Symbol {
817-
AttributeExt::name_or_empty(self)
822+
pub fn name(&self) -> Option<Symbol> {
823+
AttributeExt::name(self)
818824
}
819825

820826
pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
@@ -846,6 +852,11 @@ impl Attribute {
846852
AttributeExt::has_name(self, name)
847853
}
848854

855+
#[inline]
856+
pub fn has_any_name(&self, names: &[Symbol]) -> bool {
857+
AttributeExt::has_any_name(self, names)
858+
}
859+
849860
pub fn span(&self) -> Span {
850861
AttributeExt::span(self)
851862
}

0 commit comments

Comments
 (0)
Please sign in to comment.