Commit graph

110 commits

Author SHA1 Message Date
bors[bot]
eefbae7ed4
Merge #6921
6921: Higher-ranked trait bounds for where clauses r=flodiebold a=Veykril

There is a slight problem with this which is also noted in a FIXME now but `LifetimeParameters` of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-20 11:47:01 +00:00
Aleksey Kladov
f6ed16674c Align code_model name with ungrammar 2020-12-20 10:05:24 +03:00
bors[bot]
f4929fa9cc
Merge #6901
6901: Temp fixes panic caused by no ast for proc-macro r=maklad a=edwin0cheng

There are some panic when hover/goto definition for proc-macro. It is because in current design, we don't have `ast-node` for proc-macro and then it trigger [this](479d1f7eec/crates/hir/src/has_source.rs (L116)) line to panic.

This PR is a temp fix for all of these similar to bd4c352831/crates/completion/src/render/macro_.rs (L42)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-18 02:30:51 +00:00
Edwin Cheng
60a3785ac2 Temp fixes panic caused by no ast for proc-macro 2020-12-18 10:26:17 +08:00
Aleksey Kladov
30216880c4 Minor API cleanup 2020-12-17 20:14:13 +03:00
Jonas Schievink
9231821c03 Make Attrs::from_attrs_owner private 2020-12-17 15:45:26 +01:00
Lukas Wirth
c8c58d81ec Remove obsolete FIXME 2020-12-17 13:40:11 +01:00
Aleksey Kladov
2ae31e34b1 Rename ImplDef -> Impl
We used to have `Def` suffix for all symbols, but we moved off from
that. `FunctionDef` isn't better than `Function`. Looks like we've
forgot to change `Impl` though!
2020-12-17 14:36:15 +03:00
Jonas Schievink
6615fda695 decl_check: don't pass db around so often 2020-12-17 01:19:56 +01:00
Jonas Schievink
21b68a328c Remove module_lang_items
It isn't used anywhere except in `crate_lang_items`. Remove it to
slightly reduce memory usage and simplify the code.
2020-12-17 00:26:01 +01:00
bors[bot]
067067a6c1
Merge #6896
6896: Node-ify lifetimes r=jonas-schievink a=Veykril

Let's see if this passes the tests 🤞 

Depends on https://github.com/rust-analyzer/ungrammar/pull/15

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-16 17:08:03 +00:00
bors[bot]
63bbdb31e5
Merge #6897
6897: Basic support for macros 2.0 r=jonas-schievink a=jonas-schievink

This adds support for (built-in-only) macros 2.0, and removes some hacks used for builtin derives, which are declared via macros 2.0 in libcore.

First steps for https://github.com/rust-analyzer/rust-analyzer/issues/2248.

Blocked on https://github.com/rust-analyzer/ungrammar/pull/16.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-12-16 16:52:46 +00:00
Lukas Wirth
dd496223f5 Node-ify lifetimes 2020-12-16 14:16:09 +01:00
Jonas Schievink
b238ddd21a Make macro def krate mandatory
Refactors builtin derive support to go through proper name resolution
2020-12-15 20:33:05 +01:00
Jonas Schievink
c31c3246a8 Basic support for decl macros 2.0 2020-12-15 18:43:34 +01:00
bors[bot]
eb9ba457b0
Merge #6879
6879: Change HasChildSource::ChildId assoc item to generic param r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-15 17:22:03 +00:00
Lukas Wirth
2c67a4abe4 Change HasChildSource::ChildId assoc item to generic param 2020-12-15 18:21:01 +01:00
Jonas Schievink
c1cb595382 Move to upstream macro_rules! model 2020-12-15 15:37:37 +01:00
Lukas Wirth
c6172f3f6d Add LifetimeParam resolving to Semantics 2020-12-14 16:04:28 +01:00
bors[bot]
479d1f7eec
Merge #6818
6818: Add Lifetimes to the HIR r=matklad a=Veykril

This doesn't handle resolve yet as I don't know yet how that will be used. I'll get to that once I start moving the lifetime reference PR to the hir.

This also adds a new `hir` name type for lifetimes and labels, `hir::LifetimeName`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 14:35:38 +00:00
Lukas Wirth
11f8664182 Add Lifetimes to the HIR 2020-12-12 00:56:52 +01:00
Aleksey Kladov
4015ff0e0b Improve code structure
Make sure that there's only one entry point, analyze, remove awkard
analyzer2 name
2020-12-11 17:06:21 +03:00
bors[bot]
44978acf51
Merge #6769
6769: Add native "remove this semicolon" diagnostics r=matklad a=ivan770

