Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining generic_const_exprs with adt_const_params talks about derefs that don't exist in the code #90455

Closed
oli-obk opened this issue Oct 31, 2021 · 1 comment · Fixed by #90529
Labels
A-const-generics Area: const generics (parameters and arguments) F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]`

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Oct 31, 2021

Combining this with adt_const_params can give weird errors:

#![feature(generic_const_exprs, adt_const_params)]

struct FieldElement<const N: &'static str> {
    n: [u64; num_limbs(N)],
}
const fn num_limbs(_: &str) -> usize {
    0
}

Error:

error: overly complex generic constant
 --> src/lib.rs:5:14
  |
5 |     n: [u64; num_limbs(N)],
  |              ^^^^^^^^^^-^
  |                        |
  |                        dereferencing is not supported in generic constants
  |
  = help: consider moving this anonymous constant into a `const` function
  = note: this operation may be supported in the future

https://play.rust-lang.org/?gist=a6a2aecfba83485968a81b8599b86cc5

(I hoped I can try and play with these to see if it would be possible to implement typed algebraic fields)

Originally posted by @elichai in #76560 (comment)

@oli-obk
Copy link
Contributor Author

oli-obk commented Oct 31, 2021

We probably need to skip reborrows by treating them as no-ops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants