Commit graph

13851 commits

Author SHA1 Message Date
bors[bot]
9a88332452
Merge #6743
6743: Don't insert blank lines between doc attributes r=Veykril a=Veykril

Fixes #6742.
Doc attributes should be concatenated via a single linebreak as written in the [rustdoc book](https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html).
Also changed the loop to use an iterator to get rid of the `docs.trim_end_matches("\n\n").to_owned()` part using `Itertools::intersperse`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-07 15:12:53 +00:00
Lukas Wirth
93262c750e Don't insert blank lines between doc attributes 2020-12-07 16:10:46 +01:00
bors[bot]
6df91a84dc
Merge #6731
6731: Add replace_match_with_if_let assist r=matklad a=Veykril

Basically the counterpart to `replace_if_let_with_match`, I personally sometimes want to replace matches like
```rust
match foo {
    pat => expr,
    _ => (),
}
``` 
into the corresponding
```rust
if let pat = foo {
    expr
}
```
which is the main reasoning behind this.
I put this into the same file as `replace_if_let_with_match` because the are complementing each other and I would probably rename the file to something like `replace_if_let_match` but I didn't do that for now because I was unsure whether git would still view this as a rename or not due to the amount of changes in the file so that the diff is still properly visible for now.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-07 15:00:07 +00:00
Jonas Schievink
e8a19e24ea Make ProcMacroProcessExpander private 2020-12-07 14:11:17 +01:00
Jonas Schievink
e42e6f9ab9 ProcMacroProcessExpander: support attribute macros 2020-12-07 14:02:27 +01:00
bors[bot]
403ed489ff
Merge #6597
6597: Upgrade Chalk r=flodiebold a=flodiebold

Also make overflow depth and max type size configurable through env variables. This can be helpful at least for debugging.

Tests currently fail because of rust-lang/chalk#656, so we'll need to wait for the next update to merge this.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-12-07 10:49:37 +00:00
Florian Diebold
78dd548243 Upgrade Chalk
Also make overflow depth and max type size configurable through env variables.
This can be helpful at least for debugging.

Fixes #6628.
2020-12-07 11:48:58 +01:00
bors[bot]
a0fa522fda
Merge #6733
6733: Update attributes completion list r=jonas-schievink a=Veykril

Might be nice to have them grouped for readability/maintainability similar to how the [reference](https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index) does it but that would require the use of a `OnceCell` for sorting the entries back after construction.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-06 16:00:03 +00:00
Lukas Wirth
2ff1ebe8f3 Update attributes completion list 2020-12-06 16:46:24 +01:00
bors[bot]
1403ddf029
Merge #6734
6734: Emit additional diagnostics for hints/help/etc r=lnicola a=jonas-schievink

This makes rust-analyzer diagnostics match native rustc diagnostics in the terminal more closely. Unfortunately all of this is a bodge, since we already provide this information to the client in the form of `DiagnosticRelatedInformation`, but at least VS Code chooses such a poor UI for these that they don't help much, as evidenced [here](https://twitter.com/yaahc_/status/1335297260444250112) and in https://github.com/rust-lang/rust/issues/79741.

This PR papers over these client UI problems by taking the `DiagnosticRelatedInformation` and turning each one into its own hint-level diagnostic, which makes it show up in the source code. Quick fixes are attached to all resulting diagnostics, which makes them more discoverable.

### Example: "Consider removing this semicolon"

