Skip to content

Commit 7dfa752

Browse files
authored
Merge pull request #4402 from rust-lang/rustup-2025-06-17
Automatic Rustup
2 parents 5770b90 + fdc01cf commit 7dfa752

File tree

293 files changed

+4628
-1759
lines changed

Some content is hidden

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

293 files changed

+4628
-1759
lines changed

.mailmap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ Alona Enraght-Moony <code@alona.page> <nixon@caminus.local>
3434
Alona Enraght-Moony <code@alona.page> <contact@alona.page>
3535
Amanda Stjerna <mail@amandastjerna.se> <albin.stjerna@gmail.com>
3636
Amanda Stjerna <mail@amandastjerna.se> <amanda.stjerna@it.uu.se>
37+
Amanieu d'Antras <amanieu@gmail.com> <amanieu.dantras@huawei.com>
3738
Amos Onn <amosonn@gmail.com>
3839
Ana-Maria Mihalache <mihalacheana.maria@yahoo.com>
3940
Anatoly Ikorsky <aikorsky@gmail.com>
4041
Andre Bogus <bogusandre@gmail.com>
42+
Andre Bogus <bogusandre@gmail.com> <andre.bogus@aleph-alpha.de>
43+
Andre Bogus <bogusandre@gmail.com> <andre.bogus@ankordata.de>
4144
Andrea Ciliberti <meziu210@icloud.com>
4245
Andreas Gal <gal@mozilla.com> <andreas.gal@gmail.com>
4346
Andreas Jonson <andjo403@users.noreply.github.com>
@@ -116,6 +119,7 @@ Carol Willing <carolcode@willingconsulting.com>
116119
Chandler Deng <chandde@microsoft.com>
117120
Charles Lew <crlf0710@gmail.com> CrLF0710 <crlf0710@gmail.com>
118121
Chris C Cerami <chrisccerami@users.noreply.github.com> Chris C Cerami <chrisccerami@gmail.com>
122+
Chris Denton <chris@chrisdenton.dev> <christophersdenton@gmail.com>
119123
Chris Denton <chris@chrisdenton.dev> Chris Denton <ChrisDenton@users.noreply.github.com>
120124
Chris Gregory <czipperz@gmail.com>
121125
Chris Pardy <chrispardy36@gmail.com>
@@ -403,6 +407,8 @@ Urgau <urgau@numericable.fr> <3616612+Urgau@users.noreply.github.com>
403407
Lucy <luxx4x@protonmail.com>
404408
Lukas H. <lukaramu@users.noreply.github.com>
405409
Lukas Lueg <lukas.lueg@gmail.com>
410+
Lukas Wirth <lukastw97@gmail.com> <lukas.wirth@ferrous-systems.com>
411+
Lukas Wirth <lukastw97@gmail.com> <me@lukaswirth.dev>
406412
Luke Metz <luke.metz@students.olin.edu>
407413
Luqman Aden <me@luqman.ca> <laden@csclub.uwaterloo.ca>
408414
Luqman Aden <me@luqman.ca> <laden@mozilla.com>
@@ -493,6 +499,7 @@ Nicolas Abram <abramlujan@gmail.com>
493499
Nicole Mazzuca <npmazzuca@gmail.com>
494500
Niko Matsakis <rust@nikomatsakis.com>
495501
Niko Matsakis <rust@nikomatsakis.com> <niko@alum.mit.edu>
502+
Niko Matsakis <rust@nikomatsakis.com> <nikomat@amazon.com>
496503
Noratrieb <48135649+Noratrieb@users.noreply.github.com>
497504
Noratrieb <48135649+Noratrieb@users.noreply.github.com> <48135649+Nilstrieb@users.noreply.github.com>
498505
Noratrieb <48135649+Noratrieb@users.noreply.github.com> <nilstrieb@gmail.com>

compiler/rustc_ast/src/ast.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,20 @@ impl Expr {
14501450
}
14511451

