Repository: rust-analyzer/rust-analyzer (rust)

Issue:
Const generics: Syntax Error: expected type
<!--
Troubleshooting guide: https://rust-analyzer.github.io/manual.html#troubleshooting
Forum for questions: https://users.rust-lang.org/c/ide/14

Before submitting, please make sure that you're not running into one of these known issues:

 1. local imports (`use` statements) don't work: #1165
 2. local items don't work: #1559
 3. on-the-fly diagnostics are mostly unimplemented (`cargo check` diagnostics will be shown when saving a file)
 4. some settings are required for procedural macro and build script support (`rust-analyzer.cargo.loadOutDirsFromCheck`, `rust-analyzer.procMacro.enable`): #6448
 5. some platform-specific imports are not resolved: #6038
 6. the official `rust-lang.rust` VS Code extension conflicts with `rust-analyzer`: #6463

Otherwise please try to provide information which will help us to fix the issue faster. Minimal reproducible examples with few dependencies are especially lovely <3.
-->

So the following code gives errors at the `let s: S<true|false> = S;` and the `fn only_true(s: S<true>)`, saying `Syntax Error: expected type`

When I run the code with `cargo run`, it all works as expected - (the second `only_true` call gives a compiler error ``expected `true`, found `false` ``, commenting that out prints out the following, as it should do.

```
true
false
only true
``` 



Cargo version: `cargo 1.50.0-nightly (75d5d8cff 2020-12-22)`
Rust version: `rustc 1.51.0-nightly (fde692739 2021-01-02)`
RA version: `0.3.445-nightly`

```rust
#[derive(Copy, Clone)]
struct S<const B: bool>;

impl<const B: bool> S<B> {
    fn get_b(&self) -> bool {
        B
    }
}

fn main() {
    let s_true: S<true> = S;
    let s_false: S<false> = S;

    use_s(s_true);
    use_s(s_false);

    only_true(s_true);
    only_true(s_false);
}

fn use_s<const B: bool>(s: S<B>) {
    println!("{}", s.get_b());
}

fn only_true(s: S<true>) {
    println!("only true");
}
```

I've actually been sort of keen to get into working on RA/Rust/etc issues, so if this looks like it would be a good intro issue, I'd love to give a go at fixing it if there's any pointers. 

<details>
  <summary>VSCode output</summary>
  
```
  INFO [10/01/2021, 11:38:54]: Extension version: 0.3.445-nightly
INFO [10/01/2021, 11:38:54]: Using configuration {
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    chainingHints: true,
    maxLength: null,
    parameterHints: true,
    typeHints: true
  },
  updates: { channel: 'nightly', askBeforeDownload: false },
  server: { path: null, extraEnv: null },
  trace: { server: 'off', extension: false },
  debug: {
    engine: 'auto',
    sourceFileMap: {
      '/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
    },
    openDebugPane: false,
    engineSettings: {}
  },
  assist: { importMergeBehavior: 'full', importPrefix: 'plain' },
  callInfo: { full: true },
  cargo: {
    autoreload: true,
    allFeatures: false,
    features: [],
    loadOutDirsFromCheck: true,
    noDefaultFeatures: false,
    target: null,
    noSysroot: false
  },
  checkOnSave: {
    enable: true,
    allFeatures: null,
    allTargets: true,
    command: 'clippy',
    noDefaultFeatures: null,
    target: null,
    extraArgs: [],
    features: null,
    overrideCommand: null
  },
  completion: {
    addCallArgumentSnippets: true,
    addCallParenthesis: true,
    postfix: { enable: true },
    autoimport: { enable: true }
  },
  diagnostics: {
    enable: true,
    enableExperimental: true,
    disabled: [],
    warningsAsHint: [],
    warningsAsInfo: []
  },
  files: { watcher: 'client' },
  hoverActions: {
    debug: true,
    enable: true,
    gotoTypeDef: true,
    implementations: true,
    run: true,
    linksInHover: true
  },
  lens: {
    debug: true,
    enable: true,
    implementations: true,
    run: true,
    methodReferences: true
  },
  linkedProjects: [],
  lruCapacity: null,
  notifications: { cargoTomlNotFound: true },
  procMacro: { enable: true, server: null },
  runnables: { overrideCargo: null, cargoExtraArgs: [] },
  rustcSource: null,
  rustfmt: { extraArgs: [], overrideCommand: null }
}
INFO [10/01/2021, 11:38:54]: PersistentState: {
  lastCheck: 1610106232376,
  releaseId: 36122250,
  serverVersion: '0.3.445-nightly'
}
INFO [10/01/2021, 11:38:54]: Using server binary at /home/callym/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu
```
</details>

Pull request description:
Allow `true` and `false` keywords in const generics
This should fix #7232 - hopefully I've done it right, it passes the tests and the rast file looks like it's picking up the true and false in the test

Patch:
diff --git a/crates/parser/src/grammar/type_args.rs b/crates/parser/src/grammar/type_args.rs
index a013c49b9a..debb23fea1 100644
--- a/crates/parser/src/grammar/type_args.rs
+++ b/crates/parser/src/grammar/type_args.rs
@@ -26,7 +26,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
 }
 
 // test type_arg
