Skip to content

Rollup of 8 pull requests #139980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9eb6a54
sync::mpsc: add miri reproducer of double free
petrosagg Apr 10, 2025
b9e2ac5
sync::mpsc: prevent double free on `Drop`
petrosagg Apr 8, 2025
f35eae7
store the kind of pattern adjustments in `pat_adjustments`
dianne Mar 15, 2025
1c1febc
add new config option: `include`
onur-ozkan Apr 1, 2025
89e3bef
document config extensions
onur-ozkan Mar 25, 2025
4e80659
implement cyclic inclusion handling
onur-ozkan Apr 1, 2025
78cb453
document `include` in `bootstrap.example.toml`
onur-ozkan Apr 1, 2025
3f70f19
apply nit notes
onur-ozkan Apr 1, 2025
8e6f50b
fix path and the ordering logic
onur-ozkan Apr 15, 2025
7dfb457
add FIXME note in `TomlConfig::merge`
onur-ozkan Apr 15, 2025
2907ab5
Move `is_builder_target`, `is_system_llvm` and `is_rust_llvm` from `B…
Kobzol Apr 15, 2025
3c01dfe
Rename `is_builder_target` to `is_host_target`
Kobzol Apr 15, 2025
6d52b51
add comment in `TomlConfig::merge` about the merge order
onur-ozkan Apr 15, 2025
8c50f95
rustdoc: Output target feature information
willglynn Apr 4, 2025
a870bba
Add a warning when combining LLD with external LLVM config
Kobzol Apr 16, 2025
8270478
resolve config include FIXME
onur-ozkan Apr 16, 2025
f9ebd36
add coverage on config include logic
onur-ozkan Apr 16, 2025
cb6c499
lower implicit deref patterns to THIR
dianne Feb 24, 2025
e4b7b3d
pattern typing for immutable implicit deref patterns
dianne Mar 9, 2025
91d0b57
register `DerefMut` bounds for implicit mutable derefs
dianne Mar 9, 2025
d6df469
refactor path pattern checking to get info for peeling
dianne Apr 7, 2025
9196048
refactor struct pattern checking to get info for peeling
dianne Mar 4, 2025
1f40e9a
refactor tuple struct pattern checking to get info for peeling
dianne Mar 4, 2025
923d95c
don't peel ADTs the pattern could match
dianne Mar 9, 2025
977c9ab
respect the tcx's recursion limit when peeling
dianne Mar 10, 2025
ff0d4bc
upvar inference for implicit deref patterns
dianne Mar 14, 2025
4c4b61b
add a feature gate test
dianne Mar 14, 2025
93d13e9
add an unstable book chapter
dianne Mar 14, 2025
3b91b7a
Make cow_of_cow test a teeny bit more explicit
Nadrieril Apr 16, 2025
92ce44f
ignore aix for tests/ui/erros/pic-linker.rs
Apr 16, 2025
4be670f
Warnings-as-errors in `check-builtin-attr-ice.rs`.
nnethercote Apr 9, 2025
400e8e5
Fix attribute printing in an error.
nnethercote Apr 9, 2025
7e1f2f9
Augment some tests involving attributes.
nnethercote Apr 10, 2025
2fef0a3
Replace infallible `name_or_empty` methods with fallible `name` methods.
nnethercote Apr 10, 2025
846c10f
Avoid an `unwrap` in `RustcMirAttrs::set_field`.
nnethercote Apr 15, 2025
6214674
rustdoc/clean: Change terminology of items pertaining to (formal) fn …
fmease Apr 15, 2025
82ff0a0
rustdoc: Properly clean fn params in all contexts
fmease Apr 16, 2025
993acf1
Rollup merge of #138528 - dianne:implicit-deref-patterns, r=Nadrieril
matthiaskrgr Apr 17, 2025
4cc9588
Rollup merge of #138934 - onur-ozkan:extended-config-profiles, r=Kobzol
matthiaskrgr Apr 17, 2025
9efd2af
Rollup merge of #139393 - willglynn:rustdoc_output_target_feature_inf…
matthiaskrgr Apr 17, 2025
96192a9
Rollup merge of #139553 - petrosagg:channel-double-free, r=RalfJung,t…
matthiaskrgr Apr 17, 2025
f6008db
Rollup merge of #139615 - nnethercote:rm-name_or_empty, r=jdonszelmann
matthiaskrgr Apr 17, 2025
1257f67
Rollup merge of #139853 - Kobzol:lld-llvm-config, r=onur-ozkan
matthiaskrgr Apr 17, 2025
e30bda2
Rollup merge of #139913 - fmease:rustdoc-fix-fn-param-handling, r=Gui…
matthiaskrgr Apr 17, 2025
c4cacd2
Rollup merge of #139942 - dalvescb:master, r=jieyouxu
matthiaskrgr Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
#profile = <none>

# Inherits configuration values from different configuration files (a.k.a. config extensions).
# Supports absolute paths, and uses the current directory (where the bootstrap was invoked)
# as the base if the given path is not absolute.
#
# The overriding logic follows a right-to-left order. For example, in `include = ["a.toml", "b.toml"]`,
# extension `b.toml` overrides `a.toml`. Also, parent extensions always overrides the inner ones.
#include = []

# Keeps track of major changes made to this configuration.
#
# This value also represents ID of the PR that caused major changes. Meaning,
Expand Down
33 changes: 22 additions & 11 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ impl MetaItem {
if let [PathSegment { ident, .. }] = self.path.segments[..] { Some(ident) } else { None }
}

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

pub fn has_name(&self, name: Symbol) -> bool {
Expand Down Expand Up @@ -511,13 +511,14 @@ impl MetaItemInner {
}
}

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

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

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

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

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

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

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

#[inline]
fn has_any_name(&self, names: &[Symbol]) -> bool {
names.iter().any(|&name| self.has_name(name))
}

/// get the span of the entire attribute
fn span(&self) -> Span;

Expand Down Expand Up @@ -813,8 +819,8 @@ impl Attribute {
AttributeExt::id(self)
}

pub fn name_or_empty(&self) -> Symbol {
AttributeExt::name_or_empty(self)
pub fn name(&self) -> Option<Symbol> {
AttributeExt::name(self)
}

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

#[inline]
pub fn has_any_name(&self, names: &[Symbol]) -> bool {
AttributeExt::has_any_name(self, names)
}

pub fn span(&self) -> Span {
AttributeExt::span(self)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// create a fake body so that the entire rest of the compiler doesn't have to deal with
// this as a special case.
return self.lower_fn_body(decl, contract, |this| {
if attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic) {
if attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic)) {
let span = this.lower_span(span);
let empty_block = hir::Block {
hir_id: this.next_id(),
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl<'a> AstValidator<'a> {
sym::forbid,
sym::warn,
];
!arr.contains(&attr.name_or_empty()) && rustc_attr_parsing::is_builtin_attr(*attr)
!attr.has_any_name(&arr) && rustc_attr_parsing::is_builtin_attr(*attr)
})
.for_each(|attr| {
if attr.is_doc_comment() {
Expand Down Expand Up @@ -947,8 +947,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
self.check_defaultness(item.span, *defaultness);

let is_intrinsic =
item.attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic);
let is_intrinsic = item.attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic));
if body.is_none() && !is_intrinsic {
self.dcx().emit_err(errors::FnWithoutBody {
span: item.span,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn eval_condition(
};

match &cfg.kind {
MetaItemKind::List(mis) if cfg.name_or_empty() == sym::version => {
MetaItemKind::List(mis) if cfg.has_name(sym::version) => {
try_gate_cfg(sym::version, cfg.span, sess, features);
let (min_version, span) = match &mis[..] {
[MetaItemInner::Lit(MetaItemLit { kind: LitKind::Str(sym, ..), span, .. })] => {
Expand Down Expand Up @@ -149,26 +149,26 @@ pub fn eval_condition(

// The unwraps below may look dangerous, but we've already asserted
// that they won't fail with the loop above.
match cfg.name_or_empty() {
sym::any => mis
match cfg.name() {
Some(sym::any) => mis
.iter()
// We don't use any() here, because we want to evaluate all cfg condition
// as eval_condition can (and does) extra checks
.fold(false, |res, mi| res | eval_condition(mi, sess, features, eval)),
sym::all => mis
Some(sym::all) => mis
.iter()
// We don't use all() here, because we want to evaluate all cfg condition
// as eval_condition can (and does) extra checks
.fold(true, |res, mi| res & eval_condition(mi, sess, features, eval)),
sym::not => {
Some(sym::not) => {
let [mi] = mis.as_slice() else {
dcx.emit_err(session_diagnostics::ExpectedOneCfgPattern { span: cfg.span });
return false;
};

!eval_condition(mi, sess, features, eval)
}
sym::target => {
Some(sym::target) => {
if let Some(features) = features
&& !features.cfg_target_compact()
{
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<'sess> AttributeParser<'sess> {
// if we're only looking for a single attribute,
// skip all the ones we don't care about
if let Some(expected) = self.parse_only {
if attr.name_or_empty() != expected {
if !attr.has_name(expected) {
continue;
}
}
Expand All @@ -232,7 +232,7 @@ impl<'sess> AttributeParser<'sess> {
// that's expanded right? But no, sometimes, when parsing attributes on macros,
// we already use the lowering logic and these are still there. So, when `omit_doc`
// is set we *also* want to ignore these
if omit_doc == OmitDoc::Skip && attr.name_or_empty() == sym::doc {
if omit_doc == OmitDoc::Skip && attr.has_name(sym::doc) {
continue;
}

Expand All @@ -250,7 +250,7 @@ impl<'sess> AttributeParser<'sess> {
}))
}
// // FIXME: make doc attributes go through a proper attribute parser
// ast::AttrKind::Normal(n) if n.name_or_empty() == sym::doc => {
// ast::AttrKind::Normal(n) if n.has_name(sym::doc) => {
// let p = GenericMetaItemParser::from_attr(&n, self.dcx());
//
// attributes.push(Attribute::Parsed(AttributeKind::DocComment {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,14 @@ impl<'a> TraitDef<'a> {
item.attrs
.iter()
.filter(|a| {
[
a.has_any_name(&[
sym::allow,
sym::warn,
sym::deny,
sym::forbid,
sym::stable,
sym::unstable,
]
.contains(&a.name_or_empty())
])
})
.cloned(),
);
Expand Down
33 changes: 19 additions & 14 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,26 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
no_sanitize_span = Some(attr.span());
if let Some(list) = attr.meta_item_list() {
for item in list.iter() {
match item.name_or_empty() {
sym::address => {
match item.name() {
Some(sym::address) => {
codegen_fn_attrs.no_sanitize |=
SanitizerSet::ADDRESS | SanitizerSet::KERNELADDRESS
}
sym::cfi => codegen_fn_attrs.no_sanitize |= SanitizerSet::CFI,
sym::kcfi => codegen_fn_attrs.no_sanitize |= SanitizerSet::KCFI,
sym::memory => codegen_fn_attrs.no_sanitize |= SanitizerSet::MEMORY,
sym::memtag => codegen_fn_attrs.no_sanitize |= SanitizerSet::MEMTAG,
sym::shadow_call_stack => {
Some(sym::cfi) => codegen_fn_attrs.no_sanitize |= SanitizerSet::CFI,
Some(sym::kcfi) => codegen_fn_attrs.no_sanitize |= SanitizerSet::KCFI,
Some(sym::memory) => {
codegen_fn_attrs.no_sanitize |= SanitizerSet::MEMORY
}
Some(sym::memtag) => {
codegen_fn_attrs.no_sanitize |= SanitizerSet::MEMTAG
}
Some(sym::shadow_call_stack) => {
codegen_fn_attrs.no_sanitize |= SanitizerSet::SHADOWCALLSTACK
}
sym::thread => codegen_fn_attrs.no_sanitize |= SanitizerSet::THREAD,
sym::hwaddress => {
Some(sym::thread) => {
codegen_fn_attrs.no_sanitize |= SanitizerSet::THREAD
}
Some(sym::hwaddress) => {
codegen_fn_attrs.no_sanitize |= SanitizerSet::HWADDRESS
}
_ => {
Expand Down Expand Up @@ -420,9 +426,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
continue;
};

let attrib_to_write = match meta_item.name_or_empty() {
sym::prefix_nops => &mut prefix,
sym::entry_nops => &mut entry,
let attrib_to_write = match meta_item.name() {
Some(sym::prefix_nops) => &mut prefix,
Some(sym::entry_nops) => &mut entry,
_ => {
tcx.dcx().emit_err(errors::UnexpectedParameterName {
span: item.span(),
Expand Down Expand Up @@ -786,8 +792,7 @@ impl<'a> MixedExportNameAndNoMangleState<'a> {
fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> {
let attrs = tcx.get_attrs(id, sym::rustc_autodiff);

let attrs =
attrs.filter(|attr| attr.name_or_empty() == sym::rustc_autodiff).collect::<Vec<_>>();
let attrs = attrs.filter(|attr| attr.has_name(sym::rustc_autodiff)).collect::<Vec<_>>();

// check for exactly one autodiff attribute on placeholder functions.
// There should only be one, since we generate a new placeholder per ad macro.
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,10 +824,10 @@ impl SyntaxExtension {
return Err(item.span);
}

match item.name_or_empty() {
sym::no => Ok(CollapseMacroDebuginfo::No),
sym::external => Ok(CollapseMacroDebuginfo::External),
sym::yes => Ok(CollapseMacroDebuginfo::Yes),
match item.name() {
Some(sym::no) => Ok(CollapseMacroDebuginfo::No),
Some(sym::external) => Ok(CollapseMacroDebuginfo::External),
Some(sym::yes) => Ok(CollapseMacroDebuginfo::Yes),
_ => Err(item.path.span),
}
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2053,8 +2053,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
) -> Node::OutputTy {
loop {
return match self.take_first_attr(&mut node) {
Some((attr, pos, derives)) => match attr.name_or_empty() {
sym::cfg => {
Some((attr, pos, derives)) => match attr.name() {
Some(sym::cfg) => {
let (res, meta_item) = self.expand_cfg_true(&mut node, attr, pos);
if res {
continue;
Expand All @@ -2071,7 +2071,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
}
Default::default()
}
sym::cfg_attr => {
Some(sym::cfg_attr) => {
self.expand_cfg_attr(&mut node, &attr, pos);
continue;
}
Expand Down Expand Up @@ -2144,8 +2144,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
) {
loop {
return match self.take_first_attr(node) {
Some((attr, pos, derives)) => match attr.name_or_empty() {
sym::cfg => {
Some((attr, pos, derives)) => match attr.name() {
Some(sym::cfg) => {
let span = attr.span;
if self.expand_cfg_true(node, attr, pos).0 {
continue;
Expand All @@ -2154,7 +2154,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
node.expand_cfg_false(self, pos, span);
continue;
}
sym::cfg_attr => {
Some(sym::cfg_attr) => {
self.expand_cfg_attr(node, &attr, pos);
continue;
}
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ impl AttributeExt for Attribute {
Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
Some((*comment, *kind))
}
Attribute::Unparsed(_) if self.name_or_empty() == sym::doc => {
Attribute::Unparsed(_) if self.has_name(sym::doc) => {
self.value_str().map(|s| (s, CommentKind::Line))
}
_ => None,
Expand All @@ -1262,8 +1262,8 @@ impl Attribute {
}

#[inline]
pub fn name_or_empty(&self) -> Symbol {
AttributeExt::name_or_empty(self)
pub fn name(&self) -> Option<Symbol> {
AttributeExt::name(self)
}

#[inline]
Expand Down Expand Up @@ -1301,6 +1301,11 @@ impl Attribute {
AttributeExt::has_name(self, name)
}

#[inline]
pub fn has_any_name(&self, names: &[Symbol]) -> bool {
AttributeExt::has_any_name(self, names)
}

#[inline]
pub fn span(&self) -> Span {
AttributeExt::span(self)
Expand Down
10 changes: 7 additions & 3 deletions compiler/rustc_hir_analysis/src/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use rustc_infer::infer::InferCtxt;
use rustc_infer::traits::PredicateObligations;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_session::Limit;
use rustc_span::Span;
use rustc_span::def_id::{LOCAL_CRATE, LocalDefId};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::traits::ObligationCtxt;
use tracing::{debug, instrument};

Expand Down Expand Up @@ -259,7 +259,11 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
}
}

pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
pub fn report_autoderef_recursion_limit_error<'tcx>(
tcx: TyCtxt<'tcx>,
span: Span,
ty: Ty<'tcx>,
) -> ErrorGuaranteed {
// We've reached the recursion limit, error gracefully.
let suggested_limit = match tcx.recursion_limit() {
Limit(0) => Limit(2),
Expand All @@ -270,5 +274,5 @@ pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Spa
ty,
suggested_limit,
crate_name: tcx.crate_name(LOCAL_CRATE),
});
})
}
Loading
Loading