Skip to content

Commit 35c9ddf

Browse files
committed
Remove some duplicating self.infcx.tcx
1 parent 2ed5f25 commit 35c9ddf

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
6666
location, desired_action, moved_place, used_place, span, mpi
6767
);
6868

69+
let tcx = self.infcx.tcx;
6970
let use_spans =
7071
self.move_spans(moved_place, location).or_else(|| self.borrow_spans(span, location));
7172
let span = use_spans.args_or_use();
@@ -243,11 +244,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
243244
);
244245
}
245246

246-
let ty = used_place.ty(self.body, self.infcx.tcx).ty;
247+
let ty = used_place.ty(self.body, tcx).ty;
247248
let needs_note = match ty.kind() {
248249
ty::Closure(id, _) => {
249-
let tables = self.infcx.tcx.typeck(id.expect_local());
250-
let hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(id.expect_local());
250+
let tables = tcx.typeck(id.expect_local());
251+
let hir_id = tcx.hir().local_def_id_to_hir_id(id.expect_local());
251252

252253
tables.closure_kind_origins().get(hir_id).is_none()
253254
}
@@ -256,7 +257,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
256257

257258
let mpi = self.move_data.moves[move_out_indices[0]].path;
258259
let place = &self.move_data.move_paths[mpi].place;
259-
let ty = place.ty(self.body, self.infcx.tcx).ty;
260+
let ty = place.ty(self.body, tcx).ty;
260261

261262
// If we're in pattern, we do nothing in favor of the previous suggestion (#80913).
262263
if is_loop_move & !in_pattern {
@@ -285,7 +286,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
285286
};
286287

287288
// Try to find predicates on *generic params* that would allow copying `ty`
288-
let tcx = self.infcx.tcx;
289289
let generics = tcx.generics_of(self.mir_def_id());
290290
if let Some(hir_generics) = tcx
291291
.typeck_root_def_id(self.mir_def_id().to_def_id())
@@ -329,7 +329,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
329329
));
330330

331331
// Check first whether the source is accessible (issue #87060)
332-
if self.infcx.tcx.sess.source_map().span_to_snippet(deref_target).is_ok() {
332+
if tcx.sess.source_map().span_to_snippet(deref_target).is_ok() {
333333
err.span_note(deref_target, "deref defined here");
334334
}
335335
}
@@ -1012,6 +1012,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10121012
location, name, borrow, drop_span, borrow_spans
10131013
);
10141014

1015+
let tcx = self.infcx.tcx;
10151016
let borrow_span = borrow_spans.var_or_use_path_span();
10161017
if let BorrowExplanation::MustBeValidFor {
10171018
category,
@@ -1048,19 +1049,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10481049
format!(
10491050
"...but `{}` will be dropped here, when the {} returns",
10501051
name,
1051-
self.infcx
1052-
.tcx
1053-
.hir()
1052+
tcx.hir()
10541053
.opt_name(fn_hir_id)
10551054
.map(|name| format!("function `{}`", name))
10561055
.unwrap_or_else(|| {
1057-
match &self
1058-
.infcx
1059-
.tcx
1060-
.typeck(self.mir_def_id())
1061-
.node_type(fn_hir_id)
1062-
.kind()
1063-
{
1056+
match &tcx.typeck(self.mir_def_id()).node_type(fn_hir_id).kind() {
10641057
ty::Closure(..) => "enclosing closure",
10651058
ty::Generator(..) => "enclosing generator",
10661059
kind => bug!("expected closure or generator, found {:?}", kind),
@@ -1082,7 +1075,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10821075
if let BorrowExplanation::MustBeValidFor { .. } = explanation {
10831076
} else {
10841077
explanation.add_explanation_to_diagnostic(
1085-
self.infcx.tcx,
1078+
tcx,
10861079
&self.body,
10871080
&self.local_names,
10881081
&mut err,
@@ -1100,7 +1093,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11001093
borrow_spans.args_span_label(&mut err, format!("value captured here{}", within));
11011094

11021095
explanation.add_explanation_to_diagnostic(
1103-
self.infcx.tcx,
1096+
tcx,
11041097
&self.body,
11051098
&self.local_names,
11061099
&mut err,

0 commit comments

Comments
 (0)