-// type A = B<'static, i32, 1, { 2 }, Item=u64>;
+// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
 fn generic_arg(p: &mut Parser) {
     let m = p.start();
     match p.current() {
@@ -55,6 +55,10 @@ fn generic_arg(p: &mut Parser) {
             expressions::literal(p);
             m.complete(p, CONST_ARG);
         }
+        TRUE_KW | FALSE_KW => {
+            expressions::literal(p);
+            m.complete(p, CONST_ARG);
+        }
         _ => {
             types::type_(p);
             m.complete(p, TYPE_ARG);


Test patch:
diff --git a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast
index 51e881a8e2..68c0f1c668 100644
--- a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast
@@ -1,5 +1,5 @@
-SOURCE_FILE@0..46
-  TYPE_ALIAS@0..45
+SOURCE_FILE@0..59
+  TYPE_ALIAS@0..58
     TYPE_KW@0..4 "type"
     WHITESPACE@4..5 " "
     NAME@5..6
@@ -7,12 +7,12 @@ SOURCE_FILE@0..46
     WHITESPACE@6..7 " "
     EQ@7..8 "="
     WHITESPACE@8..9 " "
-    PATH_TYPE@9..44
-      PATH@9..44
-        PATH_SEGMENT@9..44
+    PATH_TYPE@9..57
+      PATH@9..57
+        PATH_SEGMENT@9..57
           NAME_REF@9..10
             IDENT@9..10 "B"
-          GENERIC_ARG_LIST@10..44
+          GENERIC_ARG_LIST@10..57
             L_ANGLE@10..11 "<"
             LIFETIME_ARG@11..18
               LIFETIME@11..18
@@ -51,6 +51,16 @@ SOURCE_FILE@0..46
                   PATH_SEGMENT@40..43
                     NAME_REF@40..43
                       IDENT@40..43 "u64"
-            R_ANGLE@43..44 ">"
-    SEMICOLON@44..45 ";"
-  WHITESPACE@45..46 "\n"
+            COMMA@43..44 ","
+            WHITESPACE@44..45 " "
+            CONST_ARG@45..49
+              LITERAL@45..49
+                TRUE_KW@45..49 "true"
+            COMMA@49..50 ","
+            WHITESPACE@50..51 " "
+            CONST_ARG@51..56
+              LITERAL@51..56
+                FALSE_KW@51..56 "false"
+            R_ANGLE@56..57 ">"
+    SEMICOLON@57..58 ";"
+  WHITESPACE@58..59 "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs
index 0d07d76514..6a8721a73e 100644
--- a/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs
+++ b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs
@@ -1,1 +1,1 @@
-type A = B<'static, i32, 1, { 2 }, Item=u64>;
+type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;