Skip to content

Commit a0f57d8

Browse files
committed
Auto merge of #3892 - rust-lang:rustup-2024-09-16, r=RalfJung
Automatic Rustup
2 parents 7d8ee71 + 5b8a18f commit a0f57d8

File tree

432 files changed

+5132
-3278
lines changed

Some content is hidden

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

432 files changed

+5132
-3278
lines changed

Diff for: compiler/rustc_abi/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ impl Align {
781781
}
782782

783783
/// A pair of alignments, ABI-mandated and preferred.
784+
///
785+
/// The "preferred" alignment is an LLVM concept that is virtually meaningless to Rust code:
786+
/// it is not exposed semantically to programmers nor can they meaningfully affect it.
787+
/// The only concern for us is that preferred alignment must not be less than the mandated alignment
788+
/// and thus in practice the two values are almost always identical.
789+
///
790+
/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
791+
/// It is of effectively no consequence for layout in structs and on the stack.
784792
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
785793
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
786794
pub struct AbiAndPrefAlign {

Diff for: compiler/rustc_arena/src/lib.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -614,34 +614,34 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
614614

615615
pub trait ArenaAllocatable<'tcx, C = rustc_arena::IsNotCopy>: Sized {
616616
#[allow(clippy::mut_from_ref)]
617-
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self;
617+
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self;
618618
#[allow(clippy::mut_from_ref)]
619-
fn allocate_from_iter<'a>(
620-
arena: &'a Arena<'tcx>,
619+
fn allocate_from_iter(
620+
arena: &'tcx Arena<'tcx>,
621621
iter: impl ::std::iter::IntoIterator<Item = Self>,
622-
) -> &'a mut [Self];
622+
) -> &'tcx mut [Self];
623623
}
624624

