Skip to content

Commit 8c66d6d

Browse files
committed
Remove unused field
1 parent 32f6878 commit 8c66d6d

File tree

5 files changed

+24
-75
lines changed

5 files changed

+24
-75
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ impl<'tcx> InferCtxt<'tcx> {
9191
var_values: inference_vars,
9292
region_constraints: QueryRegionConstraints::default(),
9393
certainty: Certainty::Proven, // Ambiguities are OK!
94-
opaque_types: vec![],
9594
value: answer,
9695
})
9796
}
@@ -140,28 +139,14 @@ impl<'tcx> InferCtxt<'tcx> {
140139
let certainty =
141140
if ambig_errors.is_empty() { Certainty::Proven } else { Certainty::Ambiguous };
142141

143-
let opaque_types = self.take_opaque_types_for_query_response();
144-
145142
Ok(QueryResponse {
146143
var_values: inference_vars,
147144
region_constraints,
148145
certainty,
149146
value: answer,
150-
opaque_types,
151147
})
152148
}
153149

154-
/// FIXME: This method should only be used for canonical queries and therefore be private.
155-
///
156-
/// As the new solver does canonicalization slightly differently, this is also used there
157-
/// for now. This should hopefully change fairly soon.
158-
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
159-
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
160-
.into_iter()
161-
.map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
162-
.collect()
163-
}
164-
165150
/// Given the (canonicalized) result to a canonical query,
166151
/// instantiates the result so it can be used, plugging in the
167152
/// values from the canonical query. (Note that the result may
@@ -244,8 +229,8 @@ impl<'tcx> InferCtxt<'tcx> {
244229
where
245230
R: Debug + TypeFoldable<'tcx>,
246231
{
247-
let InferOk { value: result_subst, mut obligations } = self
248-
.query_response_substitution_guess(cause, param_env, original_values, query_response)?;
232+
let InferOk { value: result_subst, mut obligations } =
233+
self.query_response_substitution_guess(cause, original_values, query_response)?;
249234

250235
// Compute `QueryOutlivesConstraint` values that unify each of
251236
// the original values `v_o` that was canonicalized into a
@@ -363,12 +348,8 @@ impl<'tcx> InferCtxt<'tcx> {
363348
original_values, query_response,
364349
);
365350

366-
let mut value = self.query_response_substitution_guess(
367-
cause,
368-
param_env,
369-
original_values,
370-
query_response,
371-
)?;
351+
let mut value =
352+
self.query_response_substitution_guess(cause, original_values, query_response)?;
372353

373354
value.obligations.extend(
374355
self.unify_query_response_substitution_guess(
@@ -396,7 +377,6 @@ impl<'tcx> InferCtxt<'tcx> {
396377
fn query_response_substitution_guess<R>(
397378
&self,
398379
cause: &ObligationCause<'tcx>,
399-
param_env: ty::ParamEnv<'tcx>,
400380
original_values: &OriginalQueryValues<'tcx>,
401381
query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
402382
) -> InferResult<'tcx, CanonicalVarValues<'tcx>>
@@ -496,16 +476,7 @@ impl<'tcx> InferCtxt<'tcx> {
496476
)),
497477
};
498478

499-
let mut obligations = vec![];
500-
501-
// Carry all newly resolved opaque types to the caller's scope
502-
for &(a, b) in &query_response.value.opaque_types {
503-
let a = substitute_value(self.tcx, &result_subst, a);
504-
let b = substitute_value(self.tcx, &result_subst, b);
505-
obligations.extend(self.at(cause, param_env).eq(a, b)?.obligations);
506-
}
507-
508-
Ok(InferOk { value: result_subst, obligations })
479+
Ok(InferOk { value: result_subst, obligations: vec![] })
509480
}
510481

511482
/// Given a "guess" at the values for the canonical variables in

compiler/rustc_middle/src/infer/canonical.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ pub struct QueryResponse<'tcx, R> {
204204
pub var_values: CanonicalVarValues<'tcx>,
205205
pub region_constraints: QueryRegionConstraints<'tcx>,
206206
pub certainty: Certainty,
207-
/// List of opaque types which we tried to compare to another type.
208-
/// Inside the query we don't know yet whether the opaque type actually
209-
/// should get its hidden type inferred. So we bubble the opaque type
210-
/// and the type it was compared against upwards and let the query caller
211-
/// handle it.
212-
pub opaque_types: Vec<(Ty<'tcx>, Ty<'tcx>)>,
213207
pub value: R,
214208
}
215209

compiler/rustc_middle/src/traits/solve.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_data_structures::intern::Interned;
44

55
use crate::ty::{
66
ir::{self, TypeFoldable, TypeVisitable},
7-
FallibleTypeFolder, Ty, TyCtxt, TypeFolder, TypeVisitor,
7+
FallibleTypeFolder, TyCtxt, TypeFolder, TypeVisitor,
88
};
99

1010
#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)]
@@ -19,32 +19,27 @@ impl<'tcx> std::ops::Deref for ExternalConstraints<'tcx> {
1919
}
2020

2121
/// Additional constraints returned on success.
22-
#[derive(Debug, PartialEq, Eq, Clone, Hash, Default)]
22+
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
2323
pub struct ExternalConstraintsData<'tcx> {
2424
// FIXME: implement this.
25-
pub regions: (),
26-
pub opaque_types: Vec<(Ty<'tcx>, Ty<'tcx>)>,
25+
pub regions: &'tcx (),
26+
}
27+
28+
impl<'tcx> Default for ExternalConstraintsData<'tcx> {
29+
fn default() -> Self {
30+
Self { regions: &() }
31+
}
2732
}
2833