![screenshot-2020-12-06-01:27:29](https://user-images.githubusercontent.com/1786438/101268366-46423980-3762-11eb-9a69-1ff0b1806c2f.png)
![screenshot-2020-12-06-01:27:39](https://user-images.githubusercontent.com/1786438/101268367-46dad000-3762-11eb-81fa-afd234d44f17.png)
![screenshot-2020-12-06-01:27:46](https://user-images.githubusercontent.com/1786438/101268368-46dad000-3762-11eb-9205-4b9bd9f4406d.png)

### Example: "Value used after move"

![screenshot-2020-12-06-01:33:00](https://user-images.githubusercontent.com/1786438/101268447-22332800-3763-11eb-85ce-8c742927a2c8.png)
![screenshot-2020-12-06-01:33:07](https://user-images.githubusercontent.com/1786438/101268448-22cbbe80-3763-11eb-8f16-0590895d8bc6.png)


Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-06 13:26:54 +00:00
Jonas Schievink
45b8b3d57f
Apply suggestions from code review
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-12-06 14:23:55 +01:00
Jonas Schievink
2a6c246184 Update expect tests 2020-12-06 01:39:52 +01:00
Jonas Schievink
9d96a6d7af Emit additional diagnostics for hints/help/etc 2020-12-06 01:24:37 +01:00
Lukas Wirth
44c76d6550 Add replace_match_with_if_let assist 2020-12-05 15:41:36 +01:00
bors[bot]
8d5aa08712
Merge #6726
6726: Add slightly more profiling details r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-04 19:28:34 +00:00
Jonas Schievink
b9d947cc6f Add slightly more profiling details 2020-12-04 20:26:28 +01:00
bors[bot]
571f247fbc
Merge #6725
6725: Don't respawn proc macro server on crash r=jonas-schievink a=jonas-schievink

Now the thread managing IPC will exit when the server process crashes instead of respawning it.

Closes https://github.com/rust-analyzer/rust-analyzer/issues/6707

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-04 19:12:49 +00:00
Jonas Schievink
869ad13cf1 Don't respawn proc macro server on crash 2020-12-04 20:11:56 +01:00
bors[bot]
2756abb167
Merge #6721
6721: Use METHOD semantic token type r=kjeremy a=lnicola

Closes #6685

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-12-04 18:46:44 +00:00
bors[bot]
b6def6575c
Merge #6724
6724: Fix `diagnostics` subcommand, look at all modules r=jonas-schievink a=jonas-schievink

The `diagnostics` subcommand used to only compute diagnostics for `lib.rs` / the root module of all workspace crates. This fixed it and makes it look at every module.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-04 18:39:04 +00:00
Jonas Schievink
e45ab7e0ec Fix diagnostics subcommand, look at all modules 2020-12-04 19:37:37 +01:00
bors[bot]
7efab3ed03
Merge #6723
6723: Use correct, full substs for self type in impl r=flodiebold a=flodiebold

Without arbitrary self types, the self type could never refer to the method type parameters, so this wasn't a problem; but with arbitrary self types, it can.

This fixes the crash from #6668; but it doesn't make method resolution work for these methods.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-12-04 17:44:37 +00:00
Florian Diebold
e5fd550dfd Use correct, full substs for self type in impl
Without arbitrary self types, the self type could never refer to the method type
parameters, so this wasn't a problem; but with arbitrary self types, it can.

This fixes the crash from #6668; but it doesn't make method resolution work for
these methods.
2020-12-04 18:43:47 +01:00
bors[bot]
6943b53023
Merge #6722
6722: Minor proc macro cleanups r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-04 17:09:12 +00:00
Laurențiu Nicola
72f013b3b9 Use METHOD semantic token type 2020-12-04 18:27:10 +02:00
Lukas Wirth
a1c8bdecfd Use items can also have doc comments 2020-12-04 17:09:40 +01:00
Jonas Schievink
b857149720 Unwrap process.stdio() result
If this is ever `None` here, that's a bug
2020-12-04 14:03:06 +01:00
Jonas Schievink
2845ce5bc6 Destructure in for loop 2020-12-04 13:57:33 +01:00
Jonas Schievink
c50d9f3683 Remove unnecessary Option 2020-12-04 13:54:09 +01:00
bors[bot]
b988c6f84e
Merge #6715
6715: Don't diagnose `#[cfg]` in macros r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6363

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-03 19:47:00 +00:00
Jonas Schievink
6e1c87eb92 Don't diagnose #[cfg] in macros 2020-12-03 20:46:16 +01:00
bors[bot]
070ecef249
Merge #6713
6713: Make `compile_error!` message match upstream rustc r=jonas-schievink a=jonas-schievink

It only consists of the argument passed to it.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-03 18:08:17 +00:00
Jonas Schievink
957fb18799 Make compile_error! message match upstream rustc
It only consists of the argument passed to it
2020-12-03 19:07:37 +01:00
bors[bot]
ec2bdd3c16
Merge #6712
6712: Fix proc macro token mapping r=jonas-schievink a=jonas-schievink

Diagnostics inside proc macros are currently incorrectly placed at their original offset, but inside the containing file. This fixes that, by allowing the creation of `ExpansionInfo` from non-`macro_rules!` macro invocations.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-03 17:40:18 +00:00
Jonas Schievink
3e6ffa5124 Fix proc macro token mapping 2020-12-03 18:38:05 +01:00
bors[bot]
d46fce88f5
Merge #6700
6700: More macro diagnostics improvements r=jonas-schievink a=jonas-schievink

This threads macro expansion errors through `eager.rs` and the `AsMacroCall` trait, improving macro diagnostics emitted during body lowering.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-03 16:55:15 +00:00
Jonas Schievink
bca1e5fcb8 Rename error_sink to diagnostic_sink 2020-12-03 17:54:43 +01:00
bors[bot]
74de29b223
Merge #6711
6711: cargo update: bump libloading to fix a double-free r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-12-03 15:31:36 +00:00
kjeremy
1da8726b85 cargo update: bump libloading to fix a double-free 2020-12-03 10:30:28 -05:00
bors[bot]
1d1da5ea8c
Merge #6710
6710: Extract tests module to file in ide_db crate r=matklad a=sasurau4

Helps with #6522 

- pass `cargo test`

Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2020-12-03 15:13:55 +00:00
Aleksey Kladov
3e00bfce2b Document statelessness invariant 2020-12-03 18:08:27 +03:00
Daiki Ihara
f486640682 Extract tests module to file in ide_db crate 2020-12-04 00:05:39 +09:00
Jonas Schievink
883c8d177d Make compile_error! lazy and emit a diagnostic 2020-12-03 15:48:29 +01:00
Jonas Schievink
4634bfb332 Give better diagnostic if OUT_DIR is unset 2020-12-03 15:48:29 +01:00
Jonas Schievink
17542d08b4 Update/Fix tests 2020-12-03 15:48:29 +01:00
Jonas Schievink
a634243634 Propagate eager expansion errors 2020-12-03 15:48:29 +01:00
bors[bot]
5a1306a436
Merge #6702
6702: Bump mio for safety goodness r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-12-02 21:07:28 +00:00
kjeremy
75bd5a5e20 Bump mio for safety goodness 2020-12-02 16:06:36 -05:00
bors[bot]
de9a984cbe
Merge #6701
6701: Don't prime caches when just opening a file r=jonas-schievink a=jonas-schievink

Fixes occasional "progress handler already registered" errors.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-02 19:19:19 +00:00
Jonas Schievink
6da651f5da Don't prime caches when just opening a file 2020-12-02 20:18:28 +01:00