625625
// Any type that impls `Copy` can be arena-allocated in the `DroplessArena`.
626626
impl<'tcx, T: Copy> ArenaAllocatable<'tcx, rustc_arena::IsCopy> for T {
627627
#[inline]
628628
#[allow(clippy::mut_from_ref)]
629-
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
629+
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self {
630630
arena.dropless.alloc(self)
631631
}
632632
#[inline]
633633
#[allow(clippy::mut_from_ref)]
634-
fn allocate_from_iter<'a>(
635-
arena: &'a Arena<'tcx>,
634+
fn allocate_from_iter(
635+
arena: &'tcx Arena<'tcx>,
636636
iter: impl ::std::iter::IntoIterator<Item = Self>,
637-
) -> &'a mut [Self] {
637+
) -> &'tcx mut [Self] {
638638
arena.dropless.alloc_from_iter(iter)
639639
}
640640
}
641641
$(
642642
impl<'tcx> ArenaAllocatable<'tcx, rustc_arena::IsNotCopy> for $ty {
643643
#[inline]
644-
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
644+
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self {
645645
if !::std::mem::needs_drop::<Self>() {
646646
arena.dropless.alloc(self)
647647
} else {
@@ -651,10 +651,10 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
651651

652652
#[inline]
653653
#[allow(clippy::mut_from_ref)]
654-
fn allocate_from_iter<'a>(
655-
arena: &'a Arena<'tcx>,
654+
fn allocate_from_iter(
655+
arena: &'tcx Arena<'tcx>,
656656
iter: impl ::std::iter::IntoIterator<Item = Self>,
657-
) -> &'a mut [Self] {
657+
) -> &'tcx mut [Self] {
658658
if !::std::mem::needs_drop::<Self>() {
659659
arena.dropless.alloc_from_iter(iter)
660660
} else {
@@ -667,7 +667,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
667667
impl<'tcx> Arena<'tcx> {
668668
#[inline]
669669
#[allow(clippy::mut_from_ref)]
670-
pub fn alloc<T: ArenaAllocatable<'tcx, C>, C>(&self, value: T) -> &mut T {
670+
pub fn alloc<T: ArenaAllocatable<'tcx, C>, C>(&'tcx self, value: T) -> &mut T {
671671
value.allocate_on(self)
672672
}
673673

@@ -691,7 +691,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
691691

692692
#[allow(clippy::mut_from_ref)]
693693
pub fn alloc_from_iter<T: ArenaAllocatable<'tcx, C>, C>(
694-
&self,
694+
&'tcx self,
695695
iter: impl ::std::iter::IntoIterator<Item = T>,
696696
) -> &mut [T] {
697697
T::allocate_from_iter(self, iter)

Diff for: compiler/rustc_ast_passes/src/feature_gate.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,9 @@ struct PostExpansionVisitor<'a> {
7575

7676
impl<'a> PostExpansionVisitor<'a> {
7777
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
78-
fn check_abi(&self, abi: ast::StrLit, constness: ast::Const) {
78+
fn check_abi(&self, abi: ast::StrLit) {
7979
let ast::StrLit { symbol_unescaped, span, .. } = abi;
8080

81-
if let ast::Const::Yes(_) = constness {
82-
match symbol_unescaped {
83-
// Stable
84-
sym::Rust | sym::C => {}
85-
abi => gate!(
86-
&self,
87-
const_extern_fn,
88-
span,
89-
format!("`{}` as a `const fn` ABI is unstable", abi)
90-
),
91-
}
92-
}
93-
9481
match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) {
9582
Ok(()) => (),
9683
Err(abi::AbiDisabled::Unstable { feature, explain }) => {
@@ -110,9 +97,9 @@ impl<'a> PostExpansionVisitor<'a> {
11097
}
11198
}
11299

113-
fn check_extern(&self, ext: ast::Extern, constness: ast::Const) {
100+
fn check_extern(&self, ext: ast::Extern) {
114101
if let ast::Extern::Explicit(abi, _) = ext {
115-
self.check_abi(abi, constness);
102+
self.check_abi(abi);
116103
}
117104
}
118105

@@ -239,7 +226,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
239226
match &i.kind {
240227
ast::ItemKind::ForeignMod(foreign_module) => {
241228
if let Some(abi) = foreign_module.abi {
242-
self.check_abi(abi, ast::Const::No);
229+
self.check_abi(abi);
243230
}
244231
}
245232

@@ -341,7 +328,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
341328
match &ty.kind {
342329
ast::TyKind::BareFn(bare_fn_ty) => {
343330
// Function pointers cannot be `const`
344-
self.check_extern(bare_fn_ty.ext, ast::Const::No);
331+
self.check_extern(bare_fn_ty.ext);
345332
self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params);
346333
}
347334
ast::TyKind::Never => {
@@ -446,7 +433,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
446433
fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) {
447434
if let Some(header) = fn_kind.header() {
448435
// Stability of const fn methods are covered in `visit_assoc_item` below.
449-
self.check_extern(header.ext, header.constness);
436+
self.check_extern(header.ext);
450437
}
451438

452439
if let FnKind::Closure(ast::ClosureBinder::For { generic_params, .. }, ..) = fn_kind {

Diff for: compiler/rustc_borrowck/src/constraints/graph.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ impl<D: ConstraintGraphDirection> ConstraintGraph<D> {
9797
/// Given the constraint set from which this graph was built
9898
/// creates a region graph so that you can iterate over *regions*
9999
/// and not constraints.
100-
pub(crate) fn region_graph<'rg, 'tcx>(
101-
&'rg self,
102-
set: &'rg OutlivesConstraintSet<'tcx>,
100+
pub(crate) fn region_graph<'a, 'tcx>(
101+
&'a self,
102+
set: &'a OutlivesConstraintSet<'tcx>,
103103
static_region: RegionVid,
104-
) -> RegionGraph<'rg, 'tcx, D> {
104+
) -> RegionGraph<'a, 'tcx, D> {
105105
RegionGraph::new(set, self, static_region)
106106
}
107107

@@ -130,15 +130,15 @@ impl<D: ConstraintGraphDirection> ConstraintGraph<D> {
130130
}
131131
}
132132

133-
pub(crate) struct Edges<'s, 'tcx, D: ConstraintGraphDirection> {
134-
graph: &'s ConstraintGraph<D>,
135-
constraints: &'s OutlivesConstraintSet<'tcx>,
133+
pub(crate) struct Edges<'a, 'tcx, D: ConstraintGraphDirection> {
134+
graph: &'a ConstraintGraph<D>,
135+
constraints: &'a OutlivesConstraintSet<'tcx>,
136136
pointer: Option<OutlivesConstraintIndex>,
137137
next_static_idx: Option<usize>,
138138
static_region: RegionVid,
139139
}
140140

141-
impl<'s, 'tcx, D: ConstraintGraphDirection> Iterator for Edges<'s, 'tcx, D> {
141+
impl<'a, 'tcx, D: ConstraintGraphDirection> Iterator for Edges<'a, 'tcx, D> {
142142
type Item = OutlivesConstraint<'tcx>;
143143

144144
fn next(&mut self) -> Option<Self::Item> {
@@ -171,55 +171,55 @@ impl<'s, 'tcx, D: ConstraintGraphDirection> Iterator for Edges<'s, 'tcx, D> {
171171
/// This struct brings together a constraint set and a (normal, not
172172
/// reverse) constraint graph. It implements the graph traits and is
173173
/// usd for doing the SCC computation.
174-
pub(crate) struct RegionGraph<'s, 'tcx, D: ConstraintGraphDirection> {
175-
set: &'s OutlivesConstraintSet<'tcx>,
176-
constraint_graph: &'s ConstraintGraph<D>,
174+
pub(crate) struct RegionGraph<'a, 'tcx, D: ConstraintGraphDirection> {
175+
set: &'a OutlivesConstraintSet<'tcx>,
176+
constraint_graph: &'a ConstraintGraph<D>,
177177
static_region: RegionVid,
178178
}
179179

180-
impl<'s, 'tcx, D: ConstraintGraphDirection> RegionGraph<'s, 'tcx, D> {
180+
impl<'a, 'tcx, D: ConstraintGraphDirection> RegionGraph<'a, 'tcx, D> {
181181
/// Creates a "dependency graph" where each region constraint `R1:
182182
/// R2` is treated as an edge `R1 -> R2`. We use this graph to
183183
/// construct SCCs for region inference but also for error
184184
/// reporting.
185185
pub(crate) fn new(
186-
set: &'s OutlivesConstraintSet<'tcx>,
187-
constraint_graph: &'s ConstraintGraph<D>,
186+
set: &'a OutlivesConstraintSet<'tcx>,
187+
constraint_graph: &'a ConstraintGraph<D>,
188188
static_region: RegionVid,
189189
) -> Self {
190190
Self { set, constraint_graph, static_region }
191191
}
192192

193193
/// Given a region `R`, iterate over all regions `R1` such that
194194
/// there exists a constraint `R: R1`.
195-
pub(crate) fn outgoing_regions(&self, region_sup: RegionVid) -> Successors<'s, 'tcx, D> {
195+
pub(crate) fn outgoing_regions(&self, region_sup: RegionVid) -> Successors<'a, 'tcx, D> {
196196
Successors {
197197
edges: self.constraint_graph.outgoing_edges(region_sup, self.set, self.static_region),
198198
}
199199
}
200200
}
201201

202-
pub(crate) struct Successors<'s, 'tcx, D: ConstraintGraphDirection> {
203-
edges: Edges<'s, 'tcx, D>,
202+
pub(crate) struct Successors<'a, 'tcx, D: ConstraintGraphDirection> {
203+
edges: Edges<'a, 'tcx, D>,
204204
}
205205

206-
impl<'s, 'tcx, D: ConstraintGraphDirection> Iterator for Successors<'s, 'tcx, D> {
206+
impl<'a, 'tcx, D: ConstraintGraphDirection> Iterator for Successors<'a, 'tcx, D> {
207207
type Item = RegionVid;
208208

209209
fn next(&mut self) -> Option<Self::Item> {
210210
self.edges.next().map(|c| D::end_region(&c))
211211
}
212212
}
213213

214-
impl<'s, 'tcx, D: ConstraintGraphDirection> graph::DirectedGraph for RegionGraph<'s, 'tcx, D> {
214+
impl<'a, 'tcx, D: ConstraintGraphDirection> graph::DirectedGraph for RegionGraph<'a, 'tcx, D> {
215215
type Node = RegionVid;
216216

217217
fn num_nodes(&self) -> usize {
218218
self.constraint_graph.first_constraints.len()
219219
}
220220
}
221221

222-
impl<'s, 'tcx, D: ConstraintGraphDirection> graph::Successors for RegionGraph<'s, 'tcx, D> {
222+
impl<'a, 'tcx, D: ConstraintGraphDirection> graph::Successors for RegionGraph<'a, 'tcx, D> {
223223
fn successors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node> {
224224
self.outgoing_regions(node)
225225
}

Diff for: compiler/rustc_borrowck/src/dataflow.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ pub struct Borrows<'a, 'tcx> {
112112
borrows_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
113113
}
114114

115-
struct OutOfScopePrecomputer<'mir, 'tcx> {
115+
struct OutOfScopePrecomputer<'a, 'tcx> {
116116
visited: BitSet<mir::BasicBlock>,
117117
visit_stack: Vec<mir::BasicBlock>,
118-
body: &'mir Body<'tcx>,
119-
regioncx: &'mir RegionInferenceContext<'tcx>,
118+
body: &'a Body<'tcx>,
119+
regioncx: &'a RegionInferenceContext<'tcx>,
120120
borrows_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
121121
}
122122

123-
impl<'mir, 'tcx> OutOfScopePrecomputer<'mir, 'tcx> {
124-
fn new(body: &'mir Body<'tcx>, regioncx: &'mir RegionInferenceContext<'tcx>) -> Self {
123+
impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> {
124+
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
125125
OutOfScopePrecomputer {
126126
visited: BitSet::new_empty(body.basic_blocks.len()),
127127
visit_stack: vec![],
@@ -224,17 +224,17 @@ pub fn calculate_borrows_out_of_scope_at_location<'tcx>(
224224
prec.borrows_out_of_scope_at_location
225225
}
226226

227-
struct PoloniusOutOfScopePrecomputer<'mir, 'tcx> {
227+
struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
228228
visited: BitSet<mir::BasicBlock>,
229229
visit_stack: Vec<mir::BasicBlock>,
230-
body: &'mir Body<'tcx>,
231-
regioncx: &'mir RegionInferenceContext<'tcx>,
230+
body: &'a Body<'tcx>,
231+
regioncx: &'a RegionInferenceContext<'tcx>,
232232

233233
loans_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
234234
}
235235

236-
impl<'mir, 'tcx> PoloniusOutOfScopePrecomputer<'mir, 'tcx> {
237-
fn new(body: &'mir Body<'tcx>, regioncx: &'mir RegionInferenceContext<'tcx>) -> Self {
236+
impl<'a, 'tcx> PoloniusOutOfScopePrecomputer<'a, 'tcx> {
237+
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
238238
Self {
239239
visited: BitSet::new_empty(body.basic_blocks.len()),
240240
visit_stack: vec![],

Diff for: compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3553,7 +3553,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
35533553
location: Location,
35543554
mpi: MovePathIndex,
35553555
) -> (Vec<MoveSite>, Vec<Location>) {
3556-
fn predecessor_locations<'tcx, 'a>(
3556+
fn predecessor_locations<'a, 'tcx>(
35573557
body: &'a mir::Body<'tcx>,
35583558
location: Location,
35593559
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {

Diff for: compiler/rustc_borrowck/src/diagnostics/find_use.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ pub(crate) fn find<'tcx>(
2121
uf.find()
2222
}
2323

24-
struct UseFinder<'cx, 'tcx> {
25-
body: &'cx Body<'tcx>,
26-
regioncx: &'cx Rc<RegionInferenceContext<'tcx>>,
24+
struct UseFinder<'a, 'tcx> {
25+
body: &'a Body<'tcx>,
26+
regioncx: &'a Rc<RegionInferenceContext<'tcx>>,
2727
tcx: TyCtxt<'tcx>,
2828
region_vid: RegionVid,
2929
start_point: Location,
3030
}
3131

32-
impl<'cx, 'tcx> UseFinder<'cx, 'tcx> {
32+
impl<'a, 'tcx> UseFinder<'a, 'tcx> {
3333
fn find(&mut self) -> Option<Cause> {
3434
let mut queue = VecDeque::new();
3535
let mut visited = FxIndexSet::default();
@@ -93,8 +93,8 @@ impl<'cx, 'tcx> UseFinder<'cx, 'tcx> {
9393
}
9494
}
9595

96-
struct DefUseVisitor<'cx, 'tcx> {
97-
body: &'cx Body<'tcx>,
96+
struct DefUseVisitor<'a, 'tcx> {
97+
body: &'a Body<'tcx>,
9898
tcx: TyCtxt<'tcx>,
9999
region_vid: RegionVid,
100100
def_use_result: Option<DefUseResult>,
@@ -106,7 +106,7 @@ enum DefUseResult {
106106
UseDrop { local: Local },
107107
}
108108

109-
impl<'cx, 'tcx> Visitor<'tcx> for DefUseVisitor<'cx, 'tcx> {
109+
impl<'a, 'tcx> Visitor<'tcx> for DefUseVisitor<'a, 'tcx> {
110110
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
111111
let local_ty = self.body.local_decls[local].ty;
112112

Diff for: compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
558558
ty: Ty<'tcx>,
559559
suggested: bool,
560560
}
561-
impl<'a, 'cx, 'tcx> Visitor<'tcx> for SuggestIndexOperatorAlternativeVisitor<'a, 'cx, 'tcx> {
561+
impl<'a, 'infcx, 'tcx> Visitor<'tcx> for SuggestIndexOperatorAlternativeVisitor<'a, 'infcx, 'tcx> {
562562
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
563563
hir::intravisit::walk_stmt(self, stmt);
564564
let expr = match stmt.kind {

Diff for: compiler/rustc_borrowck/src/polonius/loan_invalidations.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ pub(super) fn emit_loan_invalidations<'tcx>(
3232
visitor.visit_body(body);
3333
}
3434

35-
struct LoanInvalidationsGenerator<'cx, 'tcx> {
35+
struct LoanInvalidationsGenerator<'a, 'tcx> {
3636
tcx: TyCtxt<'tcx>,
37-
all_facts: &'cx mut AllFacts,
38-
location_table: &'cx LocationTable,
39-
body: &'cx Body<'tcx>,
40-
dominators: &'cx Dominators<BasicBlock>,
41-
borrow_set: &'cx BorrowSet<'tcx>,
37+
all_facts: &'a mut AllFacts,
38+
location_table: &'a LocationTable,
39+
body: &'a Body<'tcx>,
40+
dominators: &'a Dominators<BasicBlock>,
41+
borrow_set: &'a BorrowSet<'tcx>,
4242
}
4343

4444
/// Visits the whole MIR and generates `invalidates()` facts.
4545
/// Most of the code implementing this was stolen from `borrow_check/mod.rs`.
46-
impl<'cx, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'cx, 'tcx> {
46+
impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
4747
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
4848
self.check_activations(location);
4949

@@ -212,7 +212,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'cx, 'tcx> {
212212
}
213213
}
214214

215-
impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> {
215+
impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
216216
/// Simulates mutation of a place.
217217
fn mutate_place(&mut self, location: Location, place: Place<'tcx>, kind: AccessDepth) {
218218
self.access_place(

0 commit comments

Comments
 (0)