Skip to content

Writeback's fix_scalar_builtin_expr hack doesn't apply to projections #19

@compiler-errors

Description

@compiler-errors
const fn first_eq_second(x: [u32; 2]) -> bool {
    x[0] == x[1]
}

Results in:

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

That's because WritebackCx::fix_scalar_builtin_expr doesn't apply to unnormalized projections properly: https://github.com/rust-lang/rust/blob/17c11672167827b0dd92c88ef69f24346d1286dd/compiler/rustc_hir_typeck/src/writeback.rs#L143

Somewhat related to #6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions