Commit Graph

317 Commits

Author SHA1 Message Date
Aleksey Kladov
3e5b155716 fix: avoid pathological macro expansions
Today, rust-analyzer (and rustc, and bat, and IntelliJ) fail badly on
some kinds of maliciously constructed code, like a deep sequence of
nested parenthesis.

"Who writes 100k nested parenthesis" you'd ask?

Well, in a language with macros, a run-away macro expansion might do
that (see the added tests)! Such expansion can be broad, rather than
deep, so it bypasses recursion check at the macro-expansion layer, but
triggers deep recursion in parser.

In the ideal world, the parser would just handle deeply nested structs
gracefully. We'll get there some day, but at the moment, let's try to be
simple, and just avoid expanding macros with unbalanced parenthesis in
the first place.

closes #9358
2021-08-09 16:15:02 +03:00
Aleksey Kladov
0e437c809b fix: add ! to macro completions with existing arg 2021-08-08 15:53:31 +03:00
bors[bot]
546d718a7e
Merge #9808
9808: fix: Look for enum variants and trait assoc functions when looking for lang items r=matklad a=Veykril

Examples for lang enum variants are the `Option` variants.
Assoc trait functions aren't being seen since they aren't declared in the direct module scope.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-08 10:41:45 +00:00
Lukas Wirth
50d46863ef Look for enum variants and trait assoc functions when looking for lang items 2021-08-07 22:30:13 +02:00
Alexandre Fourcat
9beefef8f9
Add completion for struct literal in which all fields are visible.
Fix ide_completion tests.

Move 'complete_record_literal' call to the main completion function.

Fix a rendering bug when snippet not available.

Checks if an expression is expected before adding completion for struct literal.

Move 'completion struct literal with private field' test to 'expressions.rs' test file.

Update 'expect' tests with new check in 'complete record literal'.
2021-08-04 18:52:58 +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
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]
da894358e1
Merge #9764
9764: fix: Don't use the module as the candidate node in fuzzy path flyimport r=Veykril a=Veykril

The problem was that the candidate node is whats being used for the scope, so using an inline module will yield the surrounding scope of the module instead of the scope of the module itself.
Also seems to fix the problem in this comment https://github.com/rust-analyzer/rust-analyzer/issues/9760#issuecomment-891125674, though I could not recreate that in a test for some reason.

Fixes #9760

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-02 18:43:02 +00:00
Lukas Wirth
e138676664 Don't use the module as the candidate node in fuzzy path flyimport 2021-08-02 19:56:32 +02:00
Aleksey Kladov
8b6ea1545f simplify 2021-08-02 14:27:11 +03:00
Aleksey Kladov
71cd67fe47 failing test 2021-08-02 14:27:11 +03:00
Lukas Wirth
1edbaa29f9 Wrap inner tail expressions in MissingOkOrSomeInTailExpr 2021-07-31 20:00:09 +02:00
Aleksey Kladov
08756012a5 internal: document query implication of completion rendering 2021-07-31 16:13:15 +03:00
Aleksey Kladov
d4e381f7b2 minor: follow code style 2021-07-31 16:05:07 +03:00
Jonas Schievink
8764cc955f Make flyimport respect #[doc(hidden)] 2021-07-28 19:22:59 +02:00
Jonas Schievink
0fbf396f0d Make most completions respect #[doc(hidden)] 2021-07-28 15:59:02 +02:00
Laurențiu Nicola
1da21b797a Fix typo 2021-07-24 11:20:40 +03:00
Jonas Schievink
c495a7374f Resolve tuple field visibility FIXME 2021-07-23 20:20:41 +02:00
Jonas Schievink
4267c38db1 Add tests for tuple struct field completion 2021-07-23 20:20:23 +02:00
Jonas Schievink
3efdf6861f Complete editable private items 2021-07-23 19:57:16 +02:00
bors[bot]
75d7da196f
Merge #9683
9683: internal: Move out expression based `unqualified_path` completion tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-23 15:07:10 +00:00
Lukas Wirth
189440c7b5 Add a Union to the base item completion test fixture 2021-07-23 17:02:39 +02:00
Jonas Schievink
c8d915e2ea Fix formatting and use Iterator::any 2021-07-23 16:45:14 +02:00
Lukas Wirth
8de3f7ee53 Move out unqualified_path completion tests 2021-07-23 16:37:19 +02:00
Lukas Wirth
ea72a5136c Add functions to base items completion test fixture 2021-07-23 16:12:09 +02:00
Jonas Schievink
b0f7aac72f Respect #[doc(hidden)] in dot-completion 2021-07-23 15:36:43 +02:00
Lukas Wirth
1f558faa8d Describe the current lifetime/label completion specifics 2021-07-22 20:18:46 +02:00
Lukas Wirth
d5947d9d48 Clarify what the outline test module is for 2021-07-22 20:03:29 +02:00
Lukas Wirth
2d696b9c9e Move out record completion tests 2021-07-22 19:38:49 +02:00
bors[bot]
0bee7cb716
Merge #9453
9453: Add first-class limits. r=matklad,lnicola a=rbartlensky