2934
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
3035
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
31-
Ok(ir::FallibleTypeFolder::interner(folder).intern_external_constraints(
32-
ExternalConstraintsData {
33-
regions: (),
34-
opaque_types: self
35-
.opaque_types
36-
.iter()
37-
.map(|opaque| opaque.try_fold_with(folder))
38-
.collect::<Result<_, F::Error>>()?,
39-
},
40-
))
36+
Ok(ir::FallibleTypeFolder::interner(folder)
37+
.intern_external_constraints(ExternalConstraintsData { regions: &() }))
4138
}
4239

4340
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
44-
ir::TypeFolder::interner(folder).intern_external_constraints(ExternalConstraintsData {
45-
regions: (),
46-
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
47-
})
41+
ir::TypeFolder::interner(folder)
42+
.intern_external_constraints(ExternalConstraintsData { regions: &() })
4843
}
4944
}
5045

@@ -54,7 +49,6 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
5449
visitor: &mut V,
5550
) -> std::ops::ControlFlow<V::BreakTy> {
5651
self.regions.visit_with(visitor)?;
57-
self.opaque_types.visit_with(visitor)?;
5852
ControlFlow::Continue(())
5953
}
6054
}

compiler/rustc_trait_selection/src/solve/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ impl<'tcx> CanonicalResponseExt for Canonical<'tcx, Response<'tcx>> {
9292
fn has_no_inference_or_external_constraints(&self) -> bool {
9393
// so that we get a compile error when regions are supported
9494
// so this code can be checked for being correct
95-
let _: () = self.value.external_constraints.regions;
95+
let _: &() = self.value.external_constraints.regions;
9696

9797
self.value.var_values.is_identity()
98-
&& self.value.external_constraints.opaque_types.is_empty()
9998
}
10099
}
101100

@@ -582,14 +581,11 @@ fn compute_external_query_constraints<'tcx>(
582581
infcx: &InferCtxt<'tcx>,
583582
) -> Result<ExternalConstraints<'tcx>, NoSolution> {
584583
let region_obligations = infcx.take_registered_region_obligations();
585-
let opaque_types = infcx.take_opaque_types_for_query_response();
586-
Ok(infcx.tcx.intern_external_constraints(ExternalConstraintsData {
587-
// FIXME: Now that's definitely wrong :)
588-
//
589-
// Should also do the leak check here I think
590-
regions: drop(region_obligations),
591-
opaque_types,
592-
}))
584+
// FIXME: Now that's definitely wrong :)
585+
//
586+
// Should also do the leak check here I think
587+
drop(region_obligations);
588+
Ok(infcx.tcx.intern_external_constraints(ExternalConstraintsData { regions: &() }))
593589
}
594590

595591
fn instantiate_canonical_query_response<'tcx>(
@@ -609,10 +605,6 @@ fn instantiate_canonical_query_response<'tcx>(
609605
Certainty::Yes => OldCertainty::Proven,
610606
Certainty::Maybe(_) => OldCertainty::Ambiguous,
611607
},
612-
// FIXME: This to_owned makes me sad, but we should eventually impl
613-
// `instantiate_query_response_and_region_obligations` separately
614-
// instead of piggybacking off of the old implementation.
615-
opaque_types: resp.external_constraints.opaque_types.to_owned(),
616608
value: resp.certainty,
617609
}),
618610
) else { bug!(); };

compiler/rustc_traits/src/chalk/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ pub(crate) fn evaluate_goal<'tcx>(
131131
var_values: CanonicalVarValues { var_values },
132132
region_constraints: QueryRegionConstraints::default(),
133133
certainty: Certainty::Proven,
134-
opaque_types: vec![],
135134
value: (),
136135
},
137136
};
@@ -159,7 +158,6 @@ pub(crate) fn evaluate_goal<'tcx>(
159158
var_values: CanonicalVarValues::dummy(),
160159
region_constraints: QueryRegionConstraints::default(),
161160
certainty: Certainty::Ambiguous,
162-
opaque_types: vec![],
163161
value: (),
164162
},
165163
};

0 commit comments

Comments
 (0)