Commit Graph

547 Commits

Author SHA1 Message Date
Jake Heinz
0447be7589 wip 2021-11-27 11:25:05 +00:00
bors[bot]
55b7a06888
Merge #10820
10820: minor: Move incorrect case diagnostic things into their module r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-20 16:26:50 +00:00
Lukas Wirth
69782f55de Move incorrect case diagnostic things into their module 2021-11-20 17:25:57 +01:00
Jake Heinz
7cbc6ae920 ide: hover omits unnamed where preds 2021-11-20 11:45:12 +00:00
bors[bot]
4c20d6879f
Merge #10807
10807: fix: Diagnose invalid derive attribute input r=Veykril a=Veykril

Doesn't yet diagnose incorrect syntax between the `(`, `)` braces as we discard those problems currently.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-19 12:20:13 +00:00
Lukas Wirth
ea03defeac fix: Diagnose invalid derive attribute input 2021-11-19 13:17:35 +01:00
bors[bot]
2fafe0e37c
Merge #10804
10804: fix: Diagnose using `derive` on non-adt items r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-19 11:34:22 +00:00
Lukas Wirth
6757910934 fix: Diagnose using derive on non-adt items 2021-11-19 12:10:55 +01:00
bors[bot]
bf8cf09967
Merge #10796
10796: ide: display static values in hover r=Veykril a=jhgg

Continuation from #10785 - does the same thing, but for `static`'s as well.

Co-authored-by: Jake Heinz <jh@discordapp.com>
2021-11-18 09:48:10 +00:00
bors[bot]
b844d453b2
Merge #10795
10795: Remove unwrap in doc path resolution r=Veykril a=udoprog

I keep hitting this constantly in my project, and I haven't dug very deep into the root cause. But seeing as the project otherwise compiles it appears to be something unsupported is being incorrectly parsed in rust-analyzer which for other cases is handled by returning `None`.

Co-authored-by: John-John Tedro <udoprog@tedro.se>
2021-11-18 09:40:59 +00:00
Jake Heinz
e8d0989606 ide: display static values in hover 2021-11-18 06:00:51 +00:00
John-John Tedro
76e3feeeb5 Remove unwrap in doc path resolution 2021-11-18 05:20:53 +01:00
Jake
d5de7c21b2
Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-17 09:53:24 -08:00
Jake Heinz
312eafe916 maybe this is better?? 2021-11-17 07:02:49 +00:00
Jake Heinz
4fbc4b9356 hir: show const value in hover 2021-11-17 05:49:27 +00:00
bors[bot]
add6cccd4c
Merge #10781
10781: internal: Do not use reference search in `runnables::related_tests` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-16 20:51:09 +00:00
Lukas Wirth
366499c3be Do not use reference search in runnables::related_tests 2021-11-16 21:32:02 +01:00
Lukas Wirth
f2f89618b7 minor: Simplify 2021-11-16 19:28:32 +01:00
Lukas Wirth
5c0b895f69 Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
bors[bot]
3b3063fb2d
Merge #10741
10741: internal: Flatten Definition::ModuleDef variant r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-10 23:19:44 +00:00
Lukas Wirth
7776aad166 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
Lukas Wirth
dea973089c Simplify 2021-11-10 18:26:18 +01:00
Lukas Wirth
26419c0379 Fix proc-macro attributes being shadowed by their functions in IDE layer 2021-11-08 14:49:50 +01:00
bors[bot]
726b4dd8bd
Merge #10704
10704: internal: Short-circuit `descend_into_macros_single` r=Veykril a=Veykril

There is no need to descend everything if all we are interested in is the first mapping.
This bring `descend_into_macros` timing in highlighting in `rust-analyzer/src/config.rs` from `154ms - descend_into_macros (2190 calls)` to `24ms - descend_into_macros (2190 calls)` since we use the single variant there(will regress once we want to highlight multiple namespaces again though).
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 15:06:37 +00:00
Lukas Wirth
4d768bede0 Short-circuit descend_into_macros_single 2021-11-05 16:03:45 +01:00
Lukas Wirth
addd93ed9a Don't search for root nodes unnecessarily 2021-11-05 15:52:10 +01:00
bors[bot]
274d9f90ae
Merge #10703
10703: internal: Don't check items for macro calls if they have no attributes r=Veykril a=Veykril