Partially fixes #9286.

This introduces a new `Limits` structure which is passed as an input
to `SourceDatabase`. This makes limits accessible almost everywhere in
the code, since most places have a database in scope.

One downside of this approach is that whenever you query limits, you
essentially do an `Arc::clone` which is less than ideal.

Let me know if I missed anything, or would like me to take a different approach!

Co-authored-by: Robert Bartlensky <bartlensky.robert@gmail.com>
2021-07-22 10:33:05 +00:00
Lukas Wirth
03efb50ae8 Move out fn_param tests 2021-07-21 21:39:40 +02:00
Lukas Wirth
9485d6efba Fix some clippy lints in ide_completion 2021-07-21 19:52:10 +02:00
Lukas Wirth
ccde0bcd1f Only complete ancestors and self in visibility path completions 2021-07-21 18:54:12 +02:00
Lukas Wirth
3956a5b757 Simplify 2021-07-21 18:34:43 +02:00
Tom Dohrmann
7b20904e8b hide keyword suggestions in non trivial paths 2021-07-21 12:53:50 +02:00
Lukas Wirth
c83e37c001 cov-mark 2021-07-20 19:00:52 +02:00
bors[bot]
33972da625
Merge #9651
9651: Restrict completions inside visibility modifiers r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-20 16:38:40 +00:00
Lukas Wirth
f6cb42fdb8 Restrict completions inside visibility modifiers 2021-07-20 18:37:52 +02:00
mahdi-frms
65839f4069 add 'use' prefix for any auto-import 2021-07-20 18:35:19 +04:30
Robert Bartlensky
0b3d0cde8b Add Limit struct.
Fixes #9286.
2021-07-19 13:26:11 +01:00
Aleksey Kladov
15f11dce4a feat: improve parser error recovery for function parameters 2021-07-17 22:41:04 +03:00
Lukas Wirth
efc96b2c60 Add regression test fo #7222 2021-07-15 22:23:34 +02:00
Lukas Wirth
317b0c2e6d Move attribute completion tests 2021-07-15 16:27:01 +02:00
Levente Gyozo Lenart
a3f0197454 Update tests 2021-07-14 18:20:01 +02:00
Levente Gyozo Lenart
a0bc236adf Add true and false as completion suggestions when expecting an expression 2021-07-14 18:19:47 +02:00
bors[bot]
87621de2b9
Merge #9567 #9568
9567: remove unneded special case r=matklad a=matklad

bors r+
🤖

9568: feat: add 'for' postfix completion r=lnicola a=mahdi-frms


![Peek 2021-07-11 16-45](https://user-images.githubusercontent.com/62165556/125194692-a0aaf780-e267-11eb-952a-81de7955d9a1.gif)


adds #9561

used ```ele``` as identifier for each element in the iteration

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
2021-07-11 12:51:33 +00:00
mahdi-frms
7bae9c9187 add 'for' postfix completion 2021-07-11 17:10:57 +04:30