Open compiler-errors opened 1 year ago
Similarly, during writeback we "fix up" some expressions so that we can emit MIR built-in operations for things like add and index. This does not happen during writeback if we have projections, though, e.g.:
const fn first_eq_second(x: [u32; 2]) -> bool {
x[0] == x[1]
}
This remains a call to Index::index
and fails to const-check:
error[E0015]: cannot call non-const operator in constant functions
--> <source>:2:5
|
2 | x[0] == x[1]
| ^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
We currently normalize in writeback after hir typeck with the new solver to avoid dealing with unnormalized projections during lints and in the MIR.
This code currently ICEs with:
This is because we expect for the types in the writeback results to have been normalized deeply, and other code (e.g. MIR build, MIR validation, late lints, reachability and dead code analysis) expect that
Ty::kind
calls "just work" without any further normalization.We can either: