Aleksey Kladov
107e07458c
internal: remove erroneous Default impl for ModuleOrigin
...
In rust-analyzer, we avoid defualt impls for types which don't have
sensible, "empty" defaults. In particular, we avoid using invalid
indices for defaults and similar hacks.
2021-07-12 20:00:17 +03:00
Clemens Wasser
47747cd412
Apply some clippy suggestions
2021-06-21 16:40:21 +02:00
Aleksey Kladov
5c9f31d4c2
internal: move diagnostics to hir
...
The idea here is to eventually get rid of `dyn Diagnostic` and
`DiagnosticSink` infrastructure altogether, and just have a `enum
hir::Diagnostic` instead.
The problem with `dyn Diagnostic` is that it is defined in the lowest
level of the stack (hir_expand), but is used by the highest level (ide).
As a first step, we free hir_expand and hir_def from `dyn Diagnostic`
and kick the can up to `hir_ty`, as an intermediate state. The plan is
then to move DiagnosticSink similarly to the hir crate, and, as final
third step, remove its usage from the ide.
One currently unsolved problem is testing. You can notice that the test
which checks precise diagnostic ranges, unresolved_import_in_use_tree,
was moved to the ide layer. Logically, only IDE should have the infra to
render a specific range.
At the same time, the range is determined with the data produced in
hir_def and hir crates, so this layering is rather unfortunate. Working
on hir_def shouldn't require compiling `ide` for testing.
2021-05-25 17:49:59 +03:00
Jonas Schievink
9cf8d325a2
Precompute macro fragment kind
2021-05-09 01:36:06 +02:00
Jonas Schievink
976a3226fe
Don't store call-site text offsets in hygiene info
2021-05-06 19:59:54 +02:00
Jonas Schievink
7b7d051e81
Add failing local items test
2021-04-21 17:57:45 +02:00
Jonas Schievink
ff858376aa
Include path in unresolved-macro-call
diagnostic
2021-04-16 15:48:03 +02:00
Jonas Schievink
c0dd36fd42
Store #[derive]
attribute ID along macro invoc
2021-04-09 13:38:01 +02:00
Jonas Schievink
86b7861612
Use named fields in MacroCallKind
2021-04-08 20:43:07 +02:00
Jonas Schievink
f774a56af2
Use exhaustive matches in shrink_to_fit impls
2021-04-04 02:56:11 +02:00
Jonas Schievink
d1bce6070d
Use shrink_to_fit to reduce DefMap sizes
2021-04-03 23:45:27 +02:00
Jonas Schievink
2633e23f2b
resolver: manually traverse nested block scopes
2021-03-22 18:55:51 +01:00
Jonas Schievink
54c78c96db
Rename derive-specific APIs
2021-03-19 14:23:13 +01:00
Jonas Schievink
268f45a099
Record custom derive helpers in DefMap
...
Also clean up proc macro attribute parsing a bit
2021-03-18 19:56:37 +01:00
Jonas Schievink
5fbb97a0f0
Rename item_tree
query to file_item_tree
2021-03-18 01:53:37 +01:00
Jonas Schievink
0dcec31553
Fix find_path
when inner items are present
2021-03-01 19:39:17 +01:00
Aleksey Kladov
05729fd3c4
For unresolved macros, hightlight only the last segment
2021-02-28 14:29:10 +03:00
Jonas Schievink
338823f73a
is_visible_from_def_map: handle block expressions
2021-02-23 17:56:16 +01:00
Jonas Schievink
b9c213da7a
Make with_ancestor_maps
public
2021-02-09 17:23:25 +01:00
Jonas Schievink
26a2a2433c
Don't keep the parent DefMap alive via Arc
...
This seems like it could easily leak a lot of memory since we don't
currently run GC
2021-02-04 13:44:54 +01:00
Jonas Schievink
1a8ea81a79
Split out ItemScope::dump from DefMap::dump
2021-02-03 19:05:11 +01:00
Jonas Schievink
6458f9107c
Add newline between block and crate maps
2021-02-03 18:23:59 +01:00
Jonas Schievink
d4a22fc801
Update DefMap
and block_def_map
docs
2021-02-03 17:54:03 +01:00
Jonas Schievink
da57f5dc17
Shortcut block_def_map
if there's no inner items
...
This previously didn't work, but apparently only because of the wonky
test setup
2021-02-03 15:33:25 +01:00
Jonas Schievink
5914f86d47
Fix resolution of crate
paths from within blocks
...
They resolve to the crate root, not the DefMap's root module (which
can be a block)
2021-02-02 18:02:12 +01:00
Jonas Schievink
cd9659ffce
Use the right DefMap
when looking up modules
2021-02-02 12:36:38 +01:00
Jonas Schievink
7202ce6c96
Revert "Use block_def_map in body lowering"
2021-02-02 11:46:58 +01:00
Jonas Schievink
b4aa860cac
Shortcut block_def_map
if there's no inner items
...
This previously didn't work, but apparently only because of the wonky
test setup
2021-02-01 13:33:18 +01:00
Jonas Schievink
090b2f0e50
Fix incorrect FileId
and remove broken shortcut
...
Apparently we were using the crate's root file instead of the file
containing the block.
2021-01-28 19:33:00 +01:00
Jonas Schievink
ad254f4c97
Fix legacy macro resolution in block expressions
2021-01-27 19:16:39 +01:00
Jonas Schievink
98a88ebb9e
Intern block locations and handle them in ModuleId
2021-01-25 19:02:05 +01:00
Jonas Schievink
5c241b0766
Create all ModuleId
s through a DefMap
method
...
`ModuleId` needs to be able to represent blocks, and only the
associated `DefMap` will know how to construct that `ModuleId`
2021-01-25 15:21:33 +01:00
Aleksey Kladov
e5c5c0a040
Include countme
crate to count important data structures.
2021-01-21 19:30:52 +03:00
Jonas Schievink
896dfacfc4
Add name resolution query for block expressions
2021-01-21 15:22:17 +01:00
Jonas Schievink
82146737ac
Treat BlockExpr as a potential module origin
2021-01-20 20:05:48 +01:00
Jonas Schievink
5f319ca7ee
DefMap: hide remaining crate-visible fields
2021-01-20 18:17:48 +01:00
Jonas Schievink
0587b99fde
Make public DefMap fields private
2021-01-20 15:41:18 +01:00
Jonas Schievink
57a82fb05b
Rename CrateDefMap
to DefMap
2021-01-18 20:18:05 +01:00
Aleksey Kladov
4c4e54ac8a
prepare to publish el libro de arena
2021-01-14 19:06:02 +03:00
Lukas Wirth
816190c6f6
Remove some unneeded string allocations
2020-12-31 10:13:14 +01:00
Laurențiu Nicola
42c24ff25f
Avoid a couple of allocations
2020-12-29 14:35:49 +02:00
Jonas Schievink
d171838d63
More accurately place proc-macro diagnostic
2020-11-27 16:29:40 +01:00
Jonas Schievink
0432aa0ed7
Publish diagnostics for macro expansion errors
2020-11-27 13:50:22 +01:00
Jonas Schievink
519d870c11
Don't store SyntaxNodePtr
in CrateDefMap
...
It is volatile across reparses and makes incrementality worse.
2020-11-26 17:29:09 +01:00
Jonas Schievink
3421b645e6
Emit better #[cfg] diagnostics
2020-10-22 19:19:18 +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
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
Kirill Bulatov
9d19e5b962
Properly name the field
2020-10-02 21:38:22 +03:00
Jonas Schievink
2a9a66d254
Add diagnostic types for unresolved crates/imports
2020-09-16 17:26:51 +02:00