14521452
pub fn precedence(&self) -> ExprPrecedence {
1453+
fn prefix_attrs_precedence(attrs: &AttrVec) -> ExprPrecedence {
1454+
for attr in attrs {
1455+
if let AttrStyle::Outer = attr.style {
1456+
return ExprPrecedence::Prefix;
1457+
}
1458+
}
1459+
ExprPrecedence::Unambiguous
1460+
}
1461+
14531462
match &self.kind {
14541463
ExprKind::Closure(closure) => {
14551464
match closure.fn_decl.output {
14561465
FnRetTy::Default(_) => ExprPrecedence::Jump,
1457-
FnRetTy::Ty(_) => ExprPrecedence::Unambiguous,
1466+
FnRetTy::Ty(_) => prefix_attrs_precedence(&self.attrs),
14581467
}
14591468
}
14601469

@@ -1463,7 +1472,7 @@ impl Expr {
14631472
| ExprKind::Yield(YieldKind::Prefix(value))
14641473
| ExprKind::Yeet(value) => match value {
14651474
Some(_) => ExprPrecedence::Jump,
1466-
None => ExprPrecedence::Unambiguous,
1475+
None => prefix_attrs_precedence(&self.attrs),
14671476
},
14681477

14691478
ExprKind::Become(_) => ExprPrecedence::Jump,
@@ -1490,7 +1499,7 @@ impl Expr {
14901499
| ExprKind::Let(..)
14911500
| ExprKind::Unary(..) => ExprPrecedence::Prefix,
14921501

1493-
// Never need parens
1502+
// Need parens if and only if there are prefix attributes.
14941503
ExprKind::Array(_)
14951504
| ExprKind::Await(..)
14961505
| ExprKind::Use(..)
@@ -1525,7 +1534,7 @@ impl Expr {
15251534
| ExprKind::While(..)
15261535
| ExprKind::Yield(YieldKind::Postfix(..))
15271536
| ExprKind::Err(_)
1528-
| ExprKind::Dummy => ExprPrecedence::Unambiguous,
1537+
| ExprKind::Dummy => prefix_attrs_precedence(&self.attrs),
15291538
}
15301539
}
15311540

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,8 @@ fn visit_nested_use_tree<'a, V: Visitor<'a>>(
17001700
}
17011701

17021702
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V::Result {
1703-
let Stmt { id: _, kind, span: _ } = statement;
1703+
let Stmt { id, kind, span: _ } = statement;
1704+
try_visit!(visit_id(visitor, id));
17041705
match kind {
17051706
StmtKind::Let(local) => try_visit!(visitor.visit_local(local)),
17061707
StmtKind::Item(item) => try_visit!(visitor.visit_item(item)),

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
145145
kind,
146146
vis_span,
147147
span: self.lower_span(i.span),
148+
has_delayed_lints: !self.delayed_lints.is_empty(),
148149
};
149150
self.arena.alloc(item)
150151
}
@@ -599,6 +600,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
599600
kind,
600601
vis_span,
601602
span: this.lower_span(use_tree.span),
603+
has_delayed_lints: !this.delayed_lints.is_empty(),
602604
};
603605
hir::OwnerNode::Item(this.arena.alloc(item))
604606
});
@@ -697,6 +699,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
697699
kind,
698700
vis_span: self.lower_span(i.vis.span),
699701
span: self.lower_span(i.span),
702+
has_delayed_lints: !self.delayed_lints.is_empty(),
700703
};
701704
self.arena.alloc(item)
702705
}
@@ -941,6 +944,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
941944
kind,
942945
span: self.lower_span(i.span),
943946
defaultness: hir::Defaultness::Default { has_value: has_default },
947+
has_delayed_lints: !self.delayed_lints.is_empty(),
944948
};
945949
self.arena.alloc(item)
946950
}
@@ -1100,6 +1104,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11001104
vis_span: self.lower_span(i.vis.span),
11011105
span: self.lower_span(i.span),
11021106
defaultness,
1107+
has_delayed_lints: !self.delayed_lints.is_empty(),
11031108
};
11041109
self.arena.alloc(item)
11051110
}

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,54 @@ impl Deprecation {
130130
}
131131
}
132132