Turns out when highlighting we currently populate the Dynmaps of pretty much every item in a file, who would've known that would be so costly...
Shaves off 250 ms for the integrated benchmark on `rust-analyzer/src/config.rs`.

We are still looking at a heft `154ms - descend_into_macros (2190 calls)` but I feel like this is slowly nearing towards just call overhead.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 13:53:59 +00:00
Lukas Wirth
8dad1b9228 Don't check items for macro calls if they have no attributes 2021-11-05 14:50:10 +01:00
bors[bot]
d1e449e313
Merge #10701
10701: internal: Cache ast::MacroCalls to their expansions in Semantics::descend_into_macros_impl r=Veykril a=Veykril

Saves ~45ms when highlighting `rust-analyzer/src/config.rs` for me
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-05 13:26:56 +00:00
Lukas Wirth
af4d244462 Cache ast::MacroCalls to their expansions in Semantics::descend_into_macros_impl 2021-11-05 14:25:47 +01:00
Lukas Wirth
439a8194b0 Replace more Name::to_string usages with Name::to_smol_str 2021-11-04 18:12:05 +01:00
bors[bot]
a8247685cf
Merge #10686
10686: internal: Add `Semantics::original_ast_node` for upmapping nodes out of macro files r=Veykril a=Veykril

Fixes trying to insert imports into macro expanded files which then do text edits on very wrong text ranges.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 20:23:14 +00:00
Lukas Wirth
96db0d8bdd Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
Lukas Wirth
52f5af7165 Expose version string of crates fom HIR 2021-11-03 15:40:06 +01:00
Lukas Wirth
ebd63ec1cf feat: Make unqualified derive attributes flyimportable 2021-10-29 14:51:26 +02:00
Lukas Wirth
7fdbdc4ab2 Enable auto-import and qualify-path in derive attributes 2021-10-28 18:40:38 +02:00
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
Laurențiu Nicola
ca44b6892e Use array IntoIter 2021-10-22 09:23:29 +03:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00
bors[bot]
6877240fdf
Merge #10563
10563: feat: Make "Generate getter" assist use semantic info r=agluszak a=agluszak

This PR makes "Generate getter" assist use semantic info instead of dealing with types encoded as strings.
Getters for types which are:
- `Copy` no longer return references
- `AsRef<str>` (i.e. `String`) return `&str` (instead of `&String`)
- `AsRef<[T]>` (i.e. `Vec<T>`) return `&[T]` (instead of `&Vec<T>`)
- `AsRef<T>` (i.e. `Box<T>`) return `&T` (instead of `&Box<T>`)
- `Option<T>` return `Option<&T>` (instead of `&Option<T>`)
- `Result<T, E>` return `Result<&T, &E>` (instead of `&Result<T, E>`)

String, Vec, Box and Option were previously handled as special cases.

Closes #10295


Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2021-10-20 21:02:46 +00:00
Andrzej Głuszak
88e2f07826 Fixes 2021-10-20 22:35:31 +02:00
Lukas Wirth
aa9d093488 Resolve derive attributes even when shadowed 2021-10-19 13:42:36 +02:00
Andrzej Głuszak
98676efdc5 Semantic getter 2021-10-17 16:33:14 +02:00
bors[bot]
0af9d1fc8a
Merge #10546
10546: feat: Implement promote_local_to_const assist r=Veykril a=Veykril

Fixes #7692, that is now one can invoke the `extract_variable` assist on something and then follow that up with this assist to turn it into a const.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-14 19:51:34 +00:00
Lukas Wirth
06286ee90b Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
Ryan Levick
0ff89deb69 Add basic support for delegation 2021-10-13 18:05:09 +02:00
Mirko Rainer
eccfa1645b Saw a FIXME comment and decided to fix it.
This renames `descend_into_macros` to  `descend_into_macros_single` and `descend_into_macros_many` into `descend_into_macros`.
 However, this does not touch a function in `SemanticsImpl` of same name.
2021-10-12 11:52:31 -04:00
Lukas Wirth
12465a8a3c Expose HasSource::source through Semantics with caching behaviour 2021-10-07 15:00:14 +02:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00