6251: Semantic Highlight: Add Callable modifier for variables r=matklad a=GrayJack
This PR added the `HighlightModifier::Callable` variant and assigned it to variables and parameters that are fn pointers, closures and implements FnOnce trait.
This allows to colorize these variables/parameters when used in call expression.
6310: Rewrite algo::diff to support insertion and deletion r=matklad a=Veykril
This in turn also makes `algo::diff` generate finer diffs(maybe even minimal diffs?) as insertions and deletions aren't always represented as as replacements of parent nodes now.
Required for #6287 to go on.
Co-authored-by: GrayJack <gr41.j4ck@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
6339: Diagnose #[cfg]s in bodies r=matklad a=jonas-schievink
This PR threads diagnostics through body lowering using the `BodySourceMap`, and emits `InactiveCode` diagnostics for expressions, statements, and match arms that are `#[cfg]`d out.
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
6336: Improve Chalk debugging r=matklad a=flodiebold
- add panic context for the trait goal if CHALK_DEBUG is set
- print the Chalk program even if we're panicking
- log goal/solution while TLS is still set
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
- add panic context for the trait goal if CHALK_DEBUG is set
- print the Chalk program even if we're panicking
- log goal/solution while TLS is still set
6324: Improve #[cfg] diagnostics r=jonas-schievink a=jonas-schievink
Unfortunately I ran into https://github.com/rust-analyzer/rust-analyzer/issues/4058 while testing this on https://github.com/nrf-rs/nrf-hal/, so I didn't see much of it in action yet, but it does seem to work.
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
6326: hide paramater inlay hints for cloned vars if applicable r=SomeoneToIgnore a=Veykril
This causes `foo.clone()` parameters to be handled as if they were just `foo` parameters for inlay hint logic.
Fixes#6315
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
6320: Textmate grammar: prevent line comments from breaking block comments (closes#6281) r=matklad a=dustypomerleau
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6281.
Previously, line comments were able to break block comments by essentially commenting out the closing `*/`, resulting in a never-ending comment. This PR splits block comments into a separate repository group to fix this problem.
Since the comment scopes also include ignored parameters and inferred types, I've added the change proposed by @bnjjj in https://github.com/rust-analyzer/rust-analyzer/pull/6317, in order to close https://github.com/rust-analyzer/rust-analyzer/issues/6311 as well.
6321: Fix opening module documentation opening parent documentation instead r=matklad a=zacps
The whole path/URL joining code is kind of ugly which is what led to
this, but at the same time I don't really want to rewrite it right
now...
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6286
Co-authored-by: Dusty Pomerleau <dustypomerleau@users.noreply.github.com>
Co-authored-by: Zac Pullar-Strecker <zacmps@gmail.com>
6307: Add whitelist of safe intrinsics r=frazar a=frazar
This PR should fix#5996, where intrinsic operations where all marked as unsafe.
I'm rather new to this codebase, so I might be doing something *very* wrong. Please forgive me!
In particular, I'm not sure how to "check that we are in extern `rust-intrinsics`" as mentioned [in this comment](https://github.com/rust-analyzer/rust-analyzer/issues/5996#issuecomment-709234802).
Co-authored-by: Francesco Zardi <frazar@users.noreply.github.com>
6172: Add qualify path assist r=matklad a=Veykril
This implements a `qualify_path` assist which works quite similar to the `auto_import` assist but instead of adding imports to the file it well, qualifies the path. This PR also moves out the `AutoImportAssets` struct and functions from `auto_import` into a utils submodule as most of this is now shared between `auto_import` and `qualify_path`.
Changes made to `AutoImportAssets` are solely in its `search_for_imports` function which now takes a prefixed parameter to discern between using `find_use_path_prefixed` and `find_use_path` as the former is the required behavior by `auto_import` and the latter by this assist.
For missing imported traits instead of importing this will qualify the path with a trait cast as in:
```rust
test_mod::TestStruct::TEST_CONST<|>
```
becomes
```rust
<test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST
```
and for trait methods ideally it would do the following:
```rust
let test_struct = test_mod::TestStruct {};
test_struct.test_meth<|>od()
```
becomes
```rust
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method(&test_struct)
```
Fixes#4124.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
6299: Diagnose items that are #[cfg]d out r=jonas-schievink a=jonas-schievink
This emits a hint-level diagnostic with `Unnecessary` tag to "gray out" any items whose `#[cfg]` attributes remove the item before name resolution.
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>