Skip to content

Commit 4767f23

Browse files
committed
remove normalize_capture_place
1 parent c50bbc2 commit 4767f23

1 file changed

Lines changed: 5 additions & 46 deletions

File tree

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ use rustc_middle::ty::{
4949
use rustc_middle::{bug, span_bug};
5050
use rustc_session::lint;
5151
use rustc_span::{BytePos, Pos, Span, Symbol, sym};
52-
use rustc_trait_selection::error_reporting::InferCtxtErrorExt as _;
5352
use rustc_trait_selection::infer::InferCtxtExt;
54-
use rustc_trait_selection::solve;
5553
use tracing::{debug, instrument};
5654

5755
use super::FnCtxt;
@@ -1172,45 +1170,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11721170
);
11731171
}
11741172
}
1175-
fn normalize_capture_place(&self, span: Span, place: Place<'tcx>) -> Place<'tcx> {
1176-
let mut place = self.resolve_vars_if_possible(place);
1177-
1178-
// In the new solver, types in HIR `Place`s can contain unnormalized aliases,
1179-
// which can ICE later (e.g. when projecting fields for diagnostics).
1180-
if self.next_trait_solver() {
1181-
let cause = self.misc(span);
1182-
let at = self.at(&cause, self.param_env);
1183-
match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(
1184-
at,
1185-
Unnormalized::new_wip(place.clone()),
1186-
vec![],
1187-
) {
1188-
Ok((normalized, goals)) => {
1189-
if !goals.is_empty() {
1190-
let mut typeck_results = self.typeck_results.borrow_mut();
1191-
typeck_results.coroutine_stalled_predicates.extend(
1192-
goals
1193-
.into_iter()
1194-
// FIXME: throwing away the param-env :(
1195-
.map(|goal| (goal.predicate, self.misc(span))),
1196-
);
1197-
}
1198-
normalized
1199-
}
1200-
Err(errors) => {
1201-
let guar = self.infcx.err_ctxt().report_fulfillment_errors(errors);
1202-
place.base_ty = Ty::new_error(self.tcx, guar);
1203-
for proj in &mut place.projections {
1204-
proj.ty = Ty::new_error(self.tcx, guar);
1205-
}
1206-
place
1207-
}
1208-
}
1209-
} else {
1210-
// For the old solver we can rely on `normalize` to eagerly normalize aliases.
1211-
self.normalize(span, Unnormalized::new_wip(place))
1212-
}
1213-
}
12141173

12151174
/// Combines all the reasons for 2229 migrations
12161175
fn compute_2229_migrations_reasons(
@@ -1828,7 +1787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18281787

18291788
// Normalize eagerly when inserting into `capture_information`, so all downstream
18301789
// capture analysis can assume a normalized `Place`.
1831-
self.normalize_capture_place(self.tcx.hir_span(var_hir_id), place)
1790+
self.normalize(self.tcx.hir_span(var_hir_id), Unnormalized::new_wip(place))
18321791
}
18331792

18341793
fn should_log_capture_analysis(&self, closure_def_id: LocalDefId) -> bool {
@@ -2134,7 +2093,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
21342093
let dummy_capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable);
21352094

21362095
let span = self.fcx.tcx.hir_span(diag_expr_id);
2137-
let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone());
2096+
let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone()));
21382097

21392098
let (place, _) = restrict_capture_precision(place, dummy_capture_kind);
21402099

@@ -2148,7 +2107,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
21482107
assert_eq!(self.closure_def_id, upvar_id.closure_expr_id);
21492108

21502109
let span = self.fcx.tcx.hir_span(diag_expr_id);
2151-
let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone());
2110+
let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone()));
21522111

21532112
self.capture_information.push((
21542113
place,
@@ -2166,7 +2125,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
21662125
assert_eq!(self.closure_def_id, upvar_id.closure_expr_id);
21672126

21682127
let span = self.fcx.tcx.hir_span(diag_expr_id);
2169-
let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone());
2128+
let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone()));
21702129

21712130
self.capture_information.push((
21722131
place,
@@ -2192,7 +2151,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
21922151
let capture_kind = ty::UpvarCapture::ByRef(bk);
21932152

21942153
let span = self.fcx.tcx.hir_span(diag_expr_id);
2195-
let place = self.fcx.normalize_capture_place(span, place_with_id.place.clone());
2154+
let place = self.fcx.normalize(span, Unnormalized::new_wip(place_with_id.place.clone()));
21962155

21972156
// We only want repr packed restriction to be applied to reading references into a packed
21982157
// struct, and not when the data is being moved. Therefore we call this method here instead

0 commit comments

Comments
 (0)