Commit Graph

627 Commits

Author SHA1 Message Date
bors[bot]
3f53a5dd72
Merge #9245
9245: internal: start new diagnostics API r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-13 11:56:15 +00:00
Aleksey Kladov
efa069d288 internal: start new diagnostics API
At the moment, this moves only a single diagnostic, but the idea is
reafactor the rest to use the same pattern. We are going to have a
single file per diagnostic. This file will define diagnostics code,
rendering range and fixes, if any. It'll also have all of the tests.
This is similar to how we deal with assists.

After we refactor all diagnostics to follow this pattern, we'll probably
move them to a new `ide_diagnostics` crate.

Not that we intentionally want to test all diagnostics on this layer,
despite the fact that they are generally emitted in the guts on the
compiler. Diagnostics care to much about the end presentation
details/fixes to be worth-while "unit" testing. So, we'll unit-test only
the primary output of compilation process (types and name res tables),
and will use integrated UI tests for diagnostics.
2021-06-13 14:55:45 +03:00
bors[bot]
be9742809c
Merge #9244
9244: feat: Make block-local trait impls work r=flodiebold a=flodiebold

As long as either the trait or the implementing type are defined in the same block.

CC #8961

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-06-13 11:13:31 +00:00
Florian Diebold
5ca71a1990 Make block-local trait impls work
As long as either the trait or the implementing type are defined in the
same block.
2021-06-13 13:00:34 +02:00
Aleksey Kladov
546be18e3a internal: check that coverage marks are always paired 2021-06-13 13:13:26 +03:00
Maan2003
5ac6804bb3
cargo fmt 2021-06-13 09:48:15 +05:30
Maan2003
c50b4579ec
clippy::useless_return 2021-06-13 09:35:29 +05:30
Maan2003
75370312fb
clippy::redundant_closure 2021-06-13 09:29:36 +05:30
Maan2003
705f7e6e26
clippy::clone_on_copy 2021-06-13 09:27:19 +05:30
Maan2003
6cc6dee9e9
clippy::useless_conversion 2021-06-13 09:25:55 +05:30
Maan2003
c9b4ac5be4
clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
Aleksey Kladov
0463d76a1f internal: cross-crate cov-marks 2021-06-12 23:40:52 +03:00
Jonas Schievink
99d40e7a3a Don't stringify cfg_attr-gated attributes
This preserves the assigned `TokenId`s
2021-06-11 18:34:30 +02:00
Kirill Bulatov
690cd95327 Reduce fst_path calls 2021-06-11 00:10:09 +03:00
Kirill Bulatov
3aaf07b8cb Add more profiling for flyimports 2021-06-10 23:43:46 +03:00
Lukas Wirth
ae8d74ab2c Implement dummy expansions for builtin attributes 2021-06-09 18:27:08 +02:00
bors[bot]
2f376f7475
Merge #9169
9169: internal: steps towards attribute macro token mapping r=jonas-schievink a=jonas-schievink

