Florian Diebold
8b3ec12aac
fix: Report proc macro errors in expressions correctly as well
...
They didn't have a krate before, resulting in the generic "proc macro
not found" error.
Also improve error messages a bit more.
2022-06-28 10:43:22 +02:00
Lukas Wirth
bdbffdd463
fix: Fix completions for locals not working properly inside macro calls
2022-06-27 14:39:44 +02:00
bitgaoshu
0dbc091fee
add test for suggest_name
2022-06-25 17:33:27 +08:00
Florian Diebold
c80c34867f
Improve proc macro errors a bit
...
Distinguish between
- there is no build data (for some reason?)
- there is build data, but the cargo package didn't build a proc macro dylib
- there is a proc macro dylib, but it didn't contain the proc macro we expected
- the name did not resolve to any macro (this is now an
unresolved_macro_call even for attributes)
I changed the handling of disabled attribute macro expansion to
immediately ignore the macro and report an unresolved_proc_macro,
because otherwise they would now result in loud unresolved_macro_call
errors. I hope this doesn't break anything.
Also try to improve error ranges for unresolved_macro_call / macro_error
by reusing the code for unresolved_proc_macro. It's not perfect but
probably better than before.
2022-06-24 13:45:19 +02:00
bitgaoshu
6ecabe352a
functions resolve to impl
2022-06-24 19:11:35 +08:00
yue4u
472ae16bfb
fix: completes non exhaustive variant within the defining crate
2022-06-24 00:00:51 +09:00
Florian Diebold
29f01cd9d2
Various cleanups
...
- remove Valid, it serves no purpose and just obscures the diff
- rename some things
- don't use is_valid_candidate when searching for impl, it's not necessary
2022-06-23 14:38:28 +02:00
bitgaoshu
1ef5e14c2c
goto where trait method impl
2022-06-23 14:01:22 +02:00
Lukas Wirth
7a0774defa
internal: Simplify some completions
2022-06-20 21:55:33 +02:00
iDawer
4ff9bedbed
Display witnesses of non-exhaustive match
...
Reporting format follows rustc and shows at most three witnesses.
2022-06-20 15:48:09 +05:00
XFFXFF
6df969f5f4
the offset used for the completion cursor should always be relative to the original file and not to the marco file
2022-06-16 20:34:37 +08:00
XFFXFF
fbf8e12234
the scope of the return type is not the body of the function
2022-06-16 16:24:18 +08:00
Lukas Wirth
0e41d15b82
Use the correct crates proc-macro loading error message
2022-06-15 18:06:33 +02:00
Lukas Wirth
7d51fc4640
Show proc-macro loading errors in unresolved-proc-macro diagnostics
2022-06-15 17:34:01 +02:00
Lukas Wirth
325ceaef19
fix: Check for the correct proc-macro settings in missing proc-macro diagnostics
2022-06-14 11:00:06 +02:00
Lukas Wirth
0e4eb647f6
More precise proc-macro errors
2022-06-12 18:44:46 +02:00
Lukas Wirth
76ae5434fa
internal: Bump Dependencies
2022-06-10 17:30:02 +02:00
Nikita Podoliako
d98c04aac1
fix(ide-db): correct single-file module rename
2022-05-28 15:07:22 +03:00
Lukas Wirth
ad537be194
fix: When reference searching macro inputs, don't search everything that was downmapped
2022-05-23 16:09:56 +02:00
Jonas Schievink
52ff863abc
Teach Callable
about closures properly
2022-05-19 18:53:08 +02:00
Jonas Schievink
f1b6e45fba
Handle getters and setters in documentation template assist
2022-05-16 19:10:38 +02:00
Lukas Wirth
6b696fced8
feat: Add binding mode inlay hints
2022-05-14 14:58:35 +02:00
Jonas Schievink
7e45915aa4
Resolve assoc. types of supertraits in the IDE layer
2022-05-09 17:30:49 +02:00
Lukas Wirth
0ce620686c
fix: Fix snippets triggering where they shouldn't
2022-05-06 15:44:41 +02:00
Lukas Wirth
0c4e23b8ef
internal: Remove unqualified_path completions module
2022-05-05 22:21:42 +02:00
bors
0218aeba7a
Auto merge of #12150 - rainy-me:feat/fix-doc-url-links, r=rainy-me
...
fix: doc url link type
fix : #12033
I did some debugging and found the cause looks like to be some doc links' `LinkType` are kept as `Shortcut` which don't make sense for url links.
This PR should resolve both problems in the origin issue, but aside this PR, more work are needed for doc_links.
about `LinkType`: f29bd1e228/src/lib.rs (L191-L210)
2022-05-05 04:54:12 +00:00
rainy-me
5f4351fbb6
fix: doc url link type
2022-05-05 00:41:29 +09:00
Benjamin Coenen
6344eea242
improve the default constructor mode when filling fields
...
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-05-04 09:45:12 +02:00
Lukas Wirth
4f97950595
fix: Fix uncorrect use of double braces in HirDisplay implementations
2022-05-02 12:39:38 +02:00
Peh
1f011fa4a3
style: rename crates to kebab case
2022-05-01 10:48:58 +00:00
Jonas Schievink
fa42888e27
Diagnose unresolved derive macros
2022-04-27 20:03:57 +02:00
bitgaoshu
5d1aff3357
#11973 associated type is unresolved
2022-04-24 20:51:48 +08:00
iDawer
d26deb5b9f
Show impl Trait
in argument positon in completion details
...
`hir`: Use `db.callable_item_signature` query more.
2022-04-16 19:18:42 +05:00
iDawer
9d787e1bfe
Add hir::Function::async_ret_type
method
...
Adjust completion detail for `async fn` return types
2022-04-16 13:53:22 +05:00
iDawer
f972adc201
fix: comletion detail shows {unknown}
for impl Trait
in return position
2022-04-16 13:41:10 +05:00
bors
e10284a10c
Auto merge of #12003 - Veykril:hir-ty-simplify, r=Veykril
...
internal: Remove duplicated crate id field from hir::Type
2022-04-15 18:25:02 +00:00
Lukas Wirth
4b4a34327e
Remove duplicated crate id field from hir::Type
2022-04-15 20:14:35 +02:00
Lukas Wirth
58660dee2a
fix: Do reference search on all downmapped tokens with the same kind only
2022-04-15 19:42:48 +02:00
Lukas Wirth
295f0c57a5
Revert #11912 as it parses all visited files
2022-04-09 13:41:06 +02:00
Lukas Wirth
9050db2e80
fix: Don't create hir::Local
s from const path patterns
2022-04-09 01:08:13 +02:00
Lukas Wirth
15e7112da3
fix: Check whether a parameter can be converted to a local
2022-04-09 00:55:45 +02:00
Jonas Schievink
5d8b4c40eb
Determine function unsafety semantically
2022-04-07 18:33:03 +02:00
bors[bot]
12f803d1e3
Merge #11925
...
11925: internal: Add and use `HirFormatter::write_{str,char}` r=Veykril a=lnicola
Saves slightly over 3 KB of `text`, but comparing the total with that from two weeks ago in #11776 , this is a losing battle (we're 951 KB larger).
```
text data bss dec hex filename
24693512 1542704 4424 26240640 1906680 rust-analyzer-baseline
24690216 1542112 4424 26236752 1905750 rust-analyzer-pr
```
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-04-07 14:38:46 +00:00
Laurențiu Nicola
bd570903b0
Add and use HirFormatter::write_{str,char}
2022-04-07 16:41:07 +03:00
Lukas Wirth
3632d5946f
minor: Remove pointless rebindings
2022-04-07 01:29:31 +02:00
Lukas Wirth
4a1423337f
fix: Attempt to resolve paths in const arguments heuristically
...
While we don't support const args in type inference yet, we can at least
make use of the fallback path resolution to resolve paths in const args
in the IDE layer to enable some features for them.
2022-04-06 20:24:24 +02:00
Lukas Wirth
7959c24876
fix: Fix path qualifiers not resolving generic type params when shadowed by trait
2022-04-06 19:38:45 +02:00
Jonas Schievink
872b7b9660
Wrap macros in expr position in MacroExpr
node
2022-04-05 17:43:34 +02:00
Lukas Wirth
c290e68ff9
internal: Remove PathResolution::AssocItem
2022-04-01 18:32:05 +02:00
Lukas Wirth
75689f2ad8
internal: Enforce Resolver to always have a module scope
2022-03-31 11:12:08 +02:00
Lukas Wirth
ef92453dfe
internal: Refactor FamousDefs builtin crate search
2022-03-30 22:23:54 +02:00
Florian Diebold
2be7e26d7d
Move mismatched-arg-count diagnostic to inference
2022-03-27 19:21:09 +02:00
hkalbasi
22eaee25b8
organize const eval tests
2022-03-24 13:20:35 +04:30
hkalbasi
0e2989e421
Support constants in const eval
2022-03-24 13:09:22 +04:30
Jonas Schievink
18ad750786
fix: properly import all types of macros with #[macro_use] again
2022-03-23 14:34:27 +01:00
bors[bot]
1a92ee5db5
Merge #11792
...
11792: minor: Bump dependencies r=Veykril a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-22 21:00:24 +00:00
Lukas Wirth
8e91bb7660
minor: Bump dependencies
2022-03-22 17:42:24 +01:00
Florian Diebold
344cf1db5f
Fix expect
2022-03-21 17:00:03 +01:00
Florian Diebold
baa43a86ab
Add a FIXME
2022-03-21 16:49:01 +01:00
Florian Diebold
2ef541b35f
Cleanups
2022-03-21 16:46:01 +01:00
Florian Diebold
0689fdb650
Add "add missing Ok/Some" fix
2022-03-21 16:46:01 +01:00
Florian Diebold
ab3313b1cb
Add new type-mismatch diagnostic
2022-03-21 16:46:01 +01:00
Florian Diebold
2d30dd67d3
Expose coercion logic in hir API
2022-03-21 16:45:59 +01:00
bors[bot]
6f2b118605
Merge #11775
...
11775: internal: Treat `global_asm` and `asm` macros as unsafe r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 18:31:27 +00:00
Lukas Wirth
ddf144051a
internal: Treat {global_}asm macros as unsafe
2022-03-20 19:31:00 +01:00
bors[bot]
fedf724d82
Merge #11774
...
11774: feat: Tag macro calls as unsafe if they expand to unsafe expressions r=Veykril a=Veykril
as long as they aren't inside an unsafe block inside the macro that is.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 18:15:29 +00:00
Lukas Wirth
68de7b30e0
feat: Tag macro calls as unsafe if they expand to unsafe expressions
2022-03-20 19:07:44 +01:00
bors[bot]
966b692422
Merge #11771
...
11771: feat: Visualize compiler inserted reborrows via inlay hints r=Veykril a=Veykril
Disabled by default.
![image](https://user-images.githubusercontent.com/3757771/159165178-baaf968a-4381-468e-933f-5326ca1b203d.png )
Closes https://github.com/rust-analyzer/rust-analyzer/issues/11275
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-20 13:47:16 +00:00
Lukas Wirth
37b48ceb8f
feat: Visualize compiler inserted reborrows via inlay hints
2022-03-20 14:38:16 +01:00
Jonas Schievink
0642724e94
Provide signature help when editing generic args
2022-03-18 19:59:41 +01:00
bors[bot]
6ad8c022ed
Merge #11750
...
11750: fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros r=Veykril a=Veykril
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11746
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-18 11:13:37 +00:00
Lukas Wirth
828196be3b
fix: Fix runnables trying to add doc tests in the crate root from #[macro_export] macros
2022-03-18 12:01:59 +01:00
Florian Diebold
9ea2e0bd5b
Fixes for consts
2022-03-17 17:04:32 +01:00
bors[bot]
683fea4de4
Merge #11707
...
11707: minor: Simplify r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-14 20:05:46 +00:00
Lukas Wirth
fbc1d2a514
Simplify
2022-03-14 20:36:35 +01:00
hkalbasi
b301b040f5
Add const generics
2022-03-14 14:38:37 +03:30
Matthias Krüger
56e4ea59d9
more clippy fixes:
...
clippy::match_like_matches_macro
clippy::to_string_in_format_args
clippy::single_char_add_str
clippy::filter_map_identity
clippy::clone_on_copy
clippy::useless_format
clippy::unused_unit
2022-03-12 16:50:49 +01:00
Matthias Krüger
21ffc5350d
fix clippy::redundant_clone
2022-03-12 16:50:49 +01:00
Matthias Krüger
d64d711db2
fix clippy::map_flatten
2022-03-12 16:50:49 +01:00
Matthias Krüger
62ed658311
fix clippy::useless_conversion
2022-03-12 16:50:49 +01:00
Matthias Krüger
7912e33ed6
fix clippy::needless_borrow
2022-03-12 16:50:49 +01:00
Lukas Wirth
301711ee71
internal: Remove ide_completion::render::build_ext module
2022-03-12 16:13:49 +01:00
Lukas Wirth
a9dd606387
fix: Show what file paths were expected for unresolved modules
2022-03-11 17:08:30 +01:00
Lukas Wirth
6c8c02f625
Don't parse source files to generate macro completion details
2022-03-10 22:21:58 +01:00
Lukas Wirth
2abe19e46a
Don't offer qualified path completions for buitlin derives
2022-03-10 21:22:13 +01:00
Lukas Wirth
a8b76b632c
Expand into pseudo-derive attribute expansions in completions
2022-03-10 20:53:50 +01:00
bors[bot]
4fcaefa62a
Merge #11660
...
11660: Insert dummy values for const generics in subst r=flodiebold a=HKalbasi
fix #11659
This is a band-aid until proper const generic support.
Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-03-09 17:18:03 +00:00
Lukas Wirth
2537ad0d9e
Simplify
2022-03-09 11:26:06 +01:00
Lukas Wirth
f9c8646d89
fix symbol index collection not collecting legacy macros
2022-03-09 01:44:20 +01:00
Lukas Wirth
4e94fb7028
Fix ProcMacroData recording wrong name for derives
2022-03-09 01:13:38 +01:00
Lukas Wirth
c37fe779c6
Add data queries for macros
2022-03-09 00:41:54 +01:00
Lukas Wirth
55ec93a337
Remove unnecessary macro_declarations from ItemScope
2022-03-09 00:19:53 +01:00
Lukas Wirth
c04b0f435b
Move hir to new MacroId
2022-03-08 23:51:48 +01:00
hkalbasi
1282178783
insert dummy values for const generics in subst
2022-03-09 02:02:42 +03:30
Lukas Wirth
93b09ca067
Update tidy ignore list
2022-03-06 19:18:40 +01:00
Lukas Wirth
c1f91c93b2
minor: Simplify
2022-03-06 17:56:02 +01:00
Lukas Wirth
d460b7c9d1
Fix extern crate self having self unresolved
2022-03-06 00:17:40 +01:00
Andy Russell
49fab593ad
show variadic args in hover function signature
2022-03-04 16:44:31 -05:00
Lukas Wirth
32bf7af83e
Support locals with multiple declaration sites
2022-03-04 19:49:08 +01:00
hkalbasi
660fd4ab41
Resolve only type params in type ns
2022-03-04 12:30:53 +03:30
hkalbasi
4fa8749c44
Preserve order of generic args
2022-03-04 11:46:14 +03:30
Lukas Wirth
47ce4436e4
Make hir::Local::name infallible
2022-02-26 16:36:44 +01:00
Florian Diebold
6fb5abbc03
Refactor autoderef and method resolution
...
- don't return the receiver type from method resolution; instead just
return the autorefs/autoderefs that happened and repeat them. This
ensures all the effects like trait obligations and whatever we learned
about type variables from derefing them are actually applied. Also, it
allows us to get rid of `decanonicalize_ty`, which was just wrong in
principle.
- Autoderef itself now directly works with an inference table. Sadly
this has the effect of making it harder to use as an iterator, often
requiring manual `while let` loops. (rustc works around this by using
inner mutability in the inference context, so that things like unifying
types don't require a unique reference.)
- We now record the adjustments (autoref/deref) for method receivers
and index expressions, which we didn't before.
- Removed the redundant crate parameter from method resolution, since
the trait_env contains the crate as well.
- in the HIR API, the methods now take a scope to determine the trait env.
`Type` carries a trait env, but I think that's probably a bad decision
because it's easy to create it with the wrong env, e.g. by using
`Adt::ty`. This mostly didn't matter so far because
`iterate_method_candidates` took a crate parameter and ignored
`self.krate`, but the trait env would still have been wrong in those
cases, which I think would give some wrong results in some edge cases.
Fixes #10058 .
2022-02-25 11:47:14 +01:00
Akshay
a5ab6a2f75
add is_slice
method to hir::Type
2022-02-24 15:20:12 +05:30
Lukas Wirth
e759db361e
Resolve functions as proc-macros via FileAstId
2022-02-23 11:21:46 +01:00
Lukas Wirth
8db88df758
simplify and document
2022-02-22 10:45:29 +01:00
Lukas Wirth
94e59c9c56
Simplify
2022-02-22 10:20:45 +01:00
Lukas Wirth
1bbef5af85
Fix syntax highlighting not highlighting derives anymore
2022-02-22 10:20:44 +01:00
Lukas Wirth
f13c98034b
Make replace_derive_with_manual_impl work again
2022-02-22 10:20:44 +01:00
Lukas Wirth
7b89d5ede2
internal: Expand the derive attribute into a pseudo expansion
2022-02-22 10:20:40 +01:00
bors[bot]
979b5b32bc
Merge #11455
...
11455: Handle proc-macro functions as the proc-macro they resolve to r=Veykril a=Veykril
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11212
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 16:56:37 +00:00
Lukas Wirth
8cdef2ffcf
fix: Don't count commas when looking for the derive attribute in diagnostics
2022-02-21 13:43:42 +01:00
Lukas Wirth
035bedc28b
internal: Remove name fields from MacroCallKind
2022-02-21 00:02:10 +01:00
Lukas Wirth
cef8a17ea5
Handle proc-macro functions as the proc-macro they resolve to
2022-02-11 22:06:03 +01:00
Lukas Wirth
661d721e20
Add completion module tailored towards use trees
2022-02-03 15:51:57 +01:00
Lukas Wirth
6940cca760
Move attribute path completions into attribute completion module
2022-02-03 15:50:14 +01:00
Florian Diebold
4ed5fe1554
Fix assoc type shorthand from method bounds
...
In code like this:
```rust
impl<T> Option<T> {
fn as_deref(&self) -> T::Target where T: Deref {}
}
```
when trying to resolve the associated type `T::Target`, we were only
looking at the bounds on the impl (where the type parameter is defined),
but the method can add additional bounds that can also be used to refer
to associated types. Hence, when resolving such an associated type, it's
not enough to just know the type parameter T, we also need to know
exactly where we are currently.
This fixes #11364 (beta apparently switched some bounds around).
2022-02-03 13:15:02 +01:00
Lukas Wirth
d7a544e69a
fix: Complete functions and methods from block level impls
2022-02-01 23:29:40 +01:00
Lukas Wirth
45ff51ba22
Make more precise range macro upmapping
2022-01-31 15:53:44 +01:00
Lukas Wirth
6194092086
Complete local fn and closure params from surrounding locals scope
2022-01-31 11:56:42 +01:00
Lukas Wirth
ddf7b70a0f
Fix cfg_attr invalidating derive identifier IDE functionality
2022-01-30 22:47:16 +01:00
Lukas Wirth
cc04cfc982
Reduce allocations in attribute collection
2022-01-30 22:18:32 +01:00
Lukas Wirth
ebd723995a
fix: don't panic in semantics due to cfg_attr
disrupting offsets
2022-01-23 17:42:38 +01:00
Jonas Schievink
8a7f0d920e
Allow macros to expand to or-patterns
2022-01-17 16:52:53 +01:00
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
bors[bot]
4705df44c7
Merge #9637
...
9637: Overhaul doc_links testing infra r=Veykril a=Veykril
and fix several issues with current implementation.
Fixes #9617
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-20 16:06:37 +00:00
Lukas Wirth
cb7b4a5d5b
Some more fragment fixes
2021-07-20 17:03:39 +02:00
Aleksey Kladov
60e7c1de83
minor: address review comments
2021-07-20 17:49:33 +03:00
Aleksey Kladov
7ec8434674
internal: remove potentially slow method
2021-07-20 17:19:58 +03:00
Aleksey Kladov
3c5827cc18
internal: remove one usage of a slow method
2021-07-20 17:11:09 +03:00
Aleksey Kladov
8e0630e728
internal: remove one usage of a slow method
2021-07-20 17:02:37 +03:00
Lukas Wirth
113beab473
Cleanup runnables canonical path impl
2021-07-20 16:00:44 +02:00
Lukas Wirth
97d63d67cd
Resolve paths to assoc items for traits
2021-07-19 20:51:57 +02:00
Aleksey Kladov
6f269708e8
internal: get rid of a call to slow O(N) visibility_of function
...
Instead of inferring module's declared visibility by looking at the
scope of its parent, let's just remeber the declared visibility in the
DefMap.
2021-07-12 21:13:43 +03:00
Lukas Wirth
c6b6f18520
Simplify Semantics::type_of_expr_with_coercion
2021-07-11 14:44:10 +02:00
bors[bot]
325140a165
Merge #9449
...
9449: feat: Emit test names in `Run test` runnables if they come from a macro expansion r=matklad a=Veykril
Fixes #8964
Before:
![Code_D1Tu5Iuh5I](https://user-images.githubusercontent.com/3757771/124174685-f552b380-daac-11eb-9086-c97db014b77c.png )
After:
![image](https://user-images.githubusercontent.com/3757771/124174493-bb81ad00-daac-11eb-96c7-3de6545a62e1.png )
Basically when a macro emits more than one test we name the test functions/modules name in the runnable instead to not emit a bunch of equally named `Run Test` annotations which don't really tell much.
Note that the `Run fibonacci_test Tests` line is below the attributes due to the fact that the function name span is being reused for the generated module in rstest's expansion.
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-11 09:37:33 +00:00
Lukas Wirth
9e1eb77f6b
Respect coercions in inline_call
2021-07-10 19:24:49 +02:00
Lukas Wirth
7e6f40b6f1
Expose coercions for patterns and expressions in semantics
2021-07-10 19:03:46 +02:00
Lukas Wirth
576e3a4e12
add_explicit_type
respects coercions
2021-07-10 18:19:46 +02:00
Lukas Wirth
f1b3446844
Emit test name in Run test runnables if it comes from a macro expansion
2021-07-09 14:35:42 +02:00
Aleksey Kladov
86720f2953
minor: drop dummy authors field
2021-07-05 14:19:41 +03:00
Lukas Wirth
f283fce594
Mark (method-)calls with never type as exit points
2021-06-23 17:21:47 +02:00
Aleksey Kladov
7be2d2f008
internal: remove one more accidentally quadratic code-path
...
Definition::visibility was implemented in a rather roundabout way -- by
asking the parent module about the effective visibility.
This is problematic for a couple of reasons:
* first, it doesn't work for local items
* second, asking module about visibility of a child is a linear
operation (that's a problem in itself, tracked in #9378 )
Instead, lets ask the declared visibility directly, we have all the code
for it, and need only to actually us it.
2021-06-22 21:26:07 +03:00
Aleksey Kladov
9526c198f6
intenral: dont export impl details
2021-06-22 16:53:53 +03:00
Aleksey Kladov
2860f25ef3
minor: extend source_to_def docs
2021-06-22 16:12:01 +03:00
Aleksey Kladov
bf9ce9e65c
internal: document source_to_def and it's connection to Kotlin&Roslyn
2021-06-22 15:31:04 +03:00
Jamie Cunliffe
ae823aa23f
Move features into potential_cfg_options
2021-06-21 17:54:05 +01:00
Jamie Cunliffe
284483b347
Improve completion of cfg attributes
...
The completion of cfg will look at the enabled cfg keys when
performing completion.
It will also look crate features when completing a feature cfg
option. A fixed list of known values for some cfg options are
provided.
For unknown keys it will look at the enabled values for that cfg key,
which means that completion will only show enabled options for those.
2021-06-21 17:47:00 +01:00
Clemens Wasser
47747cd412
Apply some clippy suggestions
2021-06-21 16:40:21 +02:00
Lukas Wirth
95c8c65139
Nest all the or-patterns!
2021-06-17 17:37:14 +02:00
Lukas Wirth
354ad29493
Filter out non-type completions in the respective completions modules instead
2021-06-16 15:08:44 +02:00