Lukas Wirth
82fccb971e
feat: Add very simplistic ident completion for format_args! macro input
2022-01-15 12:23:26 +01:00
bors[bot]
fc331fe831
Merge #11282
...
11282: fix: Properly cache files in Semantics when ascending macros r=Veykril a=Veykril
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11280
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-14 10:08:27 +00:00
Lukas Wirth
f1cb5ed9b0
fix: Properly cache files in Semantics when ascending macros
2022-01-14 11:07:53 +01:00
Lukas Wirth
2f8dd64830
Replace HasSource usages with Semantics equivalent
2022-01-14 10:59:27 +01:00
Jonas Schievink
3fde9f820a
Unexport MacroDefId
from hir
2022-01-13 16:18:05 +01:00
Jonas Schievink
18e80e6892
Remove ModuleId
from hir
reexports
2022-01-12 20:21:13 +01:00
Jonas Schievink
09219e10f1
Mostly restore hir
API boundary
2022-01-12 19:56:47 +01:00
Jonas Schievink
0706de94bb
Report DefDiagnostic
s from inside item bodies
2022-01-11 14:34:25 +01:00
bors[bot]
5a711d4f3a
Merge #11210
...
11210: feat: Deprioritize ops methods in completion r=Veykril a=Veykril
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10593
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-11 09:39:12 +00:00
Lukas Wirth
ca0633c808
feat: Deprioritize ops methods in completion
2022-01-11 09:26:53 +01:00
Lukas Wirth
47591f0fb2
Remove InFile
wrapping from DynMap keys
2022-01-08 12:16:44 +01:00
Lukas Wirth
6746ba5839
Record attribute calls on assoc items in TraitData and ImplData
2022-01-08 10:45:12 +01:00
bors[bot]
41a0e95d61
Merge #11230
...
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril
Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4
fix: Fix attribute stripping ignoring doc comments
2022-01-07 18:51:10 +01:00
bors[bot]
40009e07d0
Merge #11145
...
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj
Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields
before:
```rust
pub enum Other {
One,
Two,
}
pub struct Test {
text: String,
num: usize,
other: Other,
}
fn t_test() {
let test = Test {<|>};
}
```
after:
```rust
pub enum Other {
One,
Two,
}
pub struct Test {
text: String,
num: usize,
other: Other,
}
fn t_test() {
let test = Test {
text: String::new(),
num: 0,
other: todo!(),
};
}
```
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Lukas Wirth
ca4baa6e55
Use FileAstId<ast::Adt>
in nameres where appropriate instead
2022-01-07 14:20:27 +01:00
Benjamin Coenen
f4ce0d78bb
add better default behavior on fill struct fields diagnostic
...
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-06 15:42:29 +01:00
Lukas Wirth
dc135cc076
internal: Support registered tools and attributes in ide layer
2022-01-06 14:56:50 +01:00
bors[bot]
ac3ea3e81c
Merge #11112
...
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi
cc #8655
Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-04 21:51:37 +00:00
hkalbasi
75c2acae6e
Evaluate constants in array repeat expression
2022-01-05 01:17:01 +03:30
Benjamin Coenen
336c899a07
add better default behavior on fill struct fields diagnostic
...
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04 15:59:00 +01:00
Lukas Wirth
19f1ff5c70
give resolve_derive_ident
a more robust api
2022-01-03 16:00:45 +01:00
Lukas Wirth
44b0fe8ec7
cleanup
2022-01-02 23:44:26 +01:00
Lukas Wirth
aeb5d64912
Implement ToDef for ast::Attr
2022-01-02 23:44:26 +01:00
Lukas Wirth
6b7b09d329
internal: Record unresolved derive invocations in hir
2022-01-02 23:44:23 +01:00
Lukas Wirth
762a3b3030
Fix tool module classification not working correctly
2022-01-02 23:14:18 +01:00
Lukas Wirth
44d61766b5
internal: Record unresolved derive invocations in hir
2022-01-01 20:43:25 +01:00
Aleksey Kladov
aa1788dc71
clarify semantics of doc links
2021-12-28 17:00:55 +03:00
Aleksey Kladov
177a183e85
minor: simplify
2021-12-28 16:52:15 +03:00
Aleksey Kladov
56b51852c2
minor: dedup
2021-12-28 16:52:15 +03:00
Aleksey Kladov
726da9884b
avoid speculation when completing macros
2021-12-28 16:52:15 +03:00
hkalbasi
e6139cf47b
show values of constants in hover
2021-12-23 17:53:46 +03:30
Lukas Wirth
276687a6ee
internal: Directly use self param in completions instead of searching
2021-12-22 00:18:39 +01:00
Lukas Wirth
22b2c2fdf7
Simplify
2021-12-21 14:07:48 +01:00
Lukas Wirth
8e084132f8
internal: Do less work in hir::Semantics
2021-12-21 13:38:58 +01:00
bors[bot]
8dc3a270f6
Merge #11067
...
11067: internal: Store function param names in ItemTree r=Veykril a=Veykril
This prevents us reparsing source files for completions, sometimes slowing them down massively if the source file is not cached at the expense of a slightly bigger memory usage.
related info https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Completion.20performance
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-20 14:43:39 +00:00
Lukas Wirth
cd9d76e0ca
internal: Store function param names in ItemTree
2021-12-20 15:24:37 +01:00
bors[bot]
f46731a230
Merge #11028
...
11028: Bump MSRV (1.57) r=Veykril a=iDawer
This bumps MSRV on all crates to 1.57 except `la-arena`
#10986 requires >=1.57
Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
Lukas Wirth
a574434c3f
Simplify NameClass::classify
2021-12-20 13:47:06 +01:00
Lukas Wirth
37a87708ae
internal: Don't kick off inference in Semantics::descend_into_macros_impl
2021-12-20 13:19:48 +01:00
Laurențiu Nicola
32b6f103a6
Bump chalk
2021-12-19 18:58:39 +02:00
iDawer
676744be6e
Bump MSRV (1.57)
2021-12-16 01:56:12 +05:00
Lukas Wirth
9915103c9e
Simplify
2021-12-14 12:38:20 +01:00
Lukas Wirth
749eeef3e7
fix: insert whitespaces into assoc items for assist when macro generated
2021-12-13 16:35:32 +01:00
Lukas Wirth
328419534d
Move ws insert rendering for macro expansion into ide_db
2021-12-13 15:55:13 +01:00
Lukas Wirth
1bbc255ec5
Remove some allocations
2021-12-10 20:01:24 +01:00
Lukas Wirth
c81aa68afe
Don't show trait flyimports for impl trait and placeholders
2021-12-10 19:18:21 +01:00
Jonas Schievink
b365b6119c
Treat extern blocks as item containers
2021-12-07 17:31:26 +01:00
Lukas Wirth
89e1d19ec5
internal: Prefer resolution of inert attributes
2021-12-05 16:28:08 +01:00
Lukas Wirth
1f254dd855
feat: Enable flyimport completions for attributes
2021-12-05 15:57:28 +01:00
Lukas Wirth
8da850b6d5
Improve hover message for inert attributes
2021-12-03 20:28:15 +01:00
Lukas Wirth
d174158abc
Rename things: Tool -> ToolModule
2021-12-03 17:15:19 +01:00
Lukas Wirth
70b8331fd5
Basic hover for builtin-attr and tool modules
2021-12-03 17:10:56 +01:00
Lukas Wirth
db559e5049
Simplify
2021-12-03 17:07:06 +01:00
Lukas Wirth
d1677f3286
Remove syntax highlighting hack for builtin attrs
2021-12-03 16:54:34 +01:00
Lukas Wirth
e58af219a4
feat: Resolve builtin-attr and tools in ide layer
2021-12-03 16:32:17 +01:00
Jake Heinz
fec2d39f3c
simplify??
2021-12-01 09:23:42 +00:00
Jake Heinz
a1b2d25810
hir: resolve assoc trait type
2021-12-01 08:44:30 +00:00
bors[bot]
2d0db312b5
Merge #10872
...
10872: ide_db: build symbol index from crate def map r=Veykril a=jhgg
fixes #4842 , #10764
Is this looking correct? 👀
- [x] build the symbol index based upon the CrateDefMap for the given crate in `crate_symbols`
- [x] make it multi threaded again, and figure out how to cache each moduleid's symbol index in salsa.
- [x] NavigationTarget for names in macros is wrong, need to figure out how to compute a text range in the original file id?
- [x] cleanup some duped code
- [x] collect macros from `ItemScope.declared_macros()` into symbol index.
- [x] store declared macros in `ItemScope` so we can figure out where macros were defined for the index.
- [x] do something about `SymbolIndex::for_files` - ideally it should use the new module symbol index stuff.
- [x] delete `source_file_to_file_symbols` & co...
- [x] figure out what to do about `library_symbols`
- [x] maybe... speed up the new `library_symbols` - the new impl is probably much slower, and definitely much less parallel. **deciding to do nothing here, we can optimize later if necerssary.**
- [x] fix failing test: `navigation_target::tests::test_nav_for_symbol` - notably the crate def map doesn't seem to find declarations inside function.
- [x] now a bunch of other tests are failing around auto_import & qualify_path handlers. :(
- [x] need to assoc items in traits and impls
Co-authored-by: Jake Heinz <jh@discordapp.com>
2021-11-30 14:07:39 +00:00
Jake Heinz
f0bfe310a2
add a test
2021-11-29 10:36:22 +00:00
Jake Heinz
176f4da77a
simplify work
2021-11-29 07:17:18 +00:00
Jake Heinz
1ed5699355
collect macros
2021-11-29 05:22:30 +00:00
Jake Heinz
d69e0dab56
cleanup the whole thing...
2021-11-29 03:54:52 +00:00
Jake Heinz
aecb9a378c
traverse even more...
2021-11-29 02:07:16 +00:00
Jake Heinz
8850ea0b4f
collect defs from body blocks
2021-11-29 01:09:39 +00:00
Jake Heinz
377162c0f8
container name?
2021-11-27 12:27:43 +00:00
Jake Heinz
a69af9daa3
sema parse_or_expand
2021-11-27 11:49:51 +00:00
Jake Heinz
0447be7589
wip
2021-11-27 11:25:05 +00:00
hkalbasi
30ed7fac27
Emit moniker in lsif
2021-11-22 21:29:05 +03:30
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
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo
with if foo.is_some()
2021-10-05 09:00:18 +11:00
Jonas Schievink
3aa37d7f80
Avoid cycle when lowering predicates for associated item lookup
2021-10-04 17:39:55 +02:00
Dawer
df4bb02b6f
minor: don't drop binders when doing autoderef
2021-09-30 19:57:15 +05:00
bors[bot]
629db286d1
Merge #10373
...
10373: fix: `into_iterator` not completed on `Vec<{unknown}>` r=iDawer a=iDawer
Fixes #10297
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-28 19:38:59 +00:00
Dawer
f222665ebe
fix: replace errors in a type when doing autoderef
2021-09-29 00:26:58 +05:00
Lukas Wirth
dedc2368b9
Use SmallVec<[_; 1]> in descend_into_macros_impl
2021-09-27 19:18:26 +02:00
Dawer
11aed78e2b
fix: replace errors in receiver type when iterating method candidates
2021-09-27 21:46:00 +05:00
Lukas Wirth
75660ff94f
Cleanup descend_into_macros_impl
2021-09-27 18:44:40 +02:00
Lukas Wirth
b6ed91a6de
Rename *Owner
traits to Has*
2021-09-27 12:54:24 +02:00
Lukas Wirth
a28c5d7311
Rename Dyn*
nodes to Any*
nodes
2021-09-27 12:45:36 +02:00
Aleksey Kladov
2bf81922f7
internal: more reasonable grammar for blocks
...
Consider these expples
{ 92 }
async { 92 }
'a: { 92 }
#[a] { 92 }
Previously the tree for them were
BLOCK_EXPR
{ ... }
EFFECT_EXPR
async
BLOCK_EXPR
{ ... }
EFFECT_EXPR
'a:
BLOCK_EXPR
{ ... }
BLOCK_EXPR
#[a]
{ ... }
As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357 ) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers
BLOCK_EXPR
STMT_LIST
{ ... }
BLOCK_EXPR
async
STMT_LIST
{ ... }
BLOCK_EXPR
'a:
STMT_LIST
{ ... }
BLOCK_EXPR
#[a]
STMT_LIST
{ ... }
2021-09-26 19:16:09 +03:00
Jonas Schievink
5967f3d3a9
Fix diagnostics in unnamed consts
2021-09-24 20:41:24 +02:00
Lukas Wirth
b36f12dba5
Simplify
2021-09-21 16:05:21 +02:00
Lukas Wirth
6d6e0b8f21
Generate ast nodes for each ast trait
2021-09-21 15:52:11 +02:00
Lukas Wirth
6465868449
Make inlay hints work in attributed items
2021-09-18 13:19:29 +02:00
Aleksey Kladov
73b0f9dc04
internal: remove dead code
2021-09-15 21:22:06 +03:00
Lukas Wirth
64fb7be247
Revert attributed items inlay hints
2021-09-14 20:30:28 +02:00
Lukas Wirth
0f4463e45e
fix source_to_def trying to use attribute macro calls as containers
2021-09-14 14:42:14 +02:00
Lukas Wirth
d1e489185f
Pick smaller node ancestors first when descending at offset
2021-09-14 14:10:59 +02:00
Lukas Wirth
538ac599d2
Add some more attribute ide tests
2021-09-14 03:57:29 +02:00
Lukas Wirth
e193e3b076
feat: Make inlay hints work in attributed items
2021-09-14 01:59:45 +02:00
Lukas Wirth
bb946f78f6
fix: fix expansion order for fn-like macros and attributes in token descending
2021-09-14 01:20:43 +02:00
Lukas Wirth
2b907652ee
Speculatively expand attributes in completions
2021-09-13 19:30:23 +02:00
Florian Diebold
a2d9f7d7bb
Avoid type inference panic on bitslice methods
...
Should fix #10090 , #10046 , #10179 .
This is only a workaround, but the proper fix requires some bigger
refactoring (also related to fixing #10058 ), and this at least prevents
the crash.
2021-09-12 10:49:40 +02:00
bors[bot]
317059985a
Merge #10202
...
10202: fix: Type param hover shows correct sized bounds. r=flodiebold a=iDawer
Closes #9949
This adds implicit `: Sized` bound to type parameters at lowering step.
Hovering on type parameter does not show it's `: Sized` bound be it set explicitly or implicitly. This is because it doesn't track that the bound was set implicitly.
### Perf
```rust
./target/rust-analyzer-baseline-3dae94bf -q analysis-stats --memory-usage .
Database loaded: 4.51s, 311minstr, 110mb (metadata 1.08s, 22minstr, 743kb; build 3.20s, 8730kinstr, -237kb)
crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection: 29.63s, 85ginstr, 372mb
exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference: 118.25s, 284ginstr, 601mb
Total: 147.88s, 370ginstr, 973mb
./target/rust-analyzer-hover-ty-param-dfb15292 -q analysis-stats --memory-usage .
Database loaded: 4.53s, 311minstr, 110mb (metadata 1.10s, 22minstr, 743kb; build 3.20s, 8672kinstr, -189kb)
crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection: 29.59s, 85ginstr, 372mb
exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference: 121.69s, 296ginstr, 601mb
Total: 151.28s, 382ginstr, 974mb
```
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-12 07:54:56 +00:00
Aleksey Kladov
9b2bac621e
minor: make code clearer with ControlFlow
2021-09-11 20:49:10 +03:00
Giles Cope
4ccd90af81
remove unused deps
2021-09-11 16:20:04 +01:00
Dawer
dfb15292c2
fix: Type param hover shows correct sized bounds.
2021-09-10 20:48:39 +05:00
bors[bot]
ac2520128d
Merge #10135
...
10135: minor: fix some clippy lints r=lnicola a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-03 14:28:27 +00:00
Lukas Wirth
36a5ce9790
minor: fix some clippy lints
2021-09-03 16:00:50 +02:00
Lukas Wirth
0fee14bfdd
When descending tokens don't bail on failed macro call expansions
2021-09-02 19:12:08 +02:00
Dezhi Wu
ba0947dded
switch log
crate to tracing
2021-08-30 15:11:42 +08:00
Aleksey Kladov
cfa3f679e9
internal: don't expose impl details out of hir
2021-08-29 18:55:25 +03:00
Aleksey Kladov
76b60efbfb
internal: improve compile times a bit
...
before after for cargo llvm-lines -q --lib --release -p ide_ssr | head -n 24
Lines Copies Function name
----- ------ -------------
297146 (100%) 12748 (100%) (TOTAL)
5970 (2.0%) 47 (0.4%) core::iter::traits::iterator::Iterator::try_fold
4750 (1.6%) 27 (0.2%) hashbrown::raw::RawTable<T,A>::resize
4080 (1.4%) 30 (0.2%) alloc::raw_vec::RawVec<T,A>::grow_amortized
3933 (1.3%) 69 (0.5%) alloc::raw_vec::RawVec<T,A>::current_memory
3668 (1.2%) 89 (0.7%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
3500 (1.2%) 50 (0.4%) hashbrown::raw::RawTable<T,A>::drop_elements
3436 (1.2%) 33 (0.3%) hashbrown::raw::RawTable<T,A>::find
3415 (1.1%) 17 (0.1%) hashbrown::raw::RawTable<T,A>::rehash_in_place
3400 (1.1%) 50 (0.4%) <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
2840 (1.0%) 20 (0.2%) alloc::raw_vec::RawVec<T,A>::allocate_in
2700 (0.9%) 30 (0.2%) core::alloc::layout::Layout::array
2666 (0.9%) 86 (0.7%) core::ptr::metadata::from_raw_parts_mut
2495 (0.8%) 50 (0.4%) core::option::Option<T>::map
2354 (0.8%) 38 (0.3%) alloc::alloc::box_free
2302 (0.8%) 7 (0.1%) ide_ssr::parsing::RuleBuilder::try_add
2146 (0.7%) 45 (0.4%) core::mem::replace
2070 (0.7%) 69 (0.5%) <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
1979 (0.7%) 16 (0.1%) hashbrown::map::HashMap<K,V,S,A>::insert
1926 (0.6%) 18 (0.1%) <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
1922 (0.6%) 62 (0.5%) core::fmt::ArgumentV1::new
1885 (0.6%) 13 (0.1%) alloc::raw_vec::RawVec<T,A>::shrink
Lines Copies Function name
----- ------ -------------
261717 (100%) 11666 (100%) (TOTAL)
5239 (2.0%) 42 (0.4%) core::iter::traits::iterator::Iterator::try_fold
4750 (1.8%) 27 (0.2%) hashbrown::raw::RawTable<T,A>::resize
3933 (1.5%) 69 (0.6%) alloc::raw_vec::RawVec<T,A>::current_memory
3536 (1.4%) 26 (0.2%) alloc::raw_vec::RawVec<T,A>::grow_amortized
3500 (1.3%) 50 (0.4%) hashbrown::raw::RawTable<T,A>::drop_elements
3400 (1.3%) 50 (0.4%) <hashbrown::raw::RawIterRange<T> as core::iter::traits::iterator::Iterator>::next
3124 (1.2%) 30 (0.3%) hashbrown::raw::RawTable<T,A>::find
2812 (1.1%) 14 (0.1%) hashbrown::raw::RawTable<T,A>::rehash_in_place
2604 (1.0%) 84 (0.7%) core::ptr::metadata::from_raw_parts_mut
2340 (0.9%) 26 (0.2%) core::alloc::layout::Layout::array
2302 (0.9%) 7 (0.1%) ide_ssr::parsing::RuleBuilder::try_add
2272 (0.9%) 16 (0.1%) alloc::raw_vec::RawVec<T,A>::allocate_in
2201 (0.8%) 35 (0.3%) alloc::alloc::box_free
2104 (0.8%) 44 (0.4%) core::mem::replace
2079 (0.8%) 42 (0.4%) <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
2070 (0.8%) 69 (0.6%) <alloc::raw_vec::RawVec<T,A> as core::ops::drop::Drop>::drop
1926 (0.7%) 18 (0.2%) <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::next
1885 (0.7%) 13 (0.1%) alloc::raw_vec::RawVec<T,A>::shrink
1833 (0.7%) 13 (0.1%) hashbrown::raw::RawTable<T,A>::shrink_to
1771 (0.7%) 91 (0.8%) core::ptr::read
1701 (0.6%) 35 (0.3%) core::option::Option<T>::map
2021-08-29 18:49:16 +03:00
Lukas Wirth
6993a607cb
Simplify
2021-08-29 01:38:10 +02:00
Lukas Wirth
99f1e66997
Only report unique text ranges in highlight_related
2021-08-29 01:11:29 +02:00
Lukas Wirth
72bfbb0691
Return all usages inside macros in usage searches
2021-08-29 00:49:57 +02:00
Lukas Wirth
512135920d
Highlight all related tokens in macro inputs
2021-08-29 00:49:57 +02:00
Lukas Wirth
c5059e0623
Return all ranges corresponding to a token id in TokenMap
2021-08-29 00:49:57 +02:00
Jonas Schievink
3047ae8d0f
Enable diagnostics in const
and static
items
2021-08-27 23:21:21 +02:00
bors[bot]
97409e5fc8
Merge #9970
...
9970: feat: Implement attribute input token mapping, fix attribute item token mapping r=Veykril a=Veykril
![image](https://user-images.githubusercontent.com/3757771/130328577-4c1ad72c-51b1-47c3-8d3d-3242ec44a355.png )
The token mapping for items with attributes got overwritten partially by the attributes non-item input, since attributes have two different inputs, the item and the direct input both.
This PR gives attributes a second TokenMap for its direct input. We now shift all normal input IDs by the item input maximum(we maybe wanna swap this see below) similar to what we do for macro-rules/def. For mapping down we then have to figure out whether we are inside the direct attribute input or its item input to pick the appropriate mapping which can be done with some token range comparisons.
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9867
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-27 19:30:36 +00:00
Lukas Wirth
0f3617f76f
fix: Fix multiple derives in one attribute not expanding all in expand_macro
2021-08-26 03:32:45 +02:00
Lukas Wirth
d99b81f839
Expand derive macros under cursor in Expand Macro Recursively
2021-08-24 16:33:52 +02:00
Frank Steffahn
3a5a93595f
Fix typos “a”→“an”
2021-08-22 14:31:37 +02:00
Lukas Wirth
2f179adc41
Expand attributes recursively in expand_macro
2021-08-21 23:24:12 +02:00
Lukas Wirth
177c70128c
Map attribute input tokens correctly
2021-08-21 18:13:41 +02:00
Lukas Wirth
557df6ff3f
Use correct HirFileId in find_related_test
2021-08-20 13:50:40 +02:00
Laurențiu Nicola
c9f448a834
Fix some clippy lints
2021-08-16 22:04:26 +03:00
Lukas Wirth
0336e9b25f
Flatten SourceToDefCache structure
2021-08-16 17:55:18 +02:00
Lukas Wirth
c90ecc5c26
Only add entries to SourceToDef dynmaps when they come from the same file
2021-08-16 17:07:25 +02:00
Lukas Wirth
0c0142f61a
Simplify
2021-08-16 16:12:20 +02:00
Lukas Wirth
37ad9cb2a5
Don't use non cache syntaxnodes in generate_function for lookups
2021-08-14 17:51:11 +02:00
bors[bot]
baf1494374
Merge #9807
...
9807: Implicit `Sized` bounds r=iDawer a=iDawer
This should close #8984
`hir_ty`:
- Type parameters, associated types and `impl Trait` are `Sized` by deafault except `Self` in a trait.
- Implicit `Sized` bound is added to end of predicate list. It does not check if such bound is present already. Also it does not track the bound is implicit.
- Allowed ambiguous unsize coercion if Chalk returns definite guidance.
- Allowed ambiguous autoderef if Chalk returns definite guidance.
`hir_def`:
- `ItemTree` pretty printing shows `?Sized` bounds.
`HirDisplay`:
- `impl Trait` with weird bounds rendered correctly.
- `Sized`/`?Sized` bounds are not shown if they are default.
### Perf
`./target/rust-analyzer-baseline_8a843113 -q analysis-stats --memory-usage .`
```
Database loaded: 1.63s, 287minstr, 91mb
crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection: 26.80s, 73ginstr, 338mb
exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 174
Inference: 50.28s, 116ginstr, 516mb
Total: 77.08s, 189ginstr, 855mb
```
`./target/rust-analyzer-sized-fixed_ambig_coercion-de074fe6 -q analysis-stats --memory-usage .`
```
Database loaded: 1.63s, 287minstr, 91mb
crates: 38, mods: 741, decls: 15914, fns: 11835
Item Collection: 26.95s, 73ginstr, 338mb
exprs: 318994, ??ty: 398 (0%), ?ty: 435 (0%), !ty: 166
Inference: 96.39s, 234ginstr, 543mb
Total: 123.33s, 307ginstr, 881mb
```
Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-08-12 17:55:29 +00:00
Yoshua Wuyts
d6b788a9ee
Add trait codegen to add_missing_impl_members
assist
2021-08-10 10:27:52 +02:00
ivan770
be3e70c604
Add reference here diagnostic
2021-08-08 10:12:40 +02:00
bors[bot]
950efff5c6
Merge #9780
...
9780: Support exclusive_range_pattern r=matklad a=lf-
Fix #9779
Co-authored-by: Jade <software@lfcode.ca>
2021-08-04 18:12:37 +00:00
Dawer
5f2486e9a8
Handle impl ?Sized
. Fix tests.
2021-08-04 20:20:10 +05:00
Dawer
421979bc68
HirDisplay prints ?Sized
bounds now; impl Trait: Sized
by default.
2021-08-04 20:05:46 +05:00
Dawer
3981373b93
internal: add implicit Sized
bounds to type parameters.
2021-08-04 19:04:21 +05:00
bors[bot]
1b02cafa43
Merge #9734
...
9734: semantic highlighting: add reference hlmod r=matklad a=jhgg
This PR adds the "reference" highlight modifier!
I basically went around and looked for `HlMod::Mutable` to find the callsites to add a reference. I think these all make sense!
Co-authored-by: Jake Heinz <jh@discordapp.com>
Co-authored-by: Jake <jh@discordapp.com>
2021-08-04 09:37:30 +00:00
Jake Heinz
44726b6ca3
fix + update expects
2021-08-04 06:12:41 +00:00
Jake
e01ff775ae
Apply suggestions from code review
...
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 23:07:46 -07:00
Jade
e3a67ccec6
tree-wide: fix rustdoc warnings, add some links
2021-08-03 21:34:20 -07:00
bors[bot]
8a8431133e
Merge #9775
...
9775: internal: extract_assist is aware of the expression owner r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 18:48:43 +00:00
Lukas Wirth
29c4ae6f9a
extract_assist
is aware of the expression owner
2021-08-03 20:47:51 +02:00
bors[bot]
00c8cab20b
Merge #9765
...
9765: internal: Introduce TypeInfo r=Veykril a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-03 15:32:51 +00:00
Lukas Wirth
b96f1adf5c
Give TypeInfo fields and methods more appropriate names
2021-08-03 17:28:51 +02:00
Lukas Wirth
8afa2722b2
Revise TypeInfo::ty usage
2021-08-03 17:24:43 +02:00
Lukas Wirth
25ff7171c4
Introduce TypeInfo
2021-08-03 16:41:53 +02:00
bors[bot]
4b0c97668c
Merge #9772
...
9772: feat: filter out duplicate macro completions r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-03 14:37:25 +00:00
Aleksey Kladov
2f9273633b
feat: filter out duplicate macro completions
...
closes #9303
2021-08-03 17:36:06 +03:00
bors[bot]
cae54d86d8
Merge #9761
...
9761: feat: Show coerced types on type hover r=Veykril a=Veykril
This applies to both the ranged hover request as well as the normal hover type fallback.
![image](https://user-images.githubusercontent.com/3757771/127883884-2935b624-a3e5-4f35-861a-7d6d3266d187.png )
![image](https://user-images.githubusercontent.com/3757771/127883951-4ff96b6b-7576-4886-887b-1198c1121841.png )
We unfortunately have to leave out syntax highlighting here as otherwise the `Type` and `Coerced` words in the hover will get colored.
Note that this does not show all the coercions yet(and almost no pattern coercions) as not all coercion adjustments are implemented yet.
Closes https://github.com/rust-analyzer/rust-analyzer/issues/2677
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 15:44:43 +00:00
Lukas Wirth
486603d559
Show coerced types on type hover
2021-08-02 17:10:36 +02:00
bors[bot]
0d56ff2a02
Merge #9758
...
9758: internal: explain that we don't `ref` in style.md r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-08-02 13:00:07 +00:00
Aleksey Kladov
12d7f5b56e
internal: explain that we don't ref
in style.md
2021-08-02 15:59:28 +03:00
Lukas Wirth
62ab73767f
resolve_doc_path is able to resolve to macros
2021-08-02 14:33:09 +02:00
Lukas Wirth
1edbaa29f9
Wrap inner tail expressions in MissingOkOrSomeInTailExpr
2021-07-31 20:00:09 +02:00
Jake Heinz
2baef17bb1
semantic highlighting: add reference hlmod
2021-07-31 04:42:47 +00:00
Jonas Schievink
8764cc955f
Make flyimport respect #[doc(hidden)]
2021-07-28 19:22:59 +02:00
Jonas Schievink
18f86baa62
Stop reexporting hir_def
's ItemInNs
from HIR
2021-07-28 17:39:04 +02:00
Jonas Schievink
0fbf396f0d
Make most completions respect #[doc(hidden)]
2021-07-28 15:59:02 +02:00
Jonas Schievink
b0f7aac72f
Respect #[doc(hidden)]
in dot-completion
2021-07-23 15:36:43 +02:00