Skip to content

Syntax Error: expected comma when RA + HRTB + const trait #19478

Open
@loynoir

Description

@loynoir

BUG

Syntax Error: expected comma when RA + HRTB + const trait

Detail

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer version: 1.87.0-nightly (3f55023 2025-03-27) [/home/vscode/.rustup/toolchains/nightly-2025-03-28-x86_64-unknown-linux-gnu/bin/rust-analyzer]

rustc version: (eg. output of rustc -V)

rustc 1.87.0-nightly (3f5502370 2025-03-27)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

vscode

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

#![feature(const_destruct)]
#![feature(const_trait_impl)]
pub mod reproduce {
    #[const_trait]
    pub trait ConstFrom<T>: Sized {
        #[must_use]
        fn const_from(value: T) -> Self;
    }

    #[const_trait]
    pub trait ConstAddAssign<Rhs = Self> {
        fn const_add_assign(&mut self, rhs: Rhs);
    }

    pub fn incr42<T>(mut x: T)
    where
        T: const ConstFrom<u8> + for<'a> ConstAddAssign<&'a T>,
    {
        let delta = T::const_from(42u8);

        x.const_add_assign(&delta)
    }

    pub const fn const_incr42<T>(mut x: T)
    where
        T: ~const ConstFrom<u8>
            + for<'a> ~const ConstAddAssign<&'a T>
            + ~const std::marker::Destruct,
    {
        let delta = T::const_from(42u8);

        x.const_add_assign(&delta)
    }
}

Related

Prev

rust-lang/rust#139134 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserparser issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions