Skip to content

Commit 189d206

Browse files
committed
Fix error after rebase
1 parent 22eaffe commit 189d206

File tree

6 files changed

+25
-39
lines changed

6 files changed

+25
-39
lines changed

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
165165

166166
block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields))
167167
}
168-
ExprKind::Closure { closure_id, substs, upvars, movability, fake_reads } => {
168+
ExprKind::Closure { closure_id, substs, upvars, movability, ref fake_reads } => {
169169
// Convert the closure fake reads, if any, from `ExprRef` to mir `Place`
170170
// and push the fake reads.
171171
// This must come before creating the operands. This is required in case
@@ -179,7 +179,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
179179
// match x { _ => () } // fake read of `x`
180180
// };
181181
// ```
182-
183182
// FIXME(RFC2229): Remove feature gate once diagnostics are improved
184183
if this.tcx.features().capture_disjoint_fields {
185184
for (thir_place, cause, hir_id) in fake_reads.into_iter() {
@@ -193,8 +192,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
193192
place_builder_resolved.into_place(this.tcx, this.typeck_results);
194193
this.cfg.push_fake_read(
195194
block,
196-
this.source_info(this.tcx.hir().span(hir_id)),
197-
cause,
195+
this.source_info(this.tcx.hir().span(*hir_id)),
196+
*cause,
198197
mir_place,
199198
);
200199
}

compiler/rustc_mir_build/src/build/matches/mod.rs

+12-19
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
9797
let scrutinee_place =
9898
unpack!(block = self.lower_scrutinee(block, scrutinee, scrutinee_span,));
9999

100-
let mut arm_candidates =
101-
self.create_match_candidates(scrutinee_place.clone(), &arms.clone());
100+
let mut arm_candidates = self.create_match_candidates(scrutinee_place.clone(), &arms);
102101

103102
let match_has_guard = arms.iter().any(|arm| arm.guard.is_some());
104103
let mut candidates =
@@ -244,8 +243,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
244243
let arm_source_info = self.source_info(arm.span);
245244
let arm_scope = (arm.scope, arm_source_info);
246245
self.in_scope(arm_scope, arm.lint_level, |this| {
247-
let body = arm.body;
248-
249246
// `try_upvars_resolved` may fail if it is unable to resolve the given
250247
// `PlaceBuilder` inside a closure. In this case, we don't want to include
251248
// a scrutinee place. `scrutinee_place_builder` will fail to be resolved
@@ -264,7 +261,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
264261
.try_upvars_resolved(this.tcx, this.typeck_results)
265262
{
266263
scrutinee_place =
267-
scrutinee_builder.clone().into_place(this.tcx, this.typeck_results);
264+
scrutinee_builder.into_place(this.tcx, this.typeck_results);
268265
opt_scrutinee_place = Some((Some(&scrutinee_place), scrutinee_span));
269266
}
270267
let scope = this.declare_bindings(
@@ -524,9 +521,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
524521
if let Ok(match_pair_resolved) =
525522
initializer.clone().try_upvars_resolved(self.tcx, self.typeck_results)
526523
{
527-
let place = match_pair_resolved
528-
.clone()
529-
.into_place(self.tcx, self.typeck_results);
524+
let place =
525+
match_pair_resolved.into_place(self.tcx, self.typeck_results);
530526
*match_place = Some(place);
531527
}
532528
} else {
@@ -1480,7 +1476,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14801476
}
14811477
TestKind::Switch { adt_def: _, ref mut variants } => {
14821478
for candidate in candidates.iter() {
1483-
if !self.add_variants_to_switch(&match_place.clone(), candidate, variants) {
1479+
if !self.add_variants_to_switch(&match_place, candidate, variants) {
14841480
break;
14851481
}
14861482
}
@@ -1493,8 +1489,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14931489
if let Ok(match_place_resolved) =
14941490
match_place.clone().try_upvars_resolved(self.tcx, self.typeck_results)
14951491
{
1496-
let resolved_place =
1497-
match_place_resolved.clone().into_place(self.tcx, self.typeck_results);
1492+
let resolved_place = match_place_resolved.into_place(self.tcx, self.typeck_results);
14981493
fb.insert(resolved_place);
14991494
}
15001495
}
@@ -1577,7 +1572,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
15771572
target_blocks
15781573
};
15791574

1580-
self.perform_test(block, match_place.clone(), &test, make_target_blocks);
1575+
self.perform_test(block, match_place, &test, make_target_blocks);
15811576
}
15821577

15831578
/// Determine the fake borrows that are needed from a set of places that
@@ -1811,9 +1806,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18111806
}
18121807
Guard::IfLet(pat, scrutinee) => {
18131808
let scrutinee_span = scrutinee.span;
1814-
let scrutinee_place_builder = unpack!(
1815-
block = self.lower_scrutinee(block, scrutinee.clone(), scrutinee_span)
1816-
);
1809+
let scrutinee_place_builder =
1810+
unpack!(block = self.lower_scrutinee(block, scrutinee, scrutinee_span));
18171811
let mut guard_candidate =
18181812
Candidate::new(scrutinee_place_builder.clone(), &pat, false);
18191813
let wildcard = Pat::wildcard_from_ty(pat.ty);
@@ -1827,12 +1821,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
18271821
);
18281822
let mut opt_scrutinee_place: Option<(Option<&Place<'tcx>>, Span)> = None;
18291823
let scrutinee_place: Place<'tcx>;
1830-
if let Ok(scrutinee_builder) = scrutinee_place_builder
1831-
.clone()
1832-
.try_upvars_resolved(self.tcx, self.typeck_results)
1824+
if let Ok(scrutinee_builder) =
1825+
scrutinee_place_builder.try_upvars_resolved(self.tcx, self.typeck_results)
18331826
{
18341827
scrutinee_place =
1835-
scrutinee_builder.clone().into_place(self.tcx, self.typeck_results);
1828+
scrutinee_builder.into_place(self.tcx, self.typeck_results);
18361829
opt_scrutinee_place = Some((Some(&scrutinee_place), scrutinee_span));
18371830
}
18381831
self.declare_bindings(

compiler/rustc_mir_build/src/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
158158
) {
159159
let place: Place<'tcx>;
160160
if let Ok(test_place_builder) =
161-
place_builder.clone().try_upvars_resolved(self.tcx, self.typeck_results)
161+
place_builder.try_upvars_resolved(self.tcx, self.typeck_results)
162162
{
163163
place = test_place_builder.into_place(self.tcx, self.typeck_results);
164164
} else {

compiler/rustc_mir_build/src/thir/cx/expr.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -455,28 +455,19 @@ impl<'thir, 'tcx> Cx<'thir, 'tcx> {
455455
);
456456

457457
// Convert the closure fake reads, if any, from hir `Place` to ExprRef
458-
let fake_reads = match self.typeck_results().closure_fake_reads.get(&def_id) {
458+
let fake_reads = match self.typeck_results.closure_fake_reads.get(&def_id) {
459459
Some(fake_reads) => fake_reads
460460
.iter()
461461
.map(|(place, cause, hir_id)| {
462-
(
463-
self.arena
464-
.alloc(self.convert_captured_hir_place(expr, place.clone())),
465-
*cause,
466-
*hir_id,
467-
)
462+
let expr = self.convert_captured_hir_place(expr, place.clone());
463+
let expr_ref: &'thir Expr<'thir, 'tcx> = self.arena.alloc(expr);
464+
(expr_ref, *cause, *hir_id)
468465
})
469466
.collect(),
470467
None => Vec::new(),
471468
};
472469

473-
ExprKind::Closure {
474-
closure_id: def_id,
475-
substs,
476-
upvars,
477-
movability,
478-
fake_reads: fake_reads,
479-
}
470+
ExprKind::Closure { closure_id: def_id, substs, upvars, movability, fake_reads }
480471
}
481472

482473
hir::ExprKind::Path(ref qpath) => {

compiler/rustc_mir_build/src/thir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ pub enum ExprKind<'thir, 'tcx> {
281281
substs: UpvarSubsts<'tcx>,
282282
upvars: &'thir [Expr<'thir, 'tcx>],
283283
movability: Option<hir::Movability>,
284-
fake_reads: Vec<(&'thir mut Expr<'thir, 'tcx>, FakeReadCause, hir::HirId)>,
284+
fake_reads: Vec<(&'thir Expr<'thir, 'tcx>, FakeReadCause, hir::HirId)>,
285285
},
286286
Literal {
287287
literal: &'tcx Const<'tcx>,

src/tools/clippy/clippy_lints/src/loops/mut_range_bound.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use if_chain::if_chain;
44
use rustc_hir::{BindingAnnotation, Expr, HirId, Node, PatKind};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::LateContext;
7+
use rustc_middle::mir::FakeReadCause;
78
use rustc_middle::ty;
89
use rustc_span::source_map::Span;
910
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
@@ -106,6 +107,8 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
106107
}
107108
}
108109
}
110+
111+
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _:HirId) { }
109112
}
110113

111114
impl MutatePairDelegate<'_, '_> {

0 commit comments

Comments
 (0)