Commit Graph

1105 Commits

Author SHA1 Message Date
Aleksey Kladov
6dafc13f5f Rename ra_text_edit -> text_edit 2020-08-12 17:03:06 +02:00
Aleksey Kladov
7510048ec0 Cleanup TextEdit API 2020-08-12 16:58:56 +02:00
Aleksey Kladov
208b7bd7ba Rename ra_prof -> profile 2020-08-12 16:35:29 +02:00
bors[bot]
1e8b2c498a
Merge #5637
5637: SSR: Matching trait associated constants, types and functions r=matklad a=davidlattimore

This fixes matching of things like `HashMap::default()` by resolving `HashMap` instead of `default` (which resolves to `Default::default`).

Same for associated constants and types that are part of a trait implementation.

However, we still don't support matching calls to trait methods.

Co-authored-by: David Lattimore <dml@google.com>
2020-08-12 13:50:34 +00:00
bors[bot]
5b8fdfe231
Merge #5553
5553: Add fix ranges for diagnostics r=matklad a=SomeoneToIgnore

A follow-up of https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Less.20red.20in.20the.20code

Now diagnostics can apply fixes in a range that's different from the range used to highlight the diagnostics.
Previous logic did not consider the fix range, having both ranges equal, which could cause a lot of red noise in the editor.
Now, the fix range gets used with the fix, the diagnostics range is used for everything else which allows to improve the error highlighting.

before:
<img width="191" alt="image" src="https://user-images.githubusercontent.com/2690773/88590727-df9a6a00-d063-11ea-97ed-9809c1c5e6e6.png">
after:
<img width="222" alt="image" src="https://user-images.githubusercontent.com/2690773/88590734-e1fcc400-d063-11ea-9b7c-25701cbd5352.png">

`MissingFields` and `MissingPatFields` diagnostics now have the fix range as `ast::RecordFieldList` of the expression with an error (as it was before this PR), and the diagnostics range as a `ast::Path` of the expression, if it's present (do you have any example of `ast::Expr::RecordLit` that has no path btw?).
The rest of the diagnostics have both ranges equal, same as it was before this PR.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-08-12 13:44:13 +00:00
bors[bot]
11de7ac2fb
Merge #4743
4743: Add tracking of packed repr, use it to highlight unsafe refs r=matklad a=Nashenas88

Taking a reference to a misaligned field on a packed struct is an
unsafe operation. Highlight that behavior. Currently, the misaligned
part isn't tracked, so this highlight is a bit too aggressive.

