Commit graph

209 commits

Author SHA1 Message Date
bors[bot]
f2c39d0cdf
Merge #8020
8020: Power up goto_implementation r=matklad a=Veykril

by allowing it to be invoked on references of names, now showing all (trait)
implementations of the given type in all crates instead of just the defining
crate as well as including support for builtin types

![image](https://user-images.githubusercontent.com/3757771/111144403-52bb0700-8587-11eb-9205-7a2a5b8b75a3.png)
Example screenshot of `impl`s of Box in `log`, `alloc`, `std` and the current crate. Before you had to invoke it on the definition where it would only show the `impls` in `alloc`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-15 14:08:26 +00:00
Lukas Wirth
79561b9d2e goto_implementation: Look at the entire crate graph for trait impls 2021-03-15 14:31:55 +01:00
bors[bot]
6139bd7649
Merge #8018
8018: Make Ty wrap TyKind in an Arc r=flodiebold a=flodiebold

... to further move towards Chalk.

This is a bit of a slowdown (218ginstr vs 213ginstr for inference on RA), even though it allows us to unwrap the Substs in `TyKind::Ref` etc..

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-03-15 12:51:27 +00:00
Lukas Wirth
6241567948 Speedup trait impl search for goto_implementation 2021-03-15 13:49:21 +01:00
Aleksey Kladov
f7156cb0ae Simplify source maps for fields 2021-03-15 15:38:50 +03:00
Aleksey Kladov
af2366acdf Goto definition works for S { a: } case
What happens here is that we lower `: ` to a missing expression, and
then correctly record that the corresponding field expression resolves
to a specific field. Where we fail is in the mapping of syntax to this
missing expression. Doing it via `ast_field.expr()` fails, as that
expression is `None`. Instead, we go in the opposite direcition and ask
each lowered field about its source.

This works, but has wrong complexity `O(N)` and, really, the
implementation is just too complex. We need some better management of
data here.
2021-03-15 15:12:39 +03:00
Lukas Wirth
6c782a5314 Power up goto_implementation
by allowing it to be invoked on references of names, showing all (trait)
implementations of the given type in all crates including builtin types
2021-03-15 12:10:18 +01:00
Matthias Krüger
cad617bba0 some clippy::performance fixes
use vec![] instead of Vec::new() +  push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unneccessary resizing
2021-03-15 10:19:59 +01:00
Florian Diebold
42217738e0 Don't use Substs for Ref/Raw/Array/Slice 2021-03-14 20:21:05 +01:00
Florian Diebold
1954147834 More renaming 2021-03-14 16:33:27 +01:00
Florian Diebold
3411fe3e84 Rename some fields to their Chalk names 2021-03-14 16:30:43 +01:00
Florian Diebold
3743ede404 Move type lowering methods to TyLoweringContext 2021-03-13 22:44:36 +01:00
Florian Diebold
c82d1823a1 Create TraitEnvironment through a query 2021-03-13 20:38:45 +01:00
Florian Diebold
1bf6b7360c Use chalk_ir::PlaceholderIndex 2021-03-13 19:47:34 +01:00
Florian Diebold
9719ce9fc7 Use chalk_ir::FnDefId 2021-03-13 17:56:48 +01:00
Florian Diebold
19664e276a Use chalk_ir::AssocTypeId 2021-03-13 17:56:48 +01:00
Florian Diebold
6c32bbf3ca Separate Ty and TyKind like in Chalk
Currently `Ty` just wraps `TyKind`, but this allows us to change most
places to already use `intern` / `interned`.
2021-03-13 16:17:15 +01:00
Lukas Wirth
3af69b5359 Avoid double text edits when renaming mod declaration 2021-03-10 15:49:01 +01:00
Jonas Schievink
b885e6bdee Delete ContainerId 2021-03-09 19:09:02 +01:00
Jonas Schievink
a430549aa6 Stop using ContainerId in AssocContainerId 2021-03-09 18:27:23 +01:00
bors[bot]
c45ac6effe
Merge #7942
7942: Show whether a binding is mutable or not on hover r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-09 16:23:51 +00:00
Lukas Wirth
814d617d34 Show whether a binding is mutable or not on hover 2021-03-09 17:18:50 +01:00
Aleksey Kladov
12fe301a0c Cleanup auto-ref in completion 2021-03-09 18:06:08 +03:00
bors[bot]
21913d0fdb
Merge #7873 #7933
7873: Consider unresolved qualifiers during flyimport r=matklad a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/7679

Takes unresolved qualifiers into account, providing better completions (or none, if the path is resolved or do not match).

Does not handle cases when both path qualifier and some trait has to be imported: there are many extra issues with those (such as overlapping imports, for instance) that will require large diffs to address.

Also does not do a fuzzy search on qualifier, that requires some adjustments in `import_map` for better queries and changes to the default replace range which also seems relatively big to include here.

![qualifier_completion](https://user-images.githubusercontent.com/2690773/110040808-0af8dc00-7d4c-11eb-83db-65af94e843bb.gif)


7933: Improve compilation speed r=matklad a=matklad

bors r+
🤖

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-03-09 11:58:48 +00:00
Jonas Schievink
30791c5295 Use Type::new_with_resolver_inner more 2021-03-09 12:31:16 +01:00
Kirill Bulatov
dccbb38d2e Less lifetines: derive SemanticsScope in place 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e74c55bb4a Refactor the import location 2021-03-08 23:59:20 +02:00
Kirill Bulatov
89d410cef5 Do not propose already imported imports 2021-03-08 23:59:20 +02:00
Aleksey Kladov
9faf8dd69a Hygiene is an internal implementation detail of the compiler 2021-03-08 22:14:52 +03:00
Aleksey Kladov
e346a9c5e1 Remove useless code_model indirection 2021-03-08 22:08:30 +03:00
Jonas Schievink
6750c11df3 Rename a few crate_def_maps to def_map
These could all be block `DefMap`s instead of crate-level `DefMap`s
2021-03-07 00:20:13 +01:00
Lukas Wirth
50e01d2bc7 Use chalk_ir::AdtId 2021-03-04 19:38:02 +01:00
Lukas Wirth
8d305680e6 Show docs on hover for keywords and primitives 2021-03-02 14:41:01 +01:00
Lukas Wirth
7072f59fc6 Use chalk_ir::Mutability 2021-03-01 19:57:36 +01:00
Lukas Wirth
5d121cdb45 Introduce Ty::Alias 2021-03-01 14:24:00 +01:00
Lukas Wirth
11a1f13cd1 Being Ty::InferenceVar closes to chalk equivalent 2021-03-01 12:41:29 +01:00
Lukas Wirth
407196b8c0 Lift FnPointer into a struct 2021-02-28 23:53:21 +01:00
Lukas Wirth
0e995adcf6 Turn Ty::Tuple variant into a tuple-variant 2021-02-28 20:39:43 +01:00
bors[bot]
2fc137b70f
Merge #7813
7813: Inline TypeCtor into Ty r=flodiebold a=Veykril

This removes the `ApplicationTy` variant from `Ty` bringing the representation a lot closer to chalk's `TyKind`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-02-28 19:16:51 +00:00
Lukas Wirth
faf2dd49e4 Fix code_model::Type::walk not walking all types 2021-02-28 20:15:56 +01:00
Lukas Wirth
a3f5491a1a Inline TypeCtor into Ty 2021-02-28 19:13:37 +01:00
bors[bot]
803ff2e55e
Merge #7804
7804: Introduce TypeCtor::Scalar r=lnicola a=Veykril

`TypeCtor::Int(..) | TypeCtor::Float(..) | TypeCtor::Char | TypeCtor::Bool` => `TypeCtor::Scalar(..)`, in this case we can actually just straight up use `chalk_ir::Scalar` already since its just a POD without any IDs or anything.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-02-28 13:36:44 +00:00
Aleksey Kladov
05729fd3c4 For unresolved macros, hightlight only the last segment 2021-02-28 14:29:10 +03:00
Lukas Wirth
5183c9f083 Introduce TypeCtor::Scalar 2021-02-28 01:20:04 +01:00
Lukas Wirth
0799288f01 Don't write trailing whitespace when formatting empty GenericPredicates 2021-02-20 20:43:04 +01:00
Kirill Bulatov
4fe5786c0c Consider import prefix config settings during flyimports 2021-02-20 13:53:50 +02:00
Vladyslav Katasonov
37a8cec638 expose hir::Type::type_paramters
Used to get E parameter from `Result<T, E>`
2021-02-13 22:04:52 +03:00
Jonas Schievink
216dc856c5 Wrap BuiltinType in code model 2021-02-11 19:52:33 +01:00
Lukas Wirth
a195711df0 Resolve TupleStructPat in SourceAnalyzer::resolve_path 2021-02-10 09:37:22 +01:00
Lukas Wirth
e3eeccf8ef Prefer ValueNS when resolving hir path for PathExpressions 2021-01-29 15:59:52 +01:00