Closes #6739 
![demo2](https://user-images.githubusercontent.com/14003886/101530533-b76c3180-399a-11eb-9d18-5c8457721655.gif)


Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2020-12-10 16:18:49 +00:00
ivan770
7738467e0a Format code 2020-12-08 19:25:21 +00:00
ivan770
cb66bb8ff9
Remove this semicolon 2020-12-08 20:47:20 +02:00
Jonas Schievink
4943ef085d Make original_range a method on InFile<&SyntaxNode> 2020-12-08 19:01:27 +01:00
Lukas Wirth
1caaa201fa Remove hir_def/docs.rs module 2020-12-07 19:58:17 +01:00
Lukas Wirth
b3652ef288 Remove documentation query 2020-12-07 19:58:17 +01:00
Jonas Schievink
b9d947cc6f Add slightly more profiling details 2020-12-04 20:26:28 +01:00
Aleksey Kladov
9d94ffad44 Place cursor correctly when completing assoc fns with self 2020-12-01 14:28:50 +03:00
Aleksey Kladov
6f51f728a1 Type-safer API for dealing with parameter lists with optional self 2020-12-01 13:53:39 +03:00
Jonas Schievink
0432aa0ed7 Publish diagnostics for macro expansion errors 2020-11-27 13:50:22 +01:00
Lukas Wirth
6501c9445e Don't use raw identifiers 2020-11-26 21:44:17 +01:00
Jonas Schievink
6a9338e979 Use ExpandResult instead of MacroResult
`MacroResult` is redundant
2020-11-26 16:48:17 +01:00
Jonas Schievink
9559bce311 Rename parse_macro to parse_macro_expansion
This does not parse macros, it expands a macro and parses the *result*
2020-11-24 21:57:51 +01:00
Jonas Schievink
d5e9bf80f9 hir_expand: propagate expansion errors 2020-11-24 19:00:23 +01:00
bors[bot]
156f7d6963
Merge #6553
6553: Auto imports in completion r=matklad a=SomeoneToIgnore

![completion](https://user-images.githubusercontent.com/2690773/99155339-ae4fb380-26bf-11eb-805a-655b1706ce70.gif)

Closes https://github.com/rust-analyzer/rust-analyzer/issues/1062 but does not handle the completion order, since it's a separate task for https://github.com/rust-analyzer/rust-analyzer/issues/4922 , https://github.com/rust-analyzer/rust-analyzer/issues/4922 and maybe something else.

2 quirks in the current implementation:

* traits are not auto imported during method completion

If I understand the current situation right, we cannot search for traits by a **part** of a method name, we need a full name with correct case to get a trait for it.

* VSCode (?) autocompletion is not as rigid as in Intellij Rust as you can notice on the animation.

Intellij is able to refresh the completions on every new symbol added, yet VS Code does not query the completions on every symbol for me.
With a few debug prints placed in RA, I've observed the following behaviour: after the first set of completion suggestions is received, next symbol input does not trigger a server request, if the completions contain this symbol.
When more symbols added, the existing completion suggestions are filtered out until none are left and only then, on the next symbol it queries for completions.
It seems like the only alternative to get an updated set of results is to manually retrigger it with Esc and Ctrl + Space.

Despite the eerie latter bullet, the completion seems to work pretty fine and fast nontheless, but if you have any ideas on how to make it more smooth, I'll gladly try it out.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-11-17 17:50:08 +00:00
Lukas Wirth
c868f0255f Fill the diagnostic code field in publish_diagnostics 2020-11-17 16:23:53 +01:00
Kirill Bulatov
4109968934 Remove query aliases 2020-11-16 21:24:54 +02:00
Kirill Bulatov
4c8edd003a Use imports_locator 2020-11-16 21:19:06 +02:00
Kirill Bulatov
f62e8616c8 Add imports in auto completion 2020-11-16 21:19:05 +02:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00
GrayJack
08e95a5dc1
Fix case where non FnOnce variables is marked callable 2020-10-26 15:20:33 -03:00
bors[bot]
2fa942ad30
Merge #6251 #6310
6251: Semantic Highlight: Add Callable modifier for variables r=matklad a=GrayJack

This PR added the `HighlightModifier::Callable` variant and assigned it to variables and parameters that are fn pointers, closures and implements FnOnce trait.

This allows to colorize these variables/parameters when used in call expression.



6310: Rewrite algo::diff to support insertion and deletion r=matklad a=Veykril

This in turn also makes `algo::diff` generate finer diffs(maybe even minimal diffs?) as insertions and deletions aren't always represented as as replacements of parent nodes now.

Required for #6287 to go on.

Co-authored-by: GrayJack <gr41.j4ck@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-23 22:12:15 +00:00
Jonas Schievink
93dc6f511b Diagnose #[cfg]s in bodies 2020-10-23 19:27:04 +02:00
Jonas Schievink
4cb3cf352f Rename UnconfiguredCode -> InactiveCode 2020-10-20 18:22:31 +02:00
Jonas Schievink
80d2741401 Add a (hint) diagnostic for unconfigured items 2020-10-20 17:53:04 +02:00
Aleksey Kladov
3b1a648539 More type safety around names 2020-10-20 17:09:03 +02:00
Aleksey Kladov
af4e75533f Rename declaration_name -> display_name
Declaration names sounds like a name of declaration -- something you
can use for analysis. It empathically isn't, and is just a label
displayed in various UI. It's important not to confuse the two, least
we accidentally mix semantics with UI (I believe, there's already a
case of this in the FamousDefs at least).
2020-10-20 15:38:11 +02:00
GrayJack
a483b5545d
Add Callable modifier for variables that implements Fnonce 2020-10-16 07:52:18 -03:00