Skip to content

Commit

Permalink
Unrolled build for rust-lang#136069
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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
  • Loading branch information
rust-timer authored Feb 7, 2025
2 parents 942db67 + e485cc5 commit 2c580a7
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,11 @@ where
{
// In case any fresh inference variables have been created between `state`
// and the previous instantiation, extend `orig_values` for it.
assert!(orig_values.len() <= state.value.var_values.len());
for &arg in &state.value.var_values.var_values.as_slice()
[orig_values.len()..state.value.var_values.len()]
{
let unconstrained = delegate.fresh_var_for_kind_with_span(arg, span);
orig_values.push(unconstrained);
}
orig_values.extend(
state.value.var_values.var_values.as_slice()[orig_values.len()..]
.iter()
.map(|&arg| delegate.fresh_var_for_kind_with_span(arg, span)),
);

let instantiation =
EvalCtxt::compute_query_response_instantiation_values(delegate, orig_values, &state, span);
Expand Down

0 comments on commit 2c580a7

Please sign in to comment.