This doesn't work yet, but we seem to be getting a bit further along (for example, we now stop highlighting `use` items inside item with attribute macros as if they were written verbatim).

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-07 17:37:48 +00:00
Laurențiu Nicola
15dd475988 Make Documentation::new non-generic 2021-06-07 12:58:51 +03:00
Jonas Schievink
8d87f9b298 Handle attribute macros in descend_into_macros 2021-06-06 17:03:37 +02:00
Lukas Wirth
7524850831 Render documentation for derive completion 2021-06-04 20:58:12 +02:00
Jonas Schievink
20de86d014 Return ReachedFixedPoint::No when resolving derive helper 2021-06-04 16:50:35 +02:00
Jonas Schievink
d1c4d28eed Update list of built-in attributes 2021-06-03 18:09:21 +02:00
Jonas Schievink
9fdb8f9037 Make it opt-in 2021-06-03 18:09:21 +02:00
Jonas Schievink
e5a2c6596d Expand procedural attribute macros 2021-06-03 18:09:21 +02:00
Matthias Krüger
9452dfaac7 NFC: remove redundant clones (clippy::perf) 2021-06-03 15:32:46 +02:00
Jonas Schievink
28e3e683b2 ItemTree: make variant fields inherit the enum's visibility 2021-06-03 14:26:26 +02:00
Jonas Schievink
70e19fd1cb Add comment 2021-06-03 13:51:43 +02:00
Jonas Schievink
955064b6aa Implement #[rustc_skip_array_during_method_dispatch] 2021-06-01 21:34:08 +02:00
Jonas Schievink
41321fa71d Fall back to legacy prelude 2021-06-01 19:03:00 +02:00
Jonas Schievink
f96c1a0414 Implement per-edition preludes 2021-06-01 13:39:19 +02:00
Dawer
e7c49666be Expand fixme comments 2021-06-01 01:44:51 +05:00
Dawer
466345ca81 Clean up, more docs. 2021-06-01 00:08:27 +05:00
Dawer
678d85ca7e Implement struct ctor application 2021-06-01 00:03:46 +05:00
bors[bot]
e9a797748d
Merge #8866
8866: Update salsa r=matklad a=jonas-schievink

This updates salsa to include https://github.com/salsa-rs/salsa/pull/265, and removes all cancellation-related code from rust-analyzer

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-31 12:42:32 +00:00
Jonas Schievink
cb5454db86 Diagnose unimplemented built-in macros 2021-05-30 04:19:47 +02:00
Jonas Schievink
8c639a87bd Thread proc-macro types through the HIR 2021-05-29 20:32:57 +02:00
cynecx
54d60fdee9 hir_ty: use async ret type for inference inside async bodies 2021-05-29 18:17:45 +02:00
Jonas Schievink
55f3ca2b74 Test that ItemTree works as intended 2021-05-28 00:46:05 +02:00
Laurențiu Nicola
2268a220e4 Don't store supertraits in ItemTree 2021-05-27 16:52:30 +03:00
Jonas Schievink
33debc4065 Update salsa 2021-05-27 15:05:41 +02:00
Jonas Schievink
196cb65ead Drop ignore from doctests 2021-05-27 13:55:31 +02:00
Jonas Schievink
fe910c7bc4 Reduce memory usage a bit 2021-05-26 01:26:16 +02:00
Jonas Schievink
356dd3d909 Clean up ItemTree lowering now that it's 1:1 2021-05-26 01:09:31 +02:00
Jonas Schievink
b52df91877 Stop expanding UseTrees during ItemTree lowering 2021-05-26 01:01:58 +02:00
bors[bot]
5587d0a3e3
Merge #8973
8973: internal: move diagnostics to hir r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-25 20:33:21 +00: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
Lukas Wirth
28ca371755 Consider trait to be in scope for trait-impl 2021-05-25 16:16:29 +02:00
Florian Diebold
35c948ff4a Fix lowering of FnOnce() without return type
This should result in an implicit `-> ()`, not leaving out the binding.
2021-05-25 14:29:53 +02:00
Jonas Schievink
31175a7f88 internal: intern AttrInput 2021-05-25 00:50:19 +02:00
Jonas Schievink
533e9207d3 Intern GenericArgs
This shaves off another ~4 mb or so
2021-05-24 15:35:46 +02:00
Jonas Schievink
8ebb8d29e1 internal: intern TypeBounds
Doesn't save much memory (~2 mb), but interning things is generally a
good pattern to follow
2021-05-24 15:13:23 +02:00
bors[bot]
495c9586ec
Merge #8945
8945: fix: Make expected type work in more situations r=flodiebold a=flodiebold

Also makes call info show the correct types for generic methods.

