Skip to content

Commit aedf78e

Browse files
committed
Auto merge of #98802 - Dylan-DPC:rollup-u6mwx27, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #98639 (Factor out `hir::Node::Binding`) - #98653 (Add regression test for #79494) - #98763 (bootstrap: illumos platform flags for split-debuginfo) - #98766 (cleanup mir visitor for `rustc::pass_by_value`) - #98783 (interpret: make a comment less scary) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4118ad2 + 7a4f33b commit aedf78e

File tree

45 files changed

+235
-189
lines changed

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

+235
-189
lines changed

compiler/rustc_ast_lowering/src/index.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
192192
}
193193

194194
fn visit_pat(&mut self, pat: &'hir Pat<'hir>) {
195-
let node =
196-
if let PatKind::Binding(..) = pat.kind { Node::Binding(pat) } else { Node::Pat(pat) };
197-
self.insert(pat.span, pat.hir_id, node);
195+
self.insert(pat.span, pat.hir_id, Node::Pat(pat));
198196

199197
self.with_parent(pat.hir_id, |this| {
200198
intravisit::walk_pat(this, pat);

compiler/rustc_borrowck/src/borrow_set.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ impl LocalsStateAtExit {
9292
struct HasStorageDead(BitSet<Local>);
9393

9494
impl<'tcx> Visitor<'tcx> for HasStorageDead {
95-
fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _: Location) {
95+
fn visit_local(&mut self, local: Local, ctx: PlaceContext, _: Location) {
9696
if ctx == PlaceContext::NonUse(NonUseContext::StorageDead) {
97-
self.0.insert(*local);
97+
self.0.insert(local);
9898
}
9999
}
100100
}
@@ -223,7 +223,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
223223
self.super_assign(assigned_place, rvalue, location)
224224
}
225225

226-
fn visit_local(&mut self, temp: &Local, context: PlaceContext, location: Location) {
226+
fn visit_local(&mut self, temp: Local, context: PlaceContext, location: Location) {
227227
if !context.is_use() {
228228
return;
229229
}
@@ -232,7 +232,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
232232
// check whether we (earlier) saw a 2-phase borrow like
233233
//
234234
// TMP = &mut place
235-
if let Some(&borrow_index) = self.pending_activations.get(temp) {
235+
if let Some(&borrow_index) = self.pending_activations.get(&temp) {
236236
let borrow_data = &mut self.location_map[borrow_index.as_usize()];
237237

238238
// Watch out: the use of TMP in the borrow itself

compiler/rustc_borrowck/src/diagnostics/find_all_local_uses.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ struct AllLocalUsesVisitor {
1818
}
1919

2020
impl<'tcx> Visitor<'tcx> for AllLocalUsesVisitor {
21-
fn visit_local(&mut self, local: &Local, _context: PlaceContext, location: Location) {
22-
if *local == self.for_local {
21+
fn visit_local(&mut self, local: Local, _context: PlaceContext, location: Location) {
22+
if local == self.for_local {
2323
self.uses.insert(location);
2424
}
2525
}

compiler/rustc_borrowck/src/diagnostics/find_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ enum DefUseResult {
106106
}
107107

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

112112
let mut found_it = false;

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
362362

363363
let upvar_hir_id = captured_place.get_root_variable();
364364

365-
if let Some(Node::Binding(pat)) = self.infcx.tcx.hir().find(upvar_hir_id)
365+
if let Some(Node::Pat(pat)) = self.infcx.tcx.hir().find(upvar_hir_id)
366366
&& let hir::PatKind::Binding(
367367
hir::BindingAnnotation::Unannotated,
368368
_,

compiler/rustc_borrowck/src/type_check/liveness/local_use_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl LocalUseMapBuild<'_> {
157157
}
158158

159159
impl Visitor<'_> for LocalUseMapBuild<'_> {
160-
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
160+
fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) {
161161
if self.locals_with_use_data[local] {
162162
match def_use::categorize(context) {
163163
Some(DefUse::Def) => self.insert_def(local, location),

compiler/rustc_borrowck/src/type_check/liveness/polonius.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl UseFactsExtractor<'_, '_> {
5454
}
5555

5656
impl<'a, 'tcx> Visitor<'tcx> for UseFactsExtractor<'a, 'tcx> {
57-
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
57+
fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) {
5858
match def_use::categorize(context) {
5959
Some(DefUse::Def) => self.insert_def(local, location),
6060
Some(DefUse::Use) => self.insert_use(local, location),

compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ struct TypeVerifier<'a, 'b, 'tcx> {
333333
}
334334

335335
impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
336-
fn visit_span(&mut self, span: &Span) {
336+
fn visit_span(&mut self, span: Span) {
337337
if !span.is_dummy() {
338-
self.last_span = *span;
338+
self.last_span = span;
339339
}
340340
}
341341

compiler/rustc_borrowck/src/used_muts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tc
9191
self.super_statement(statement, location);
9292
}
9393

94-
fn visit_local(&mut self, local: &Local, place_context: PlaceContext, location: Location) {
95-
if place_context.is_place_assignment() && self.temporary_used_locals.contains(local) {
94+
fn visit_local(&mut self, local: Local, place_context: PlaceContext, location: Location) {
95+
if place_context.is_place_assignment() && self.temporary_used_locals.contains(&local) {
9696
// Propagate the Local assigned at this Location as a used mutable local variable
9797
for moi in &self.mbcx.move_data.loc_map[location] {
9898
let mpi = &self.mbcx.move_data.moves[*moi].path;

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx,
143143
// now that we have moved to the "slice of projections" representation.
144144
if let mir::ProjectionElem::Index(local) = elem {
145145
self.visit_local(
146-
&local,
146+
local,
147147
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
148148
location,
149149
);
150150
}
151151
} else {
152-
self.visit_local(&place_ref.local, context, location);
152+
self.visit_local(place_ref.local, context, location);
153153
}
154154
}
155155
}
@@ -185,7 +185,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
185185
self.process_place(&place.as_ref(), context, location);
186186
}
187187

188-
fn visit_local(&mut self, &local: &mir::Local, context: PlaceContext, location: Location) {
188+
fn visit_local(&mut self, local: mir::Local, context: PlaceContext, location: Location) {
189189
match context {
190190
PlaceContext::MutatingUse(MutatingUseContext::Call)
191191
| PlaceContext::MutatingUse(MutatingUseContext::Yield) => {

compiler/rustc_const_eval/src/interpret/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
202202
let ptr = self.scalar_to_ptr(scalar)?;
203203
match ptr.into_pointer_or_addr() {
204204
Ok(ptr) => M::expose_ptr(self, ptr)?,
205-
Err(_) => {} // do nothing, exposing an invalid pointer has no meaning
205+
Err(_) => {} // Do nothing, exposing an invalid pointer (`None` provenance) is a NOP.
206206
};
207207
Ok(self.cast_from_int_like(scalar, src.layout, cast_ty)?.into())
208208
}

compiler/rustc_const_eval/src/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
244244
// for a generator).
245245
let var_hir_id = captured_place.get_root_variable();
246246
let node = self.ecx.tcx.hir().get(var_hir_id);
247-
if let hir::Node::Binding(pat) = node {
247+
if let hir::Node::Pat(pat) = node {
248248
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
249249
name = Some(ident.name);
250250
}

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
418418
PlaceContext::MutatingUse(MutatingUseContext::Borrow)
419419
}
420420
};
421-
self.visit_local(&reborrowed_place_ref.local, ctx, location);
421+
self.visit_local(reborrowed_place_ref.local, ctx, location);
422422
self.visit_projection(reborrowed_place_ref, ctx, location);
423423
return;
424424
}
@@ -431,7 +431,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
431431
}
432432
Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::AddressOf),
433433
};
434-
self.visit_local(&reborrowed_place_ref.local, ctx, location);
434+
self.visit_local(reborrowed_place_ref.local, ctx, location);
435435
self.visit_projection(reborrowed_place_ref, ctx, location);
436436
return;
437437
}

compiler/rustc_const_eval/src/transform/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct Collector<'a, 'tcx> {
106106
}
107107

108108
impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
109-
fn visit_local(&mut self, &index: &Local, context: PlaceContext, location: Location) {
109+
fn visit_local(&mut self, index: Local, context: PlaceContext, location: Location) {
110110
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
111111
// We're only interested in temporaries and the return place
112112
match self.ccx.body.local_kind(index) {

compiler/rustc_const_eval/src/transform/validate.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
196196
}
197197

198198
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
199-
fn visit_local(&mut self, local: &Local, context: PlaceContext, location: Location) {
200-
if self.body.local_decls.get(*local).is_none() {
199+
fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) {
200+
if self.body.local_decls.get(local).is_none() {
201201
self.fail(
202202
location,
203203
format!("local {:?} has no corresponding declaration in `body.local_decls`", local),
@@ -208,7 +208,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
208208
// Uses of locals must occur while the local's storage is allocated.
209209
self.storage_liveness.seek_after_primary_effect(location);
210210
let locals_with_storage = self.storage_liveness.get();
211-
if !locals_with_storage.contains(*local) {
211+
if !locals_with_storage.contains(local) {
212212
self.fail(location, format!("use of local {:?}, which has no storage here", local));
213213
}
214214
}
@@ -823,8 +823,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
823823
self.super_terminator(terminator, location);
824824
}
825825

826-
fn visit_source_scope(&mut self, scope: &SourceScope) {
827-
if self.body.source_scopes.get(*scope).is_none() {
826+
fn visit_source_scope(&mut self, scope: SourceScope) {
827+
if self.body.source_scopes.get(scope).is_none() {
828828
self.tcx.sess.diagnostic().delay_span_bug(
829829
self.body.span,
830830
&format!(

compiler/rustc_const_eval/src/util/collect_writes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ struct FindLocalAssignmentVisitor {
2424
}
2525

2626
impl<'tcx> Visitor<'tcx> for FindLocalAssignmentVisitor {
27-
fn visit_local(&mut self, local: &Local, place_context: PlaceContext, location: Location) {
28-
if self.needle != *local {
27+
fn visit_local(&mut self, local: Local, place_context: PlaceContext, location: Location) {
28+
if self.needle != local {
2929
return;
3030
}
3131

compiler/rustc_hir/src/hir.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,6 @@ pub enum Node<'hir> {
33263326
Ty(&'hir Ty<'hir>),
33273327
TypeBinding(&'hir TypeBinding<'hir>),
33283328
TraitRef(&'hir TraitRef<'hir>),
3329-
Binding(&'hir Pat<'hir>),
33303329
Pat(&'hir Pat<'hir>),
33313330
Arm(&'hir Arm<'hir>),
33323331
Block(&'hir Block<'hir>),
@@ -3378,7 +3377,6 @@ impl<'hir> Node<'hir> {
33783377
| Node::Block(..)
33793378
| Node::Ctor(..)
33803379
| Node::Pat(..)
3381-
| Node::Binding(..)
33823380
| Node::Arm(..)
33833381
| Node::Local(..)
33843382
| Node::Crate(..)

compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a> State<'a> {
8787
Node::Ty(a) => self.print_type(&a),
8888
Node::TypeBinding(a) => self.print_type_binding(&a),
8989
Node::TraitRef(a) => self.print_trait_ref(&a),
90-
Node::Binding(a) | Node::Pat(a) => self.print_pat(&a),
90+
Node::Pat(a) => self.print_pat(&a),
9191
Node::Arm(a) => self.print_arm(&a),
9292
Node::Infer(_) => self.word("_"),
9393
Node::Block(a) => {

compiler/rustc_middle/src/hir/map/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ impl<'hir> Map<'hir> {
302302
| Node::Infer(_)
303303
| Node::TraitRef(_)
304304
| Node::Pat(_)
305-
| Node::Binding(_)
306305
| Node::Local(_)
307306
| Node::Param(_)
308307
| Node::Arm(_)
@@ -901,7 +900,7 @@ impl<'hir> Map<'hir> {
901900
#[inline]
902901
fn opt_ident(self, id: HirId) -> Option<Ident> {
903902
match self.get(id) {
904-
Node::Binding(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
903+
Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
905904
// A `Ctor` doesn't have an identifier itself, but its parent
906905
// struct/variant does. Compare with `hir::Map::opt_span`.
907906
Node::Ctor(..) => match self.find(self.get_parent_node(id))? {
@@ -1046,7 +1045,6 @@ impl<'hir> Map<'hir> {
10461045
Node::Ty(ty) => ty.span,
10471046
Node::TypeBinding(tb) => tb.span,
10481047
Node::TraitRef(tr) => tr.path.span,
1049-
Node::Binding(pat) => pat.span,
10501048
Node::Pat(pat) => pat.span,
10511049
Node::Arm(arm) => arm.span,
10521050
Node::Block(block) => block.span,
@@ -1263,7 +1261,6 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
12631261
Some(Node::Ty(_)) => node_str("type"),
12641262
Some(Node::TypeBinding(_)) => node_str("type binding"),
12651263
Some(Node::TraitRef(_)) => node_str("trait ref"),
1266-
Some(Node::Binding(_)) => node_str("local"),
12671264
Some(Node::Pat(_)) => node_str("pat"),
12681265
Some(Node::Param(_)) => node_str("param"),
12691266
Some(Node::Arm(_)) => node_str("arm"),

0 commit comments

Comments
 (0)