rust/crates
bors[bot] 787bd3c551
Merge #8122
8122: Make bare underscore token an Ident rather than Punct in proc-macro r=edwin0cheng a=kevinmehall

In rustc and proc-macro2, a bare `_` token is parsed for procedural macro purposes as `Ident` rather than `Punct` (see https://github.com/rust-lang/rust/pull/48842). This changes rust-analyzer to match rustc's behavior and implementation by handling `_` as an Ident in token trees, but explicitly preventing `$x:ident` from matching it in MBE.

proc macro crate:
```rust
#[proc_macro]
pub fn input(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    dbg!(input)
}
```

test crate:
```rust
test_proc_macro::input!(_);
```

output (rustc):
```rust
[test-proc-macro/src/lib.rs:10] input = TokenStream [
    Ident {
        ident: "_",
        span: #0 bytes(173..174),
    },
]
```

output (rust-analyzer before this change):
```rust
[test-proc-macro/src/lib.rs:10] input = TokenStream [
    Punct {
        ch: '_',
        spacing: Joint,
        span: 4294967295,
    },
]
```

output (rust-analyzer after this change):
```rust
[test-proc-macro/src/lib.rs:10] input = TokenStream [
    Ident {
        ident: "_",
        span: 4294967295,
    },
]
```


Co-authored-by: Kevin Mehall <km@kevinmehall.net>
2021-03-21 00:10:14 +00:00
..
base_db avoid converting types into themselves via .into() (clippy::useless-conversion) 2021-03-17 01:27:56 +01:00
cfg
flycheck
hir Turn Obligation into something similar to chalk_ir::DomainGoal 2021-03-20 12:47:12 +01:00
hir_def Add AttrsWithOwner and clean up source_map 2021-03-19 21:23:57 +01:00
hir_expand Return Either from MacroDefId::ast_id 2021-03-19 19:56:13 +01:00
hir_ty Turn Obligation into something similar to chalk_ir::DomainGoal 2021-03-20 12:47:12 +01:00
ide Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
ide_assists Merge #8119 2021-03-20 12:58:28 +00:00
ide_completion Merge #8124 2021-03-20 22:32:25 +00:00
ide_db Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
ide_ssr don't clone types that are copy (clippy::clone_on_copy) 2021-03-17 01:56:31 +01:00
mbe Fix and test edge cases of _ as ident 2021-03-20 17:54:57 -06:00
parser Parse extended_key_value_attributes 2021-03-19 02:13:46 +01:00
paths
proc_macro_api remove uselessly wrapped ?s. (clippy::meedless_question_mark 2021-03-17 02:19:40 +01:00
proc_macro_srv Make bare underscore token an Ident rather than Punct in proc-macro 2021-03-20 12:28:44 -06:00
proc_macro_test
profile
project_model some clippy::performance fixes 2021-03-15 10:19:59 +01:00
rust-analyzer Don't return a SourceChange on WillRenameFiles when nothing gets refactored 2021-03-20 13:57:58 +01:00
stdx
syntax Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
test_utils Add new_source_root meta to test fixtures 2021-03-16 15:28:02 +01:00
text_edit
toolchain
tt
vfs
vfs-notify