Maan2003
c9b4ac5be4
clippy::redudant_borrow
2021-06-13 09:24:16 +05:30
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
Jade
e666589e63
Add support for lengths in array repeats, if they are literals
...
Now we will get the type of `[0u8; 4]`.
2021-05-12 21:22:46 -07:00
Jade
73023c0299
Support length for ByteStrings
...
I am not confident that my added byte string parsing is right.
2021-05-12 21:22:46 -07:00
bors[bot]
da80dfc022
Merge #8398
...
8398: Fix inference with conditionally compiled tails r=flodiebold a=DJMcNab
Fixes #8378
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2021-05-11 19:01:39 +00:00
Jonas Schievink
20ae41c1a1
Reuse database in LowerCtx
2021-05-06 23:23:50 +02:00
Jonas Schievink
976a3226fe
Don't store call-site text offsets in hygiene info
2021-05-06 19:59:54 +02:00
Daniel McNab
ebbcf9f458
Fix inference with conditionally compiled tails
...
Fixes #8378
2021-05-03 14:13:05 +01:00
Jonas Schievink
7b7d051e81
Add failing local items test
2021-04-21 17:57:45 +02:00
cynecx
cf3b4f1e20
hir_ty: Expand macros at type position
2021-04-17 16:24:56 +02:00
Jonas Schievink
ff858376aa
Include path in unresolved-macro-call
diagnostic
2021-04-16 15:48:03 +02:00
Jonas Schievink
e2c1da36f5
Support macros in pattern position
2021-04-11 01:25:50 +02:00
Jonas Schievink
053dac88ca
Update OUT_DIR
diagnostic to match setting
2021-04-07 20:19:28 +02:00
Jonas Schievink
a25fbdb30a
Intern TypeRefs stored in Body
...
Minor improvement to memory usage (1 MB or so)
2021-04-06 16:07:45 +02:00
Alexandru Macovei
32304d14a1
Use Box'es to reduce the size of hir_def::expr::Pat from 112 to 64 bytes on 64bit
2021-04-06 16:01:31 +03:00
Alexandru Macovei
fb1f544e24
Use Box'es to reduce size of hir_def::expr::Expr from 128 to 72 bytes (on 64bit systems)
...
Rationale: only a minority of variants used almost half the size.
By keeping large members (especially in Option) behind a box
the memory cost is only payed when the large variants are needed.
This reduces the size Vec<Expr> needs to allocate.
2021-04-06 16:01:31 +03:00
Jonas Schievink
9b13e1bb91
Only remember blocks that have a DefMap
2021-04-04 03:16:26 +02:00
Edwin Cheng
8ce15b02de
Fix recursive macro statement expansion
2021-03-26 04:21:15 +08:00
Lukas Wirth
64957acb5f
Fix incorrect scoping in while expressions
2021-03-21 01:28:42 +01:00
Lukas Wirth
cbd325707b
Track labels in scopes
2021-03-21 01:02:01 +01:00
Jonas Schievink
5f80364ede
Improve diagnostic when including nonexistent file
2021-03-17 21:56:09 +01:00
Jonas Schievink
cb530e7c97
Handle #[cfg]
on call arguments
2021-03-17 15:10:46 +01:00
bors[bot]
6fcb5d772f
Merge #8048
...
8048: Fix missing unresolved macro diagnostic in function body r=edwin0cheng a=brandondong
This was an issue I found while working on https://github.com/rust-analyzer/rust-analyzer/pull/7970 .
**Reproduction:**
1. Call a non-existent macro in a function body.
```
fn main() {
foo!();
}
```
2. No diagnostics are raised. An unresolved-macro-call diagnostic is expected.
3. If the macro call is instead outside of the function body, this works as expected.
I believe this worked previously and regressed in https://github.com/rust-analyzer/rust-analyzer/pull/7805 .
**Behavior prior to https://github.com/rust-analyzer/rust-analyzer/pull/7805 :**
- The unresolved-macro-call diagnostic did not exist. Instead, a macro-error diagnostic would be raised with the text "could not resolve macro [path]".
- This was implemented by adding an error to the error sink (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8L657 ).
- The error was propagated through 1a82af3527/crates/hir_def/src/body.rs (L123)
eventually reaching 1a82af3527/crates/hir_def/src/body/lower.rs (L569)
.
**Behavior after:**
- Instead of writing to the error sink, an UnresolvedMacro error is now returned (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R631 ).
- The parent caller throws away the error as its function signature is `Option<MacroCallId>` (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R604 ).
- We instead now reach the warn condition (1a82af3527/crates/hir_def/src/body.rs (L124)
) and no diagnostics are created in 1a82af3527/crates/hir_def/src/body/lower.rs (L575)
.
**Fix:**
- Make sure to propagate the UnresolvedMacro error. Report the error using the new unresolved-macro-call diagnostic.
Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-03-17 07:20:28 +00:00
Brandon
0103f5df8f
Fix missing unresolved macro diagnostic in function body
2021-03-16 00:52:58 -07:00
Edwin Cheng
8e07b23b84
Fix macro expansion for statements w/o semicolon
2021-03-16 13:44:50 +08:00
Aleksey Kladov
f7156cb0ae
Simplify source maps for fields
2021-03-15 15:38:50 +03:00
Jonas Schievink
7beec8fda1
Stop fetching ItemTrees for no reason
2021-03-10 02:32:16 +01:00
Jonas Schievink
6be4f30cae
Remove item_scope
field from Body
2021-03-09 18:27:23 +01:00
Jonas Schievink
13f4356d2f
Store inner BlockId
s in Body
2021-03-09 18:27:23 +01:00
Laurențiu Nicola
fc9eed4836
Use upstream cov-mark
2021-03-08 22:19:44 +02: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
Jonas Schievink
6990b89b26
Restrict visibilities to the containing DefMap
2021-02-28 04:47:38 +01:00
Lukas Wirth
5183c9f083
Introduce TypeCtor::Scalar
2021-02-28 01:20:04 +01:00
Jonas Schievink
7067a22e1c
Add another block def map test
2021-02-09 17:24:43 +01:00
Jonas Schievink
27f77060e2
Add TestDB::module_at_position
2021-02-09 17:22:57 +01:00
Jonas Schievink
1956286368
Add expression scopes for blocks
2021-02-09 17:11:44 +01:00
Jonas Schievink
c312ab51d0
Test super
resolution too
2021-02-05 19:25:50 +01:00
Jonas Schievink
997bd97b77
Fix resolution of self
module within blocks
2021-02-05 19:24:03 +01:00
Yoshua Wuyts
79d103d5b4
Remove redundant clones
2021-02-05 16:57:26 +01:00
Jonas Schievink
cacaebcb33
Expander: store a LocalModuleId, not ModuleId
...
It already stores the DefMap containing the module, so having
a full ModuleId is unnecessary and makes it easier to mix things up
2021-02-04 15:04:21 +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
6458f9107c
Add newline between block and crate maps
2021-02-03 18:23:59 +01:00
Jonas Schievink
63744fe128
Test for name resolution with DefMap shortcut
2021-02-03 15:33:25 +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
7eff6705cc
Use body lowering for block_def_map tests
...
Removes the hacky and buggy custom lowering code
2021-02-03 14:21:15 +01:00
Jonas Schievink
b7be2b1d3c
Use block_def_map in body lowering
2021-02-03 14:21:15 +01:00
Jonas Schievink
7202ce6c96
Revert "Use block_def_map in body lowering"
2021-02-02 11:46:58 +01:00
Jonas Schievink
80ae583dc0
Use body lowering for block_def_map tests
...
Removes the hacky and buggy custom lowering code
2021-02-01 13:33:18 +01:00
Jonas Schievink
9cc7d57429
Use block_def_map in body lowering
2021-02-01 13:33:18 +01:00
Aleksey Kladov
181590412e
add more counts
2021-01-27 12:16:24 +03:00