![2021-05-23-182952_1134x616_scrot](https://user-images.githubusercontent.com/906069/119269023-dd5a5b00-bbf5-11eb-993a-b6e122c3b9a6.png)
![2021-05-23-183117_922x696_scrot](https://user-images.githubusercontent.com/906069/119269025-dfbcb500-bbf5-11eb-983c-fc415b8428e0.png)


Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-05-23 21:55:51 +00:00
Jonas Schievink
693325fc39 internal: document ItemTree design 2021-05-23 23:09:38 +02:00
Florian Diebold
7a0c93c58a Infer correct expected type for generic struct fields 2021-05-23 18:45:44 +02:00
Jonas Schievink
11825ac5fe Explain why nested TypeRef aren't interned 2021-05-23 16:28:23 +02:00
Jonas Schievink
15ff7faf3d Render where clauses and more generic params 2021-05-23 02:51:58 +02:00
Jonas Schievink
380293d6c2 Pretty-print generic parameters 2021-05-23 01:15:26 +02:00
Jonas Schievink
c22ccd07fe ItemTree: pretty-print all paths 2021-05-23 00:37:15 +02:00
Jonas Schievink
d077b8a7e0 Work around non-unique AttrIds 2021-05-22 02:30:03 +02:00
Jonas Schievink
8d13864440 Add an ItemTree pretty-printer 2021-05-21 23:45:27 +02:00
Jonas Schievink
01df4c04d1 impl Display for AttrInput/ImportAlias 2021-05-21 23:45:09 +02:00
Jonas Schievink
45f4a1e559 Remove StructDefKind 2021-05-21 21:08:06 +02:00
Jonas Schievink
d00bc9c2fc Don't lower extern block in the ItemTree 2021-05-21 18:27:25 +02:00
Jonas Schievink
6f19484c93 Support #[register_attr] and #[register_tool] 2021-05-20 20:40:02 +02:00
Jonas Schievink
df824c2f81 Rename ignore_attrs_on to skip_attrs 2021-05-20 20:18:53 +02:00
Jonas Schievink
9ac5a90522 Simplify 2021-05-20 20:08:39 +02:00
Jonas Schievink
036e5b2806 Refactor name resolution to resolve derive helpers 2021-05-20 19:56:04 +02:00
Jonas Schievink
f088606d89 Rename unexpanded_macros to unresolved_macros 2021-05-20 13:12:29 +02:00
Jonas Schievink
d4eb6708d9 Track in-scope derive helpers during nameres 2021-05-19 23:35:09 +02:00
Jonas Schievink
4a84c3fb21 Fix unresolved attribute fallback again 2021-05-19 22:08:34 +02:00
bors[bot]
49922cb2c3
Merge #8885 #8887
8885: internal: greatly simplify eager macro representation r=jonas-schievink a=jonas-schievink

- Share structures with lazy macros, make both use `MacroCallLoc`.
- Remove `intern_eager_expansion`, `EagerCallLoc`, `EagerMacroId`, and *many* matches on `MacroCallId`.
- Make a lot of FIXMEs obsolete since the code no longer distinguishes between eager and lazy macros.
- Add `EagerCallInfo`, which is `Some` for calls to eager macros and holds the argument or expansion result and the included file.

8887: fix: fix derive collection after unresolved attribute fallback r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/pull/8882#issuecomment-844379170

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-19 19:07:05 +00:00
Jonas Schievink
274d813cff Fix derive collection after unresolved attribute fallback 2021-05-19 21:05:58 +02:00
Jonas Schievink
ea8555b155 Simplify eager macro representation 2021-05-19 20:19:08 +02:00
bors[bot]
1cf0794f5e
Merge #8882
8882: internal: resolve attributes in name resolution (minimal version) r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/pull/7049

This should not have any observable effect, since we don't attempt to expand attribute macros yet, and I have implemented a fallback that treats items with unresolved attributes as if the attribute wasn't there.

Derive helpers are not yet resolved. `#![register_{attr,tool}]` are not yet supported.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-19 17:06:49 +00:00
Jonas Schievink
383635a13e Rewrite resolve_imports to use an iterator
This allows reusing the original vector's allocation
2021-05-19 19:05:03 +02:00
Jonas Schievink
aebb60de5c Restructure nameres loop to be a bit clearer 2021-05-19 18:56:00 +02:00
Jonas Schievink
3e186d4778 internal: resolve attributes in name resolution 2021-05-19 15:17:57 +02:00
bors[bot]
16b03d21dc
Merge #8871
8871: internal: Simplify `DefCollector::resolve_macros` r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-18 19:02:32 +00:00
Jonas Schievink
4884d9ec1d Simplify DefCollector::resolve_macros 2021-05-18 17:51:02 +02:00
ivan770
999217374f
Added cov mark 2021-05-17 11:37:24 +02:00
ivan770
a79b54ef73
Fix #8834 2021-05-16 20:05:52 +02:00
bors[bot]
a57bd59f35
Merge #8813
8813: Get some more array lengths! r=lf- a=lf-

This is built on #8799 and thus contains its changes. I'll rebase it onto master when that one gets merged. It adds support for r-a understanding the length of:

* `let a: [u8; 2] = ...`
* `let a = b"aaa"`
* `let a = [0u8; 4]`

I have added support for getting the values of byte strings, which was not previously there. I am least confident in the correctness of this part and it probably needs some more tests, as we currently have only one test that exercised that part (!).

Fixes #2922.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-16 01:53:12 +00:00
Jade
de0ed9860d Address final feedback
* rename ConstExtension->ConstExt
* refactor a manual construction of a Const
2021-05-15 18:51:18 -07:00
Jade
78d6b88f21 Add more tests, refactor array lengths/consteval work
Fix #2922: add unknown length as a condition for a type having unknown.

Incorporate reviews:

* Extract some of the const evaluation workings into functions
* Add fixmes on the hacks
* Add tests for impls on specific array lengths (these work!!! 😁)
* Add tests for const generics (indeed we don't support it yet)
2021-05-14 01:39:28 -07:00
bors[bot]
9c8c72b7c4
Merge #8822
8822: minor: Cleanup imports r=Veykril a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-13 20:38:56 +00:00
bors[bot]
908cd23f81
Merge #8820
8820: fix: Return absolute paths in find_path if crate start is ambiguous r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-13 16:48:11 +00:00
Aleksey Kladov
ad0648dc95 Cleanup imports 2021-05-13 13:44:47 +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
Jade
8b147624ff Add lowering of array lengths in types
Now e.g.

```rust
fn a(b: [u8; 2]) {
}
```

will know about the length of b.
2021-05-12 21:22:46 -07:00
Lukas Wirth
69e0b10150 Return absolute paths in find_path if crate start is ambiguous 2021-05-13 02:53:32 +02: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
da08198bc9 Rewrite attr.rs to allow using syntax-based indices 2021-05-10 21:50:42 +02:00
Jonas Schievink
a87bec5148 Move AttrId back into hir_def 2021-05-10 16:35:06 +02:00
Jonas Schievink
fd5a1d1765 Test that none of the macros are reparsed 2021-05-09 16:39:47 +02:00
Jonas Schievink
9cf8d325a2 Precompute macro fragment kind 2021-05-09 01:36:06 +02:00
Jonas Schievink
20ae41c1a1 Reuse database in LowerCtx 2021-05-06 23:23:50 +02:00
Aleksey Kladov
c4f9cb9b53 Update crates/hir_def/src/nameres/tests/incremental.rs
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-06 20:00:43 +02:00
Aleksey Kladov
548e5a5c29 internal: add failing incremental test 2021-05-06 20:00:11 +02:00
Jonas Schievink
976a3226fe Don't store call-site text offsets in hygiene info 2021-05-06 19:59:54 +02:00