133-
/// Represent parsed, *built in*, inert attributes.
133+
/// Represents parsed *built-in* inert attributes.
134134
///
135-
/// That means attributes that are not actually ever expanded.
136-
/// For more information on this, see the module docs on the [`rustc_attr_parsing`] crate.
137-
/// They're instead used as markers, to guide the compilation process in various way in most every stage of the compiler.
138-
/// These are kept around after the AST, into the HIR and further on.
135+
/// ## Overview
136+
/// These attributes are markers that guide the compilation process and are never expanded into other code.
137+
/// They persist throughout the compilation phases, from AST to HIR and beyond.
139138
///
140-
/// The word "parsed" could be a little misleading here, because the parser already parses
141-
/// attributes early on. However, the result, an [`ast::Attribute`]
142-
/// is only parsed at a high level, still containing a token stream in many cases. That is
143-
/// because the structure of the contents varies from attribute to attribute.
144-
/// With a parsed attribute I mean that each attribute is processed individually into a
145-
/// final structure, which on-site (the place where the attribute is useful for, think the
146-
/// the place where `must_use` is checked) little to no extra parsing or validating needs to
147-
/// happen.
139+
/// ## Attribute Processing
140+
/// While attributes are initially parsed by [`rustc_parse`] into [`ast::Attribute`], they still contain raw token streams
141+
/// because different attributes have different internal structures. This enum represents the final,
142+
/// fully parsed form of these attributes, where each variant contains contains all the information and
143+
/// structure relevant for the specific attribute.
148144
///
149-
/// For more docs, look in [`rustc_attr_parsing`].
145+
/// Some attributes can be applied multiple times to the same item, and they are "collapsed" into a single
146+
/// semantic attribute. For example:
147+
/// ```rust
148+
/// #[repr(C)]
149+
/// #[repr(packed)]
150+
/// struct S { }
151+
/// ```
152+
/// This is equivalent to `#[repr(C, packed)]` and results in a single [`AttributeKind::Repr`] containing
153+
/// both `C` and `packed` annotations. This collapsing happens during parsing and is reflected in the
154+
/// data structures defined in this enum.
150155
///
156+
/// ## Usage
157+
/// These parsed attributes are used throughout the compiler to:
158+
/// - Control code generation (e.g., `#[repr]`)
159+
/// - Mark API stability (`#[stable]`, `#[unstable]`)
160+
/// - Provide documentation (`#[doc]`)
161+
/// - Guide compiler behavior (e.g., `#[allow_internal_unstable]`)
162+
///
163+
/// ## Note on Attribute Organization
164+
/// Some attributes like `InlineAttr`, `OptimizeAttr`, and `InstructionSetAttr` are defined separately
165+
/// from this enum because they are used in specific compiler phases (like code generation) and don't
166+
/// need to persist throughout the entire compilation process. They are typically processed and
167+
/// converted into their final form earlier in the compilation pipeline.
168+
///
169+
/// For example:
170+
/// - `InlineAttr` is used during code generation to control function inlining
171+
/// - `OptimizeAttr` is used to control optimization levels
172+
/// - `InstructionSetAttr` is used for target-specific code generation
173+
///
174+
/// These attributes are handled by their respective compiler passes in the [`rustc_codegen_ssa`] crate
175+
/// and don't need to be preserved in the same way as the attributes in this enum.
176+
///
177+
/// For more details on attribute parsing, see the [`rustc_attr_parsing`] crate.
178+
///
179+
/// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
180+
/// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html
151181
/// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html
152182
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
153183
pub enum AttributeKind {
@@ -158,6 +188,9 @@ pub enum AttributeKind {
158188
/// Represents `#[allow_internal_unstable]`.
159189
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
160190

191+
/// Represents `#[rustc_as_ptr]` (used by the `dangling_pointers_from_temporaries` lint).
192+
AsPtr(Span),
193+
161194
/// Represents `#[rustc_default_body_unstable]`.
162195
BodyStability {
163196
stability: DefaultBodyStability,

compiler/rustc_attr_data_structures/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Data structures for representing parsed attributes in the Rust compiler.
2+
//! For detailed documentation about attribute processing,
3+
//! see [rustc_attr_parsing](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html).
4+
15
// tidy-alphabetical-start
26
#![allow(internal_features)]
37
#![doc(rust_logo)]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use rustc_attr_data_structures::AttributeKind;
2+
use rustc_span::{Symbol, sym};
3+
4+
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
5+
use crate::context::{AcceptContext, Stage};
6+
use crate::parser::ArgParser;
7+
8+
pub(crate) struct AsPtrParser;
9+
10+
impl<S: Stage> SingleAttributeParser<S> for AsPtrParser {
11+
const PATH: &[Symbol] = &[sym::rustc_as_ptr];
12+
13+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
14+
15+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
16+
17+
fn convert(cx: &mut AcceptContext<'_, '_, S>, _args: &ArgParser<'_>) -> Option<AttributeKind> {
18+
// FIXME: check that there's no args (this is currently checked elsewhere)
19+
Some(AttributeKind::AsPtr(cx.attr_span))
20+
}
21+
}

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub(crate) mod allow_unstable;
2929
pub(crate) mod cfg;
3030
pub(crate) mod confusables;
3131
pub(crate) mod deprecation;
32+
pub(crate) mod lint_helpers;
3233
pub(crate) mod repr;
3334
pub(crate) mod stability;
3435
pub(crate) mod transparency;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1818
use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser};
1919
use crate::attributes::confusables::ConfusablesParser;
2020
use crate::attributes::deprecation::DeprecationParser;
21+
use crate::attributes::lint_helpers::AsPtrParser;
2122
use crate::attributes::repr::ReprParser;
2223
use crate::attributes::stability::{
2324
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
@@ -102,6 +103,7 @@ attribute_parsers!(
102103
// tidy-alphabetical-end
103104

104105
// tidy-alphabetical-start
106+
Single<AsPtrParser>,
105107
Single<ConstStabilityIndirectParser>,
106108
Single<DeprecationParser>,
107109
Single<TransparencyParser>,

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22

33
use rustc_data_structures::fx::FxIndexMap;
44
use rustc_data_structures::graph;
5-
use rustc_index::bit_set::DenseBitSet;
5+
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
66
use rustc_middle::mir::{
77
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
88
};
@@ -548,7 +548,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
548548
}
549549
}
550550

551-
type BorrowsDomain = DenseBitSet<BorrowIndex>;
551+
type BorrowsDomain = MixedBitSet<BorrowIndex>;
552552

553553
/// Forward dataflow computation of the set of borrows that are in scope at a particular location.
554554
/// - we gen the introduced loans
@@ -564,7 +564,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
564564

565565
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
566566
// bottom = nothing is reserved or activated yet;
567-
DenseBitSet::new_empty(self.borrow_set.len())
567+
MixedBitSet::new_empty(self.borrow_set.len())
568568
}
569569

570570
fn initialize_start_block(&self, _: &mir::Body<'tcx>, _: &mut Self::Domain) {

0 commit comments

Comments
 (0)