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

feature(const_trait_impl) is treated as syntax error #7313

Closed
andre-richter opened this issue Jan 17, 2021 · 4 comments · Fixed by #7338
Closed

feature(const_trait_impl) is treated as syntax error #7313

andre-richter opened this issue Jan 17, 2021 · 4 comments · Fixed by #7338
Labels
A-parser parser issues S-actionable Someone could pick this issue up and work on it right now

Comments

@andre-richter
Copy link
Member

Hi,

experimental feature const_trait_impl is treated as a syntax error by rust-analyzer. For example, on nightly, the following compiles, but rust-analyzer would complain about the impl const and even erase the const on saving.

#![allow(incomplete_features)]
#![feature(const_trait_impl)]

struct X(u32);

impl const core::ops::Add<u32> for X {
    type Output = u32;
    
    fn add(self, other: u32) -> u32 {
        self.0 + other
    }
}

fn main(){
    let y = X(2);

    println!("{}", y + 1u32);
}
@Veykril Veykril added A-parser parser issues S-actionable Someone could pick this issue up and work on it right now labels Jan 17, 2021
@Veykril
Copy link
Member

Veykril commented Jan 17, 2021

impl const parsing isn't implemented yet.

and even erase the const on saving.

This shouldn't be caused by RA, at least it seems suprising to me. I wonder if this is rustfmt eating that up for some reason, assuming you have format on save enabled 🤔
That seems to be a rustfmt issue

@flodiebold
Copy link
Member

That seems to be a rustfmt issue

Yeah, it's reproducible on playground as well.

@andre-richter
Copy link
Member Author

Ah yeah, sorry for getting that part wrong.

@andre-richter
Copy link
Member Author

Raised rust-lang/rustfmt#4650 for the rustfmt part.

@bors bors bot closed this as completed in 342bf41 Jan 18, 2021
@bors bors bot closed this as completed in #7338 Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants