Lukas Wirth
1e66a5a8ce
Diagnose incorrect continue expressions
2022-09-01 14:41:38 +02:00
Lukas Wirth
192a79c235
Remove hir::Expr::MacroStmts
...
This hir expression isn't needed and only existed as it was simpler to
deal with at first as it gave us a direct mapping for the ast version of
the same construct. This PR removes it, properly handling the statements
that are introduced by macro call expressions.
2022-08-31 16:58:11 +02:00
bors
dea163970a
Auto merge of #12965 - DesmondWillowbrook:assoc-method-dimming, r=Veykril
...
feat: make trait assoc items become inactive due to cfg
fixes #12394
2022-08-22 07:20:56 +00:00
Kartavya Vashishtha
23c00ed50d
fix: formatting
2022-08-20 13:44:01 +05:30
Kartavya Vashishtha
87b779756c
make impl and trait inactive diagnostics work
2022-08-20 13:28:43 +05:30
bors
1da9156b0d
Auto merge of #12982 - jridgewell:into_future, r=Veykril
...
Implement IntoFuture type inference
One of my projects is using [IntoFuture](https://doc.rust-lang.org/std/future/trait.IntoFuture.html ) to make our async code a little less verbose. However, rust-analyzer can't infer the output type of an await expression if the value uses `IntoFuture` to convert into another type. So we're getting `{unknown}` types everywhere since switching.
`foo.await` itself [desugars](e4417cf020/compiler/rustc_ast_lowering/src/expr.rs (L644-L658)
) into a `match into_future(foo) {}`, with every `Future` impl getting a [default](e4417cf020/library/core/src/future/into_future.rs (L131-L139)
) `IntoFuture` implementation. I'm not sure if we want to disable the old `future_trait` paths, since this only recently [stabilize](https://github.com/rust-lang/rust/pull/98718 ).
2022-08-18 07:37:47 +00:00
Justin Ridgewell
cebf95718c
Find IntoFuture::IntoFuture's poll method
2022-08-16 17:53:10 -04:00
Jonas Schievink
dcbe892d7c
Add an HIR pretty-printer
2022-08-15 13:51:45 +02:00
Lukas Wirth
1bb58205f0
Fix panic in no_such_field when using tuple fields on record structs
2022-08-11 10:41:30 +02:00
Justin Ridgewell
dc3219bb11
Suggest .await
when type impls IntoFuture
2022-08-09 16:39:14 -04:00
Justin Ridgewell
5810c8188a
Implement IntoFuture type inference
2022-08-08 21:05:56 -04:00
bors
3805067bf5
Auto merge of #12905 - HKalbasi:master, r=Veykril
...
Generate rust type from json
fix #10118
Should this be a diagnostic? I made it a diagnostic because of issue label.
2022-08-08 11:46:22 +00:00
Lukas Wirth
8aa50e08af
Simplify
2022-08-05 14:54:14 +02:00
Lukas Wirth
352d3c6e50
Fix visibilities
2022-08-05 14:28:36 +02:00
Lukas Wirth
d6e78b04d0
feat: Handle operators like their trait functions in the IDE
2022-08-05 14:16:36 +02:00
hkalbasi
61d1c3e138
add debug impl for AnyDiagnostic
2022-07-28 22:38:20 +04:30
Lukas Wirth
e782e59d3d
fix: Calculate completions after type anchors
2022-07-28 10:06:36 +02:00
Lukas Wirth
1f8daa180f
fix: Honor ref expressions for compute_ref_match completions
2022-07-27 13:48:26 +02:00
Lukas Wirth
6c379b9f4b
fix: Fix Semantics::original_ast_node not caching the resulting file
2022-07-27 12:46:04 +02:00
Lukas Wirth
ddad2847ab
Allow name querying for derive helpers
2022-07-26 09:27:22 +02:00
Lukas Wirth
aa1491ecde
Record derive helper attributes, resolve them in IDE layer
2022-07-26 09:26:51 +02:00
Lukas Wirth
4e60db2d07
feat: Downmap tokens inside derive helpers
2022-07-26 09:26:47 +02:00
bors
0b131bc78e
Auto merge of #12849 - Veykril:no-parse, r=Veykril
...
internal: Don't parse files unnecessarily in scope_for_offset
2022-07-22 23:00:35 +00:00
Lukas Wirth
cb6703fe06
internal: Don't parse files unnecessarily in scope_for_offset
2022-07-23 00:50:59 +02:00
Lukas Wirth
1ab862a628
fix: Improve syntax highlighting in attributes
2022-07-22 17:29:03 +02:00
Amos Wenger
7e285e1ef5
Run cargo fmt
2022-07-20 15:06:15 +02:00
Amos Wenger
816f7fe12a
Run cargo fix --edition-idioms
2022-07-20 15:02:08 +02:00
Amos Wenger
23d25a3094
Enable extra warnings required by rust-lang/rust
2022-07-20 15:00:17 +02:00
bors
22e53f1d33
Auto merge of #12549 - bitgaoshu:goto_where_trait_m_impl, r=Veykril
...
feat: Go to implementation of trait methods
try goto where the trait method implies, #4558
2022-07-18 16:29:23 +00:00
bors
766c5f0861
Auto merge of #12689 - Veykril:macro-rec, r=Veykril
...
internal: Record all macro definitions in ItemScope
Fixes https://github.com/rust-lang/rust-analyzer/issues/12100
Doesn't resolve the shadowing issues though, fixing those is gonna be really tricky I believe unless we can come up with a nice scheme to "order" item tree items (using syntax ranges and file ids would be a pain and also a bad idea since that'll require us to potentially reparse files in collection).
2022-07-16 16:45:26 +00:00
bors
2e9d5b59a6
Auto merge of #12766 - Veykril:completion-vis, r=Veykril
...
fix: Don't show qualified path completions for private items
Fixes https://github.com/rust-lang/rust-analyzer/issues/12703
2022-07-16 09:29:20 +00:00
Lukas Wirth
7ff6c36716
fix: Don't show qualified path completions for private items
2022-07-15 13:30:43 +02:00
Dorian Scheidt
075ab03851
fix: Support generics in extract_function assist
...
This change attempts to resolve issue #7636 : Extract into Function does not
create a generic function with constraints when extracting generic code.
In `FunctionBody::analyze_container`, we now traverse the `ancestors` in search
of `AnyHasGenericParams`, and attach any `GenericParamList`s and `WhereClause`s
we find to the `ContainerInfo`.
Later, in `format_function`, we collect all the `GenericParam`s and
`WherePred`s from the container, and filter them to keep only types matching
`TypeParam`s used within the newly extracted function body or param list. We
can then include the new `GenericParamList` and `WhereClause` in the new
function definition.
This change only impacts `TypeParam`s. `LifetimeParam`s and `ConstParam`s are
out of scope for this change.
2022-07-13 14:54:10 -05:00
Hongxu Xu
75fb3de310
Handle generic args per arg index
...
Add more test cases for generic args
2022-07-07 00:45:22 +08:00
Hongxu Xu
0f2eba54db
Show only assoc type args in the correct arg pos
2022-07-06 22:58:27 +08:00
Lukas Wirth
db49ac8734
internal: Record all macro definitions in ItemScope
2022-07-05 11:28:47 +02:00
Laurențiu Nicola
791f2a0bec
Bump smallvec
2022-07-03 10:09:35 +03:00
Laurențiu Nicola
e6fcb23445
Bump either
2022-07-03 10:09:35 +03:00
Lukas Wirth
531e152390
fix: Simplify macro statement expansion handling
2022-07-01 14:49:30 +02:00
bors
642084093a
Auto merge of #12634 - iDawer:match-check.witnesses, r=flodiebold
...
feat: Show witnesses of non-exhaustiveness in `missing-match-arm` diagnostic
Shamelessly copied from rustc. Thus reporting format is same.
This extends public api `hir::diagnostics::MissingMatchArms` with `uncovered_patterns: String` field. It does not expose data for implementing a quick fix yet.
-----
Worth to note: current implementation does not give a comprehensive list of missing patterns. Also mentioned in [paper](http://moscova.inria.fr/~maranget/papers/warn/warn.pdf ):
> One may think that algorithm I should make an additional effort to provide more
> non-matching values, by systematically computing recursive calls on specialized
> matrices when possible, and by returning a list of all pattern vectors returned by
> recursive calls. We can first observe that it is not possible in general to supply the
> users with all non-matching values, since the signature of integers is (potentially)
> infinite.
2022-06-30 14:51:58 +00:00
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