Skip to content

Commit 6ff727b

Browse files
committed
Bubble up the defining_use_anchor from fully_perform
1 parent 2a39fb2 commit 6ff727b

File tree

7 files changed

+38
-15
lines changed

7 files changed

+38
-15
lines changed

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
3737
{
3838
let old_universe = self.infcx.universe();
3939

40-
let TypeOpOutput { output, constraints, error_info } = op.fully_perform(self.infcx)?;
40+
let TypeOpOutput { output, constraints, error_info } =
41+
op.fully_perform(self.infcx, self.defining_use_anchor)?;
4142

4243
debug!(?output, ?constraints);
4344

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
268268
let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = self
269269
.param_env
270270
.and(type_op::normalize::Normalize::new(ty))
271-
.fully_perform(self.infcx)
271+
.fully_perform(self.infcx, rustc_infer::infer::DefiningAnchor::Error)
272272
.unwrap_or_else(|_| {
273273
let guar = self
274274
.infcx
@@ -349,7 +349,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
349349
let TypeOpOutput { output: bounds, constraints, .. } = self
350350
.param_env
351351
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
352-
.fully_perform(self.infcx)
352+
.fully_perform(self.infcx, rustc_infer::infer::DefiningAnchor::Error)
353353
.unwrap_or_else(|_| bug!("failed to compute implied bounds {:?}", ty));
354354
debug!(?bounds, ?constraints);
355355
self.add_outlives_bounds(bounds);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,10 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
570570
debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,);
571571

572572
let param_env = typeck.param_env;
573-
let TypeOpOutput { output, constraints, .. } =
574-
param_env.and(DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx).unwrap();
573+
let TypeOpOutput { output, constraints, .. } = param_env
574+
.and(DropckOutlives::new(dropped_ty))
575+
.fully_perform(typeck.infcx, typeck.defining_use_anchor)
576+
.unwrap();
575577

576578
DropData { dropck_result: output, region_constraint_data: constraints }
577579
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,10 +2720,15 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
27202720
/// constraints in our `InferCtxt`
27212721
type ErrorInfo = InstantiateOpaqueType<'tcx>;
27222722

2723-
fn fully_perform(mut self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
2724-
let (mut output, region_constraints) = scrape_region_constraints(infcx, || {
2725-
Ok(InferOk { value: (), obligations: self.obligations.clone() })
2726-
})?;
2723+
fn fully_perform(
2724+
mut self,
2725+
infcx: &InferCtxt<'tcx>,
2726+
defining_use_anchor: DefiningAnchor,
2727+
) -> Fallible<TypeOpOutput<'tcx, Self>> {
2728+
let (mut output, region_constraints) =
2729+
scrape_region_constraints(infcx, defining_use_anchor, || {
2730+
Ok(InferOk { value: (), obligations: self.obligations.clone() })
2731+
})?;
27272732
self.region_constraints = Some(region_constraints);
27282733
output.error_info = Some(self);
27292734
Ok(output)

compiler/rustc_trait_selection/src/traits/outlives_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
5555
let span = self.tcx.def_span(body_id);
5656
let result = param_env
5757
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
58-
.fully_perform(self);
58+
.fully_perform(self, rustc_infer::infer::DefiningAnchor::Error);
5959
let result = match result {
6060
Ok(r) => r,
6161
Err(NoSolution) => {

compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::traits;
44
use crate::traits::query::type_op::TypeOpOutput;
55
use crate::traits::query::Fallible;
66
use rustc_infer::infer::region_constraints::RegionConstraintData;
7+
use rustc_infer::infer::DefiningAnchor;
78
use rustc_span::source_map::DUMMY_SP;
89

910
use std::fmt;
@@ -36,12 +37,16 @@ where
3637
/// Processes the operation and all resulting obligations,
3738
/// returning the final result along with any region constraints
3839
/// (they will be given over to the NLL region solver).
39-
fn fully_perform(self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
40+
fn fully_perform(
41+
self,
42+
infcx: &InferCtxt<'tcx>,
43+
defining_use_anchor: DefiningAnchor,
44+
) -> Fallible<TypeOpOutput<'tcx, Self>> {
4045
if cfg!(debug_assertions) {
4146
info!("fully_perform({:?})", self);
4247
}
4348

44-
Ok(scrape_region_constraints(infcx, || (self.closure)(infcx))?.0)
49+
Ok(scrape_region_constraints(infcx, defining_use_anchor, || (self.closure)(infcx))?.0)
4550
}
4651
}
4752

@@ -58,6 +63,7 @@ where
5863
/// constraints that result, creating query-region-constraints.
5964
pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
6065
infcx: &InferCtxt<'tcx>,
66+
defining_use_anchor: DefiningAnchor,
6167
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
6268
) -> Fallible<(TypeOpOutput<'tcx, Op>, RegionConstraintData<'tcx>)> {
6369
// During NLL, we expect that nobody will register region
@@ -73,7 +79,7 @@ pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
7379
);
7480

7581
let InferOk { value, obligations } = infcx.commit_if_ok(|_| op())?;
76-
let errors = traits::fully_solve_obligations(infcx, obligations, infcx.old_defining_use_anchor);
82+
let errors = traits::fully_solve_obligations(infcx, obligations, defining_use_anchor);
7783
if !errors.is_empty() {
7884
infcx.tcx.sess.diagnostic().delay_span_bug(
7985
DUMMY_SP,

compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::infer::{InferCtxt, InferOk};
55
use crate::traits::query::Fallible;
66
use crate::traits::ObligationCause;
77
use rustc_infer::infer::canonical::Certainty;
8+
use rustc_infer::infer::DefiningAnchor;
89
use rustc_infer::traits::query::NoSolution;
910
use rustc_infer::traits::PredicateObligations;
1011
use rustc_middle::ty::fold::TypeFoldable;
@@ -32,7 +33,11 @@ pub trait TypeOp<'tcx>: Sized + fmt::Debug {
3233
/// Processes the operation and all resulting obligations,
3334
/// returning the final result along with any region constraints
3435
/// (they will be given over to the NLL region solver).
35-
fn fully_perform(self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>>;
36+
fn fully_perform(
37+
self,
38+
infcx: &InferCtxt<'tcx>,
39+
defining_use_anchor: DefiningAnchor,
40+
) -> Fallible<TypeOpOutput<'tcx, Self>>;
3641
}
3742

3843
/// The output from performing a type op
@@ -120,7 +125,11 @@ where
120125
type Output = Q::QueryResponse;
121126
type ErrorInfo = Canonical<'tcx, ParamEnvAnd<'tcx, Q>>;
122127

123-
fn fully_perform(self, infcx: &InferCtxt<'tcx>) -> Fallible<TypeOpOutput<'tcx, Self>> {
128+
fn fully_perform(
129+
self,
130+
infcx: &InferCtxt<'tcx>,
131+
_defining_use_anchor: DefiningAnchor,
132+
) -> Fallible<TypeOpOutput<'tcx, Self>> {
124133
let mut region_constraints = QueryRegionConstraints::default();
125134
let (output, error_info, mut obligations, _) =
126135
Q::fully_perform_into(self, infcx, &mut region_constraints)?;

0 commit comments

Comments
 (0)