@@ -1168,6 +1168,40 @@ where
11681168 self . delegate . evaluate_const ( param_env, uv)
11691169 }
11701170
1171+ pub ( super ) fn evaluate_const_and_instantiate_normalizes_to_term (
1172+ & mut self ,
1173+ goal : Goal < I , ty:: NormalizesTo < I > > ,
1174+ uv : ty:: UnevaluatedConst < I > ,
1175+ ) -> QueryResult < I > {
1176+ match self . evaluate_const ( goal. param_env , uv) {
1177+ Some ( evaluated) => {
1178+ self . instantiate_normalizes_to_term ( goal, evaluated. into ( ) ) ;
1179+ self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
1180+ }
1181+ None => {
1182+ // HACK(khyperia): calling `resolve_vars_if_possible` here shouldn't be necessary,
1183+ // `try_evaluate_const` calls `resolve_vars_if_possible` already. However, we want
1184+ // to check `has_non_region_infer` against the type with vars resolved (i.e. check
1185+ // if there are vars we failed to resolve), so we need to call it again here.
1186+ // Perhaps we could split EvaluateConstErr::HasGenericsOrInfers into HasGenerics and
1187+ // HasInfers or something, make evaluate_const return that, and make this branch be
1188+ // based on that, rather than checking `has_non_region_infer`.
1189+ if self . resolve_vars_if_possible ( uv) . has_non_region_infer ( ) {
1190+ self . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
1191+ } else {
1192+ // We do not instantiate to the `uv` passed in, but rather
1193+ // `goal.predicate.alias`. The `uv` passed in might correspond to the `impl`
1194+ // form of a constant (with generic arguments corresponding to the impl block),
1195+ // however, we want to structurally instantiate to the original, non-rebased,
1196+ // trait `Self` form of the constant (with generic arguments being the trait
1197+ // `Self` type).
1198+ self . structurally_instantiate_normalizes_to_term ( goal, goal. predicate . alias ) ;
1199+ self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
1200+ }
1201+ }
1202+ }
1203+ }
1204+
11711205 pub ( super ) fn is_transmutable (
11721206 & mut self ,
11731207 src : I :: Ty ,
0 commit comments