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

generic Self types are currently not permitted in anonymous constants #2820

Open
Dushistov opened this issue Sep 6, 2024 · 1 comment
Open

Comments

@Dushistov
Copy link

Dushistov commented Sep 6, 2024

Code bellow cause compilation error:

error: generic `Self` types are currently not permitted in anonymous constants
  --> src/main.rs:15:27
   |
15 |     pub id: ArrayString<{ Self::FIX_ID_MAX_LEN }>,
   |                           ^^^^
   |
note: not a concrete type

Without #[derive(Deserialize)] it compiled and work just fine.

use arrayvec::ArrayString;
use serde::Deserialize;

#[derive(Deserialize)]
pub struct Foo {
    pub id: ArrayString<{ Self::FIX_ID_MAX_LEN }>,
}

impl Foo {
    pub const FIX_ID_MAX_LEN: usize = 20;
}

serde 1.0.210, rustc 1.82.0-beta.1, arrayvec 0.7.6

@appetrosyan
Copy link

Can confirm.

Related upstream issue in Rust

rust-lang/rust#68436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants