]>
git.lizzy.rs Git - rust.git/log
Aleksey Kladov [Mon, 30 Nov 2020 10:45:32 +0000 (13:45 +0300)]
Minor cleanup
Lukas Wirth [Sun, 29 Nov 2020 21:49:07 +0000 (22:49 +0100)]
Show type of Self on hover
bors[bot] [Sun, 29 Nov 2020 20:03:44 +0000 (20:03 +0000)]
Merge #6665
6665: Support self in reference search r=matklad a=Veykril
The approach here is simply checking the descendants of the function body for `PathExpr` then checking whether it only contains a single `self` `PathSegment`, this is to prevent us from picking up `self` tokens from local `UseTree`s.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sat, 28 Nov 2020 21:55:34 +0000 (22:55 +0100)]
Support self in reference search
bors[bot] [Sun, 29 Nov 2020 19:35:12 +0000 (19:35 +0000)]
Merge #6599
6599: Add attribute highlight modifier to all tokens inside attributes r=matklad a=Veykril
This has the side effect that we also emit `attribute.attribute` highlights now, as in, the tokens that get the attribute semantic type also get the attribute modifier. I personally don't think it's really a problem but maybe it is to some? It's just that it was really simple to implement it this way, which is why I just went this route for now.
Fixes #6536
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
bors[bot] [Sun, 29 Nov 2020 19:21:25 +0000 (19:21 +0000)]
Merge #6601
6601: add let and letm postfix to turn expressions into variables r=matklad a=bnjjj
Partially resolve #6426
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
bors[bot] [Sun, 29 Nov 2020 19:07:04 +0000 (19:07 +0000)]
Merge #6670
6670: Allow renaming between self and first param with owned parameters r=matklad a=Veykril
This fixes renaming owned SelfParams turning the parameter into a reference, as in, for a type `Foo`, `fn foo(self) {}` became `fn foo(renamed_name: &Foo) {}` prior to this.
Similarly for the other way around, we now support renaming non-ref parameters to `self`. Additionally we do more checks now than before. We check:
- that the function has an impl block
- that we are renaming the first parameter(prior we ignored which parameter was renamed and always picked the first nevertheless)
- that the parameter's type aligns with the impl block(minus one level of reference abstraction to account for `&self`/`&mut self`)
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sun, 29 Nov 2020 17:44:26 +0000 (18:44 +0100)]
Reject more cases of invalid parameter to self renames
Lukas Wirth [Sun, 29 Nov 2020 16:56:36 +0000 (17:56 +0100)]
Fix renaming owned self to parameter emitting ref
bors[bot] [Sun, 29 Nov 2020 15:46:08 +0000 (15:46 +0000)]
Merge #6669
6669: Align default importMergeBehaviour with VSCode r=lnicola a=flodiebold
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Florian Diebold [Sun, 29 Nov 2020 15:43:30 +0000 (16:43 +0100)]
Align default importMergeBehaviour with VSCode
bors[bot] [Sun, 29 Nov 2020 14:35:38 +0000 (14:35 +0000)]
Merge #6666
6666: Support 'go to definition' for self r=jonas-schievink a=Veykril
Also reverts #6660, instead of showing the type it now works like it does for names by returning the declaration we are already on. This for example enables VSCode to show all references(#6665) when executing `go to definition` on the declaration.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sat, 28 Nov 2020 21:50:59 +0000 (22:50 +0100)]
Support 'go to definition' for self
bors[bot] [Sat, 28 Nov 2020 23:38:18 +0000 (23:38 +0000)]
Merge #6664
6664: Show type of self param on hover r=jonas-schievink a=Veykril
Show the type of `self` when hovering the token in a `SelfParam`.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sat, 28 Nov 2020 21:46:25 +0000 (22:46 +0100)]
Show type of self param on hover
Benjamin Coenen [Sat, 28 Nov 2020 16:38:16 +0000 (17:38 +0100)]
add let and letm postfix to turn expressions into variables
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
bors[bot] [Sat, 28 Nov 2020 16:04:35 +0000 (16:04 +0000)]
Merge #6660
6660: Support "go to definition" for SelfParams r=jonas-schievink a=Veykril
Fixes #6657
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sat, 28 Nov 2020 15:22:28 +0000 (16:22 +0100)]
Add ast::*Number::suffix tests unit tests
bors[bot] [Sat, 28 Nov 2020 15:16:33 +0000 (15:16 +0000)]
Merge #6659
6659: Explain how we get precise spans for diagnostics. r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Aleksey Kladov [Sat, 28 Nov 2020 15:14:08 +0000 (18:14 +0300)]
Explain how we get precise spans for diagnostics.
bors[bot] [Sat, 28 Nov 2020 15:10:00 +0000 (15:10 +0000)]
Merge #6645
6645: Publish diagnostics for macro expansion errors r=matklad a=jonas-schievink
This adds 2 new diagnostics, emitted during name resolution:
* `unresolved-proc-macro`, a weak warning that is emitted when a proc macro is supposed to be expanded, but was not provided by the build system. This usually means that proc macro support is turned off, but may also indicate setup issues when using rust-project.json. Being a weak warning, this should help set expectations when users see it, while not being too obstructive. We do not yet emit this for attribute macros though, just custom derives and `!` macros.
* `macro-error`, which is emitted when any macro (procedural or `macro_rules!`) fails to expand due to some error. This is an error-level diagnostic, but currently still marked as experimental, because there might be spurious errors and this hasn't been tested too well.
This does not yet emit diagnostics when expansion in item bodies fails, just for module-level macros.
Known bug: The "proc macro not found" diagnostic points at the whole item for custom derives, it should just point at the macro's name in the `#[derive]` list, but I haven't found an easy way to do that.
Screenshots:
![screenshot-2020-11-26-19:54:14](https://user-images.githubusercontent.com/
1786438 /
100385782 -
f8bc2300 -3023-11eb-9f27-
e8f8ce9d6114 .png)
![screenshot-2020-11-26-19:55:39](https://user-images.githubusercontent.com/
1786438 /
100385784 -
f954b980 -3023-11eb-9617-
ac2eb0a0a9dc .png)
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Lukas Wirth [Sat, 28 Nov 2020 15:07:07 +0000 (16:07 +0100)]
Support goto definition for ADT-SelfParams
bors[bot] [Sat, 28 Nov 2020 14:33:57 +0000 (14:33 +0000)]
Merge #6650
6650: Make completion and assists module independent r=matklad a=SomeoneToIgnore
A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/6553#discussion_r524402907
Move the common code for both assists and completion modules into a separate crate.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Kirill Bulatov [Sat, 28 Nov 2020 14:30:39 +0000 (16:30 +0200)]
Move the helpers into ide_db
bors[bot] [Sat, 28 Nov 2020 13:56:28 +0000 (13:56 +0000)]
Merge #6656
6656: Coalesce flycheck events r=matklad a=jonas-schievink
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 27 Nov 2020 21:52:22 +0000 (22:52 +0100)]
Coalesce flycheck events
bors[bot] [Fri, 27 Nov 2020 17:36:07 +0000 (17:36 +0000)]
Merge #6653
6653: Downgrade "failed to load" error to warning r=jonas-schievink a=jonas-schievink
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6596
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 27 Nov 2020 17:35:22 +0000 (18:35 +0100)]
Downgrade "failed to load" error to warning
bors[bot] [Fri, 27 Nov 2020 17:08:22 +0000 (17:08 +0000)]
Merge #6652
6652: Add/Fix macro expansion profiling r=jonas-schievink a=jonas-schievink
bors r+ :robot:
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 27 Nov 2020 17:07:16 +0000 (18:07 +0100)]
Add/Fix macro expansion profiling
Kirill Bulatov [Fri, 27 Nov 2020 10:26:20 +0000 (12:26 +0200)]
Rustdocs fixes
Kirill Bulatov [Fri, 27 Nov 2020 10:22:10 +0000 (12:22 +0200)]
Group import data in a struct
Kirill Bulatov [Tue, 24 Nov 2020 21:25:13 +0000 (23:25 +0200)]
Extract the import code into the shared module
bors[bot] [Fri, 27 Nov 2020 16:14:04 +0000 (16:14 +0000)]
Merge #6651
6651: Profile completions better r=SomeoneToIgnore a=SomeoneToIgnore
During https://github.com/rust-analyzer/rust-analyzer/issues/6612 investigation, had added a few more profiling points and considered that they can be useful later, ergo the PR.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Kirill Bulatov [Fri, 27 Nov 2020 16:13:02 +0000 (18:13 +0200)]
Fix the profiling string
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
Kirill Bulatov [Fri, 27 Nov 2020 16:00:03 +0000 (18:00 +0200)]
Profile completions better
Jonas Schievink [Fri, 27 Nov 2020 15:29:40 +0000 (16:29 +0100)]
More accurately place proc-macro diagnostic
Jonas Schievink [Thu, 26 Nov 2020 19:09:54 +0000 (20:09 +0100)]
Publish diagnostics for macro expansion errors
Jonas Schievink [Thu, 26 Nov 2020 18:07:53 +0000 (19:07 +0100)]
Add dedicated error for "proc macro not found"
bors[bot] [Fri, 27 Nov 2020 11:14:14 +0000 (11:14 +0000)]
Merge #6648
6648: Avoid allocation in ast::String::value if the string needs no unescaping r=lnicola a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Thu, 26 Nov 2020 22:08:02 +0000 (23:08 +0100)]
Avoid allocation in ast::String::value if the string needs no unescaping
bors[bot] [Fri, 27 Nov 2020 09:49:37 +0000 (09:49 +0000)]
Merge #6586
6586: Don't call a closure a function in the infer_function_return_type assist label r=lnicola a=Veykril
`Add this function's return type` becomes `Add this closure's return type` for closures. This makes it more obvious that we are indeed planning on modifying the closure and not its containing function.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Thu, 26 Nov 2020 22:57:40 +0000 (23:57 +0100)]
Accept more than just the standard rust literal suffixes in *Number::suffix
bors[bot] [Thu, 26 Nov 2020 20:50:16 +0000 (20:50 +0000)]
Merge #6646
6646: Remove single r#trait identifer usage r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Thu, 26 Nov 2020 20:44:17 +0000 (21:44 +0100)]
Don't use raw identifiers
bors[bot] [Thu, 26 Nov 2020 20:30:16 +0000 (20:30 +0000)]
Merge #6635
6635: Complete struct in irrefutable let r=Veykril a=Veykril
Fixes #6210
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Wed, 25 Nov 2020 22:25:10 +0000 (23:25 +0100)]
Complete struct in irrefutable let
bors[bot] [Thu, 26 Nov 2020 19:18:40 +0000 (19:18 +0000)]
Merge #6644
6644: Simplify error formatting r=lnicola a=lnicola
CC jonas-schievink
bors r+
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Laurențiu Nicola [Thu, 26 Nov 2020 18:56:38 +0000 (20:56 +0200)]
Simplify error formatting
bors[bot] [Thu, 26 Nov 2020 17:28:43 +0000 (17:28 +0000)]
Merge #6643
6643: Remove unused import r=lnicola a=lnicola
Not sure why CI didn't catch this...
bors r+
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Laurențiu Nicola [Thu, 26 Nov 2020 17:25:59 +0000 (19:25 +0200)]
Remove unused import
bors[bot] [Thu, 26 Nov 2020 16:30:05 +0000 (16:30 +0000)]
Merge #6641
6641: Fix def map volatility with `#[cfg]` diagnostics r=jonas-schievink a=jonas-schievink
bors r+ :robot:
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 26 Nov 2020 16:29:09 +0000 (17:29 +0100)]
Don't store `SyntaxNodePtr` in `CrateDefMap`
It is volatile across reparses and makes incrementality worse.
Jonas Schievink [Thu, 26 Nov 2020 16:28:00 +0000 (17:28 +0100)]
Test def map invalidation with #[cfg] below change
bors[bot] [Thu, 26 Nov 2020 15:56:58 +0000 (15:56 +0000)]
Merge #6640
6640: Implement `Display` for macro expansion errors r=jonas-schievink a=jonas-schievink
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 26 Nov 2020 15:56:22 +0000 (16:56 +0100)]
Implement `Display` for macro expansion errors
bors[bot] [Thu, 26 Nov 2020 15:48:58 +0000 (15:48 +0000)]
Merge #6639
6639: Use `ExpandResult` instead of `MacroResult` r=jonas-schievink a=jonas-schievink
`MacroResult` is redundant.
bors r+ :robot:
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 26 Nov 2020 15:48:17 +0000 (16:48 +0100)]
Use `ExpandResult` instead of `MacroResult`
`MacroResult` is redundant
bors[bot] [Thu, 26 Nov 2020 15:05:09 +0000 (15:05 +0000)]
Merge #6638
6638: Use named fields in `ExpandResult` r=jonas-schievink a=jonas-schievink
bors r+ :robot:
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 26 Nov 2020 15:04:23 +0000 (16:04 +0100)]
Use named fields in `ExpandResult`
bors[bot] [Thu, 26 Nov 2020 12:42:29 +0000 (12:42 +0000)]
Merge #6637
6637: Publish diagnostics on file open r=jonas-schievink a=jonas-schievink
Diagnostics are sometimes only showing up when typing. This should fix that.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6381
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 26 Nov 2020 12:33:47 +0000 (13:33 +0100)]
Publish diagnostics on file open
Diagnostics are sometimes only showing up when typing.
This should fix that.
bors[bot] [Thu, 26 Nov 2020 10:43:35 +0000 (10:43 +0000)]
Merge #6614 #6632
6614: Improve autoimports on completion speed r=matklad a=SomeoneToIgnore
Presumably closes https://github.com/rust-analyzer/rust-analyzer/issues/6594
May help https://github.com/rust-analyzer/rust-analyzer/issues/6612
* Ignore modules eaferly
* Do less completion string rendering
6632: Pin cargo_metadata r=matklad a=kjeremy
See: https://github.com/oli-obk/cargo_metadata/pull/142#issuecomment-
733653275
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
bors[bot] [Thu, 26 Nov 2020 10:36:26 +0000 (10:36 +0000)]
Merge #6496
6496: Use builtin scopes more r=matklad a=georgewfraser
VSCode has added more builtin fallback scopes, so we can remove some of our fallback scopes by aligning with their conventions.
Note that the macro scope doesn't seem to actually *work* at the moment. I have filed a bug with VSCode: https://github.com/microsoft/vscode/issues/110150
Co-authored-by: George Fraser <george@fivetran.com>
George Fraser [Wed, 25 Nov 2020 16:39:39 +0000 (08:39 -0800)]
Just remove the macro fallback
kjeremy [Wed, 25 Nov 2020 15:11:53 +0000 (10:11 -0500)]
Pin cargo_metadata
bors[bot] [Tue, 24 Nov 2020 23:40:05 +0000 (23:40 +0000)]
Merge #6631
6631: Gate autoimports begind experimental completions flag r=kjeremy a=SomeoneToIgnore
Part of https://github.com/rust-analyzer/rust-analyzer/issues/6612
Adds a possibility to disable autoimports:
<img width="598" alt="image" src="https://user-images.githubusercontent.com/
2690773 /
100156673 -
f8037f80 -2eb1-11eb-8e74-
59ebe4260ba3 .png">
and other experimental completions we might want to add later.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Kirill Bulatov [Tue, 24 Nov 2020 22:42:58 +0000 (00:42 +0200)]
Document experimental completions
Kirill Bulatov [Tue, 24 Nov 2020 22:02:45 +0000 (00:02 +0200)]
Gate autoimports begind experimental completions flag
bors[bot] [Tue, 24 Nov 2020 21:01:33 +0000 (21:01 +0000)]
Merge #6630
6630: followup to "hir_expand: propagate expansion errors" r=jonas-schievink a=jonas-schievink
https://github.com/rust-analyzer/rust-analyzer/pull/6625
bors r+ :robot:
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Tue, 24 Nov 2020 20:57:51 +0000 (21:57 +0100)]
Rename `parse_macro` to `parse_macro_expansion`
This does not parse macros, it expands a macro and parses the *result*
Jonas Schievink [Tue, 24 Nov 2020 20:55:08 +0000 (21:55 +0100)]
hir_expand::db: reduce fn visibility
Jonas Schievink [Tue, 24 Nov 2020 20:52:19 +0000 (21:52 +0100)]
Remove fixed FIXME, propagate errors better
bors[bot] [Tue, 24 Nov 2020 18:01:49 +0000 (18:01 +0000)]
Merge #6625
6625: hir_expand: propagate expansion errors r=jonas-schievink a=jonas-schievink
This is needed to collect and report expansion errors later.
bors r+ :robot:
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Tue, 24 Nov 2020 18:00:23 +0000 (19:00 +0100)]
hir_expand: propagate expansion errors
bors[bot] [Tue, 24 Nov 2020 17:51:46 +0000 (17:51 +0000)]
Merge #6624
6624: Check structs for match exhaustiveness r=Veykril a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Tue, 24 Nov 2020 17:28:55 +0000 (18:28 +0100)]
Check structs for match exhaustiveness
bors[bot] [Tue, 24 Nov 2020 15:57:32 +0000 (15:57 +0000)]
Merge #6621
6621: Handle ellipsis in tuple patterns in match exhaustiveness checking r=flodiebold a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Tue, 24 Nov 2020 15:46:06 +0000 (16:46 +0100)]
Add middle ellipsis missing arm text
Lukas Wirth [Tue, 24 Nov 2020 15:43:28 +0000 (16:43 +0100)]
Handle ellipsis in tuple patterns in match exhaustiveness checking
bors[bot] [Tue, 24 Nov 2020 15:13:25 +0000 (15:13 +0000)]
Merge #6618
6618: Properly infer tuple patterns when encountering ellipsis r=Veykril a=Veykril
We basically just split the subpatterns into two halves when the ellipsis is present and then offset the latter half to account for the ignored bindings.
Fixes #6616
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Tue, 24 Nov 2020 13:52:46 +0000 (14:52 +0100)]
Properly infer tuple struct patterns when encountering ellipsis
bors[bot] [Tue, 24 Nov 2020 15:00:54 +0000 (15:00 +0000)]
Merge #6620
6620: cargo update (without cargo_metadata) r=kjeremy a=kjeremy
This is a `cargo update` run without updating `cargo_metadata`.
`cargo_metadata` `0.12.1` pins `semver-parser` to `0.10.0` (https://github.com/oli-obk/cargo_metadata/commit/
4e88e5624c5f20ca94dad0ea97fdb438fdea443f ) which brings back the compile time blowup that @matklad tried so hard to avoid in https://github.com/steveklabnik/semver-parser/pull/50.
Co-authored-by: kjeremy <kjeremy@gmail.com>
kjeremy [Tue, 24 Nov 2020 14:13:26 +0000 (09:13 -0500)]
cargo update
bors[bot] [Tue, 24 Nov 2020 13:53:38 +0000 (13:53 +0000)]
Merge #6619
6619: New lsp-types to fix versioning r=kjeremy a=kjeremy
Fixes #6603
Co-authored-by: kjeremy <kjeremy@gmail.com>
kjeremy [Tue, 24 Nov 2020 13:52:24 +0000 (08:52 -0500)]
New lsp-types to fix versioning
Fixes #6603
Lukas Wirth [Tue, 24 Nov 2020 12:41:21 +0000 (13:41 +0100)]
Properly infer tuple patterns when encountering ellipsis
bors[bot] [Tue, 24 Nov 2020 10:10:05 +0000 (10:10 +0000)]
Merge #6617
6617: Avoid string allocations in ignore_test r=lnicola a=lnicola
CC @jakobhellermann
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Laurențiu Nicola [Tue, 24 Nov 2020 10:08:54 +0000 (12:08 +0200)]
Avoid string allocations in ignore_test
bors[bot] [Tue, 24 Nov 2020 00:54:53 +0000 (00:54 +0000)]
Merge #6610
6610: add 'Re-enable this test' assist r=SomeoneToIgnore a=jakobhellermann
The `Ignore this test` assist previously allowed ignoring multiple times, each time adding a `#[ignore]` attribute.
This PR instead shows an assist to undo the ignoring.
Co-authored-by: Jakob Hellermann <jakob.hellermann@protonmail.com>
bors[bot] [Tue, 24 Nov 2020 00:41:08 +0000 (00:41 +0000)]
Merge #6613
6613: Don't assume DidChangeTextDocument paths exist r=SomeoneToIgnore a=mjibson
Fixes #5933
Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
Kirill Bulatov [Tue, 24 Nov 2020 00:26:16 +0000 (02:26 +0200)]
Improve autoimports on completion speed
* Ignore modules eaferly
* Do less completion string rendering
Matt Jibson [Mon, 23 Nov 2020 23:35:34 +0000 (16:35 -0700)]
Don't assume DidChangeTextDocument paths exist
Fixes #5933
Jakob Hellermann [Mon, 23 Nov 2020 19:22:13 +0000 (20:22 +0100)]
add 'Re-enable this test' assist
bors[bot] [Mon, 23 Nov 2020 18:20:01 +0000 (18:20 +0000)]
Merge #6609
6609: Minor, import style r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Aleksey Kladov [Mon, 23 Nov 2020 18:19:37 +0000 (21:19 +0300)]
Minor, import style
bors[bot] [Mon, 23 Nov 2020 07:05:31 +0000 (07:05 +0000)]
Merge #6606
6606: Parse unsafe extern block r=lnicola a=dtolnay
`unsafe extern` block is parsed successfully by rustc, which means it is usable in attribute macro input.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=
6f805556f176d082d87255957f16b5f6
```rust
#[cfg(parse)]
unsafe extern "C++" {
fn demo();
}
```
```diff
SOURCE_FILE@0..52
- ERROR@0..33
+ EXTERN_BLOCK@0..52
ATTR@0..13
POUND@0..1 "#"
L_BRACK@1..2 "["
PATH@2..5
PATH_SEGMENT@2..5
NAME_REF@2..5
IDENT@2..5 "cfg"
TOKEN_TREE@5..12
L_PAREN@5..6 "("
IDENT@6..11 "parse"
R_PAREN@11..12 ")"
R_BRACK@12..13 "]"
WHITESPACE@13..14 "\n"
UNSAFE_KW@14..20 "unsafe"
WHITESPACE@20..21 " "
ABI@21..33
EXTERN_KW@21..27 "extern"
WHITESPACE@27..28 " "
STRING@28..33 "\"C++\""
- WHITESPACE@33..34 " "
- ERROR@34..52
- L_CURLY@34..35 "{"
- WHITESPACE@35..40 "\n "
- FN@40..50
- FN_KW@40..42 "fn"
- WHITESPACE@42..43 " "
- NAME@43..47
- IDENT@43..47 "demo"
- PARAM_LIST@47..49
- L_PAREN@47..48 "("
- R_PAREN@48..49 ")"
- SEMICOLON@49..50 ";"
- WHITESPACE@50..51 "\n"
- R_CURLY@51..52 "}"
+ WHITESPACE@33..34 " "
+ EXTERN_ITEM_LIST@34..52
+ L_CURLY@34..35 "{"
+ WHITESPACE@35..40 "\n "
+ FN@40..50
+ FN_KW@40..42 "fn"
+ WHITESPACE@42..43 " "
+ NAME@43..47
+ IDENT@43..47 "demo"
+ PARAM_LIST@47..49
+ L_PAREN@47..48 "("
+ R_PAREN@48..49 ")"
+ SEMICOLON@49..50 ";"
+ WHITESPACE@50..51 "\n"
+ R_CURLY@51..52 "}"
```
This is of interest for https://github.com/dtolnay/cxx.
Co-authored-by: David Tolnay <dtolnay@gmail.com>
David Tolnay [Mon, 23 Nov 2020 04:43:00 +0000 (20:43 -0800)]
Parse unsafe extern block
Benjamin Coenen [Sat, 21 Nov 2020 14:06:22 +0000 (15:06 +0100)]
add let and letm postfix to turn expressions into variables
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Lukas Wirth [Sat, 21 Nov 2020 11:51:05 +0000 (12:51 +0100)]
Add attribute highlight modifier to all tokens inside attributes