Skip to content

Commit ae1410e

Browse files
authored
Rollup merge of #136069 - yotamofek:next-solver-slice, r=compiler-errors
Simplify slice indexing in next trait solver Unless I'm missing something: - no need to explicitly specify the end of the slice as the end of the index range - the `assert` is redundant since the indexing will panic for the same condition I think this change simplifies it a bit. Also replaced the `for` loop of `push`es with a call to `extend` with an iterator. Might improve performance since it knows how many elements will be added beforehand and can pre-reserve room? r? `@compiler-errors` , I think
2 parents 4b7e55a + e485cc5 commit ae1410e

File tree

1 file changed

+5
-7
lines changed
  • compiler/rustc_next_trait_solver/src/solve/eval_ctxt

1 file changed

+5
-7
lines changed

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,11 @@ where
453453
{
454454
// In case any fresh inference variables have been created between `state`
455455
// and the previous instantiation, extend `orig_values` for it.
456-
assert!(orig_values.len() <= state.value.var_values.len());
457-
for &arg in &state.value.var_values.var_values.as_slice()
458-
[orig_values.len()..state.value.var_values.len()]
459-
{
460-
let unconstrained = delegate.fresh_var_for_kind_with_span(arg, span);
461-
orig_values.push(unconstrained);
462-
}
456+
orig_values.extend(
457+
state.value.var_values.var_values.as_slice()[orig_values.len()..]
458+
.iter()
459+
.map(|&arg| delegate.fresh_var_for_kind_with_span(arg, span)),
460+
);
463461

464462
let instantiation =
465463
EvalCtxt::compute_query_response_instantiation_values(delegate, orig_values, &state, span);

0 commit comments

Comments
 (0)