Skip to content

Commit d2589c4

Browse files
committed
avoid some unnecessary interning
1 parent 19163b9 commit d2589c4

3 files changed

Lines changed: 20 additions & 26 deletions

File tree

‎compiler/rustc_next_trait_solver/src/canonical/canonicalizer.rs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,34 +261,33 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
261261
/// variable in the future by changing the way we detect global where-bounds.
262262
pub(super) fn canonicalize_input<P: TypeFoldable<I>>(
263263
delegate: &'a D,
264-
input: QueryInput<I, P>,
264+
Goal { param_env, predicate }: Goal<I, P>,
265+
predefined_opaques_in_body: Vec<(ty::OpaqueTypeKey<I>, I::Ty)>,
266+
pseudo_rigid_due_to_opaques: Vec<(I::Ty, ty::PseudoRigidDueToOpaquesBound<I>)>,
265267
) -> (ThinVec<I::GenericArg>, ty::Canonical<I, QueryInput<I, P>>) {
266268
// First canonicalize the `param_env` while keeping `'static`. This produces a
267269
// canonicalizer that can canonicalize the rest of the input without keeping `'static`.
268-
let (param_env, mut rest_canonicalizer) =
269-
Self::canonicalize_param_env(delegate, input.goal.param_env);
270+
let (param_env, mut rest_canonicalizer) = Self::canonicalize_param_env(delegate, param_env);
270271

271-
let predicate = input.goal.predicate;
272272
let predicate = predicate.fold_with(&mut rest_canonicalizer);
273273
let goal = Goal { param_env, predicate };
274274

275-
let predefined_opaques_in_body = input.predefined_opaques_in_body;
276275
let predefined_opaques_in_body =
277276
if predefined_opaques_in_body.has_type_flags(NEEDS_CANONICAL) {
278277
predefined_opaques_in_body.fold_with(&mut rest_canonicalizer)
279278
} else {
280279
predefined_opaques_in_body
281280
};
281+
let predefined_opaques_in_body =
282+
delegate.cx().mk_predefined_opaques_in_body(&predefined_opaques_in_body);
282283

283284
let pseudo_rigid_due_to_opaques = rest_canonicalizer
284-
.filter_and_canonicalize_pseudo_rigids_due_to_opaques(
285-
input.pseudo_rigid_due_to_opaques.to_vec(),
286-
);
285+
.filter_and_canonicalize_pseudo_rigids_due_to_opaques(pseudo_rigid_due_to_opaques);
287286

288287
let value = QueryInput { goal, predefined_opaques_in_body, pseudo_rigid_due_to_opaques };
289-
290288
debug_assert!(!value.has_infer(), "unexpected infer in {value:?}");
291289
debug_assert!(!value.has_placeholders(), "unexpected placeholders in {value:?}");
290+
292291
let (max_universe, variables, var_kinds) = rest_canonicalizer.finalize();
293292
(variables, Canonical { max_universe, var_kinds, value })
294293
}

‎compiler/rustc_next_trait_solver/src/canonical/mod.rs‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ use tracing::instrument;
2727
use crate::delegate::SolverDelegate;
2828
use crate::solve::{
2929
CanonicalResponse, Certainty, ExternalConstraintsData, ExternalRegionConstraints, Goal,
30-
NestedNormalizationGoals, QueryInput, RawExternalConstraintsData, Response,
31-
VisibleForLeakCheck, inspect,
30+
NestedNormalizationGoals, RawExternalConstraintsData, Response, VisibleForLeakCheck, inspect,
3231
};
3332

3433
pub mod canonicalizer;
@@ -56,8 +55,8 @@ impl<I: Interner, T> ResponseT<I> for inspect::State<I, T> {
5655
pub(super) fn canonicalize_goal<D, I>(
5756
delegate: &D,
5857
goal: Goal<I, I::Predicate>,
59-
opaque_types: &[(ty::OpaqueTypeKey<I>, I::Ty)],
60-
pseudo_rigid_due_to_opaques: &[(I::Ty, ty::PseudoRigidDueToOpaquesBound<I>)],
58+
opaque_types: Vec<(ty::OpaqueTypeKey<I>, I::Ty)>,
59+
pseudo_rigid_due_to_opaques: Vec<(I::Ty, ty::PseudoRigidDueToOpaquesBound<I>)>,
6160
typing_mode: TypingMode<I>,
6261
) -> (ThinVec<I::GenericArg>, I::CanonicalInput)
6362
where
@@ -66,13 +65,9 @@ where
6665
{
6766
let (orig_values, canonical) = Canonicalizer::canonicalize_input(
6867
delegate,
69-
QueryInput {
70-
goal,
71-
predefined_opaques_in_body: delegate.cx().mk_predefined_opaques_in_body(opaque_types),
72-
pseudo_rigid_due_to_opaques: delegate
73-
.cx()
74-
.mk_pseudo_rigid_due_to_opaques(pseudo_rigid_due_to_opaques),
75-
},
68+
goal,
69+
opaque_types,
70+
pseudo_rigid_due_to_opaques,
7671
);
7772

7873
let query_input = delegate.cx().mk_canonical_input(ty::CanonicalQueryInput {

‎compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,8 @@ where
844844
let (orig_values, canonical_goal) = canonicalize_goal(
845845
self.delegate,
846846
goal,
847-
&[],
848-
&[],
847+
Vec::new(),
848+
Vec::new(),
849849
TypingMode::ErasedNotCoherence(MayBeErased),
850850
);
851851

@@ -885,8 +885,8 @@ where
885885
let (orig_values, canonical_goal) = canonicalize_goal(
886886
self.delegate,
887887
goal,
888-
&opaque_types,
889-
&pseudo_rigid_due_to_opaques,
888+
opaque_types,
889+
pseudo_rigid_due_to_opaques,
890890
typing_mode,
891891
);
892892

@@ -2132,8 +2132,8 @@ pub(super) fn evaluate_root_goal_for_proof_tree<D: SolverDelegate<Interner = I>,
21322132
let (orig_values, canonical_goal) = canonicalize_goal(
21332133
delegate,
21342134
goal,
2135-
&opaque_types,
2136-
&pseudo_rigid_due_to_opaques,
2135+
opaque_types,
2136+
pseudo_rigid_due_to_opaques,
21372137
typing_mode.into(),
21382138
);
21392139

0 commit comments

Comments
 (0)