Commit graph

335 commits

Author SHA1 Message Date
Lukas Wirth
26e784a575 simplify 2021-05-26 21:09:27 +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
bors[bot]
8b049ec393
Merge #8942
8942: Add `library` semantic token modifier to items from other crates r=arzg a=arzg

Closes #5772.

A lot of code here is pretty repetitive; please let me know if you have any ideas how to improve it, or whether it’s fine as-is.

Side-note: How can I add tests for this? I don’t see a way for the test Rust code in `test_highlighting` to reference other crates to observe the new behaviour.


Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-05-25 02:30:47 +00:00
Aleksey Kladov
45112aa8c0 internal: rename hypothetical -> speculative
Lets steal this good naming from Roslyn before I forget about it yet
again.
2021-05-24 22:21:25 +03: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
Aramis Razzaghipour
c32428571c
Remove hir krate methods 2021-05-24 14:54:16 +10:00
Aramis Razzaghipour
4fd5248749
Add highlighting of items from other crates 2021-05-24 14:53:48 +10: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
Florian Diebold
b8262099cc Get rid of field_type again 2021-05-23 23:54:35 +02:00
Lukas Tobias Wirth
da74c66947 Correctly resolve crate name in use paths when import shadows itself 2021-05-23 19:37:01 +02:00
Florian Diebold
7a0c93c58a Infer correct expected type for generic struct fields 2021-05-23 18:45:44 +02:00
Florian Diebold
4a6cdd776d Record method call substs and use them in call info 2021-05-23 18:24:21 +02:00
Aramis Razzaghipour
4d4dbcfead
Give ‘unsafe’ semantic token modifier to unsafe traits 2021-05-23 21:45:10 +10:00
Florian Diebold
34a3bc4196 Paper over #8931 a bit more
The problem was the skipping of binders in
`resolve_method_call_as_callable`; this still doesn't use the _correct_
substitution, but at least it doesn't return a type with free variables
in it.

Fixes #8931.
2021-05-23 13:00:14 +02:00
Florian Diebold
a5d85a6356 Add test for #8931 and better checking 2021-05-23 12:52:41 +02:00
Aleksey Kladov
188b0f96f9 Add more docs 2021-05-22 16:53:47 +03:00
Florian Diebold
1250ddc5cf Rework obligation handling
We can't do the easy hack that we did before anymore, where we kept
track of whether any inference variables changed since the last time we
rechecked obligations. Instead, we store the obligations in
canonicalized form; that way we can easily check the inference variables
to see whether they have changed since the goal was canonicalized.
2021-05-21 17:48:34 +02:00
Florian Diebold
8397734cfe Fix HIR expecting errors to unify with anything 2021-05-21 17:48:34 +02:00
Florian Diebold
48c492af7e Fix compilation of hir and ide crates 2021-05-21 17:48:34 +02:00
Jonas Schievink
ea8555b155 Simplify eager macro representation 2021-05-19 20:19:08 +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
hi-rustin
b98c119ba6 Apply async semantic token modifier to async/await keywords
Only async semantic token modifier
2021-05-14 10:47:00 +08:00
Lukas Wirth
41f470fea8 Correctly support SelfType when searching for usages 2021-05-08 22:34:55 +02:00
Aleksey Kladov
53f7149d45 internal: expose cfg attrs from hir::Crate 2021-05-07 23:50:24 +03:00
bors[bot]
a8da2ca3a1
Merge #8745
8745: Support goto_type_definition for types r=matklad a=Veykril

I'm unsure if the approach of lowering an `ast::Type` to a `hir::Type` is a good idea, it seems fine to me at least.
Fixes #2882

Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-06 22:28:35 +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
Lukas Tobias Wirth
d97a4b8e49 Support goto_type_definition for types 2021-05-06 17:05:49 +02:00
Lukas Tobias Wirth
3f796fea9f simplify 2021-05-05 22:55:12 +02:00
Aleksey Kladov
1a01a5ae19 internal: fix naming polarity
Type Constructors have *parameters*, when they are substituted with type
*arguments*, we have a type.
2021-04-30 11:55:59 +03:00
Aleksey Kladov
cb3ef552e8 internal: normalize name
All def types in hir are unsubstituted
2021-04-30 11:52:31 +03:00
cynecx
28ef7c20d7 hir_ty: deal with TypeRef::Macro in HirFormatter 2021-04-17 16:24:56 +02:00
cynecx
cf3b4f1e20 hir_ty: Expand macros at type position 2021-04-17 16:24:56 +02:00
Kirill Bulatov
739edfd5cf Exclude inherent traits from flyimports 2021-04-16 11:13:17 +03:00
Florian Diebold
fdd721e9ef Improve indexing of impls
Store impls for e.g. &Foo with the ones for Foo instead of the big
"other" bucket. This can improve performance and simplifies the HIR impl
search a bit.
2021-04-09 11:21:31 +02:00
Florian Diebold
be03db0e3a Intern Substitutions
(Costs a bit of performance, reduces memory usage on RA by ~10%.)
2021-04-08 22:48:47 +02:00
Florian Diebold
a838a60caa Fix missing match arms 2021-04-08 14:23:17 +02:00
Florian Diebold
be0084a0bc InEnvironment::new takes a reference 2021-04-07 20:48:58 +02:00
Florian Diebold
d1b645d236 Make Canonical::new a free-standing function 2021-04-07 20:47:04 +02:00
Florian Diebold
6777a4975d Move hir_trait_id to extension trait 2021-04-07 20:40:01 +02:00
Florian Diebold
92dcc53f94 Remove Ty::substs{_mut}
Almost all uses actually only care about ADT substs, so it's better to
be explicit. The methods were a bad abstraction anyway since they
already didn't include the inner types of e.g. `TyKind::Ref` anymore.
2021-04-07 17:56:53 +02:00
Lukas Wirth
c3c8e8225f Free Ty::def_crates 2021-04-07 13:09:31 +02:00
Florian Diebold
b03969cda9 Remove SolutionVariables, add ConstrainedSubst analogous to Chalk
... just missing the constraints.
2021-04-06 23:46:32 +02:00
Jonas Schievink
230c763648 infer: remove record_pat_field_resolutions field
Same as https://github.com/rust-analyzer/rust-analyzer/pull/8376, this
can be computed from other data
2021-04-06 19:44:28 +02:00
Jonas Schievink
e9752308bb infer: remove record_field_resolutions field
It stores no useful data, since we can derive all fields from
`variant_resolutions`
2021-04-06 17:59:18 +02:00
Lukas Wirth
9b4699a9be Move Ty accessors to TyExt 2021-04-06 13:58:48 +02:00
Lukas Wirth
9fbba7bc45 Add chalk_ir::Const to TyKind::Array 2021-04-06 11:45:41 +02:00
Lukas Wirth
96756f1b1d Add Lifetime to TyKind::Ref 2021-04-06 10:45:30 +02:00