1
Fork 0

Rollup merge of #130714 - compiler-errors:try-structurally-resolve-const, r=BoxyUwU

Introduce `structurally_normalize_const`, use it in `rustc_hir_typeck`

Introduces `structurally_normalize_const` to typecking to separate the "eval a const" step from the "try to turn a valtree into a target usize" in HIR typeck, where we may still have infer vars and stuff around.

I also changed `check_expr_repeat` to move a double evaluation of a const into a single one. I'll leave inline comments.

r? ```@BoxyUwU```

I hesitated to really test this on the new solver where it probably matters for unevaluated consts. If you're worried about the side-effects, I'd be happy to craft some more tests 😄
This commit is contained in:
Matthias Krüger 2024-09-23 06:45:36 +02:00 committed by GitHub
commit 2bca5c4fc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 122 additions and 39 deletions

View file

@ -1668,10 +1668,17 @@ pub enum ArrayLen<'hir> {
}
impl ArrayLen<'_> {
pub fn hir_id(&self) -> HirId {
pub fn span(self) -> Span {
match self {
ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(ConstArg { hir_id, .. }) => {
*hir_id
ArrayLen::Infer(arg) => arg.span,
ArrayLen::Body(body) => body.span(),
}
}
pub fn hir_id(self) -> HirId {
match self {
ArrayLen::Infer(InferArg { hir_id, .. }) | ArrayLen::Body(&ConstArg { hir_id, .. }) => {
hir_id
}
}
}