Skip to content

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

Closed

Description

@oli-obk

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)

Activity

  1. oli-obk commented on Oct 31, 2021

    @oli-obk
    ContributorAuthor

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

  2. added a commit that references this issue on Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)F-adt_const_params`#![feature(adt_const_params)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions