Skip to content

rustfmt can't parse negative const generic parameters #3614

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

Closed
bgourlie opened this issue Jun 10, 2019 · 1 comment · Fixed by #3631
Closed

rustfmt can't parse negative const generic parameters #3614

bgourlie opened this issue Jun 10, 2019 · 1 comment · Fixed by #3631

Comments

@bgourlie
Copy link

cargo +nightly fmt fails to parse the following code:

#![feature(const_generics)]

fn main() {
    let i = test::<-1>();
    println!("Hello, {}!", i);
}

fn test<const T: i8>() -> i8 {
    {T}
}

output:

error: expected identifier, found `<-`
 --> /Users/brian/Repos/untitled3/src/main.rs:4:19
  |
4 |     let i = test::<-1>();
  |                   ^^ expected identifier
@scampi scampi added the bug Panic, non-idempotency, invalid code, etc. label Jun 10, 2019
@topecongiro
Copy link
Contributor

Cannot-be-parsed part is fixed on the master, though with suboptimal formatting:

 fn test<const T: i8>() -> i8 {
-    {T}
+    {
+        T
+    }
 }

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

Successfully merging a pull request may close this issue.

3 participants