Fixes #4600

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
Co-authored-by: Paul Daniel Faria <paulf@pop-os.localdomain>
2020-08-12 13:20:18 +00:00
Aleksey Kladov
1c359ab634 Replace SepBy with Itertools 2020-08-12 15:04:06 +02:00
Kirill Bulatov
7543b06d30 Display snippet in the completion label 2020-08-11 22:33:17 +03:00
Kirill Bulatov
db12ccee96 Better naming and docs 2020-08-11 17:52:05 +03:00
Kirill Bulatov
188ec3459e Simplify fix structure 2020-08-11 17:13:40 +03:00
Kirill Bulatov
37aa68f050 Add rustdocs 2020-08-11 15:09:08 +03:00
Kirill Bulatov
c8cad76d25 Improve the ide diagnostics trait API 2020-08-11 15:09:08 +03:00
Kirill Bulatov
29fbc8e021 Move the DiagnosticsWithFix trait on the ide level 2020-08-11 15:09:08 +03:00
Kirill Bulatov
9368619939 Make the fix AST source Optional 2020-08-11 15:09:08 +03:00
Kirill Bulatov
9963f43d51 Refactor the diagnostics 2020-08-11 15:09:08 +03:00
Kirill Bulatov
ee1586c1ed Better naming 2020-08-11 15:09:08 +03:00
Kirill Bulatov
a61f2445cb Less stubs 2020-08-11 15:09:08 +03:00
Kirill Bulatov
21e5224484 Custom ranges for missing fields 2020-08-11 15:09:08 +03:00
Kirill Bulatov
26e102a567 Separate diagnostics and diagnostics fix ranges 2020-08-11 15:09:08 +03:00
Laurențiu Nicola
fc01c7846d Use Hygiene in completion 2020-08-11 10:09:50 +03:00
Paul Daniel Faria
72baf1acdd Remove unused import left behind after rebasing 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
2199d0cda9 Fix type names broken by rebase, redo expected test because of rebase 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
39fdd41df4 Return bool from is_unsafe_method_call and cleanup usages 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
a6af0272f7 Move semantic logic into Semantics, fix missing tag for safe amp operator, using functional methods rather than clunky inline closure 2020-08-10 08:46:34 -04:00
Paul Daniel Faria
87cb09365c Remove merge backup 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
55633f3404 Fix rebase errors 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
08182aa9fa Move unsafe packed ref logic to Semantics, use Attrs::by_key to simplify repr attr lookup 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
c5cc24cb31 Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
aca3d6c57e Deduplicate unsafe method call into a single function 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
d5f11e530d Unsafe borrow of packed fields: account for borrow through ref binding, auto ref function calls 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
38440d53d8 Cleanup repr check, fix packed repr check and test 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
c9e670b875 Update FIXME comment to be more useful 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
4a4b1f48ef Limit scope of unsafe to & instead of all ref exprs, add test showing missing support for autoref behavior 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
fd30134cf8 Remove token tree from ReprKind::Other variant, expose ReprKind higher, remove debug println. 2020-08-10 08:44:54 -04:00
Paul Daniel Faria
263f9a7f23 Add tracking of packed repr, use it to highlight unsafe refs
Taking a reference to a misaligned field on a packed struct is an
unsafe operation. Highlight that behavior. Currently, the misaligned
part isn't tracked, so this highlight is a bit too aggressive.
2020-08-10 08:44:54 -04:00
JmPotato
958b91c1e8 Better codes
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-10 17:51:45 +08:00
JmPotato
4d9c8821e5 Show const body in short_label
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-10 14:02:40 +08:00
bors[bot]
7a03f05eac
Merge #5692
5692: Add support for extern crate r=jonas-schievink a=Nashenas88

This adds syntax highlighting, hover and goto def functionality for extern crate.

Fixes #5690 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-09 23:16:58 +00:00
Paul Daniel Faria
bf9b4578bb Remove Option<...> from result of Crate::root_module
There doesn't seem to be any need for it, and removing it simplies
several paths of code that depend on it.
2020-08-09 18:52:19 -04:00
JmPotato
3f2bc813d3 format in to_proto::markup_content
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2020-08-09 21:33:14 +08:00
Paul Daniel Faria
6cde0b1aa0 Add support for extern crate
This adds syntax highlighting, hover and goto def
functionality for extern crate
2020-08-08 14:14:18 -04:00
bors[bot]
8a57afe5a4
Merge #5684
5684: Semantic highlighting for unsafe union field access r=jonas-schievink a=Nashenas88

This change adds support for unions in inference and lowering, then extends on that to add the unsafe semantic modifier on field access only. The `is_possibly_unsafe` function in `syntax_highlighting.rs` could be extended to support fns and static muts so that their definitions are not highlighted as unsafe, but only their usage.

Also, each commit of this PR updates the tests. By reviewing the files by commit, it's easy to see how the changes in the code affected the tests.

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-08-08 16:45:37 +00:00
Paul Daniel Faria
be935b2b56 Apply unsafe semantic highlighting to union field access 2020-08-08 11:29:56 -04:00
Paul Daniel Faria
3bf033e548 Add support for unions in inference and lowering 2020-08-08 11:29:56 -04:00
Paul Daniel Faria
a6532905a9 Add test for unsafe union field access highlighting 2020-08-06 21:15:31 -04:00
Paul Daniel Faria
8e657f663d Mark static mutable names as unsafe 2020-08-06 20:07:42 -04:00
Paul Daniel Faria
6be528da0d Add test for accessing static mut 2020-08-06 19:58:37 -04:00
Aleksey Kladov
09d3b7d7a2 align names in make 2020-08-05 19:37:26 +02:00
Paul Daniel Faria
4e2e3543c7 When resolving a rename, fallback to the name higher in the use tree if the path segment is self 2020-08-04 09:28:40 -04:00
Paul Daniel Faria
cc3eb85311 Add test showing unresolved module rename 2020-08-04 09:26:38 -04:00