Commit Graph

715 Commits

Author SHA1 Message Date
Dawer
2431ff5987 Handle unordered fields in struct patterns 2021-06-01 00:03:46 +05:00
Dawer
3ffcb2658c Complete field replacing 2021-06-01 00:03:46 +05:00
Dawer
3a85e47f6a Support bool literal patterns 2021-06-01 00:03:46 +05:00
Dawer
5a8a0b6269 Check enum patterns 2021-06-01 00:03:46 +05:00
Dawer
b4f4197332 Build wildcard witnesses instead of panicking 2021-06-01 00:03:46 +05:00
Dawer
678d85ca7e Implement struct ctor application 2021-06-01 00:03:46 +05:00
Dawer
062c7953a1 Add remaining Constructor variants 2021-06-01 00:03:46 +05:00
Dawer
2880fd2320 Complete usefulness::SubPatSet impl 2021-06-01 00:03:46 +05:00
Dawer
f4c3960364 List useless patterns in a useful match arm 2021-06-01 00:03:45 +05:00
Dawer
f4a95c93fe Remove unneeded indirection on PatCtxt 2021-06-01 00:03:45 +05:00
Dawer
26baab5d28 Enable generation of non-exhaustiveness witnesses 2021-06-01 00:03:45 +05:00
Dawer
c3c2893f30 Update match checking.
fn is_useful , more skeletons

Specify a lifetime on pattern references

impl PatStack

fill impl Matrix

PatStack::pop_head_constructor

Index-based approach

struct PatCtxt

fields construction fn Fields::wildcards

split wildcard

fn Constructor::is_covered_by_any(..)

fn Matrix::specialize_constructor(..)

impl Usefulness

Initial work on witness construction

Reorganize files

Replace match checking diagnostic

Handle types of expanded patterns

unit match checking go brrr
2021-06-01 00:03:45 +05:00
cynecx
759cb07891 hir_ty: use correct receiver_ty in method resolution 2021-05-31 20:26:38 +02:00
Aleksey Kladov
159922de93 minor: it's Parameter, not Argument 2021-05-31 19:45:50 +03:00
Aleksey Kladov
341f8bb200 fix: avoid panics in match case diagnostic 2021-05-31 19:45:50 +03: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
cynecx
51cbcc5346 hir_ty: don't pass where clauses of associated types down to chalk (temp. fix #9052) 2021-05-30 19:21:08 +02:00
bors[bot]
f41b68637a
Merge #9062
9062: internal: Bump deps r=lnicola a=lnicola

Fixes #9061

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-30 11:48:59 +00:00
Laurențiu Nicola
36567eb9be Bump deps 2021-05-30 14:48:10 +03:00
cynecx
54d60fdee9 hir_ty: use async ret type for inference inside async bodies 2021-05-29 18:17:45 +02:00
Jonas Schievink
31588aea04 Remove fragment kind knowledge from builtin macros 2021-05-29 17:17:08 +02:00
Jonas Schievink
26b4777e1f Move hir_ty incremental test to its own file 2021-05-27 20:21:52 +02:00
Jonas Schievink
33debc4065 Update salsa 2021-05-27 15:05:41 +02:00
bors[bot]
f3aaae6555
Merge #9007
9007: Internal: `clippy::redundant_clone` fixes r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-26 15:36:14 +00:00
Laurențiu Nicola
8206939fed clippy::redundant_clone fixes 2021-05-26 18:34:50 +03: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
bors[bot]
33fdd512e3
Merge #8987
8987: Fix lowering of FnOnce() without return type r=flodiebold a=flodiebold

This should result in an implicit `-> ()`, not leaving out the binding.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-05-25 13:25:15 +00:00
Florian Diebold
7c6f764ad6 Hide -> () in Fn traits 2021-05-25 15:23:52 +02:00
Lukas Wirth
3ee4e6c54c Fix type inference not working for new Try trait 2021-05-25 14:59:54 +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
Florian Diebold
c33ee36d2a Minor test fixes / new tests 2021-05-25 13:07:18 +02:00
Florian Diebold
b26a472ccb Fix type mismatch caused by macros
MacroStmts should be completely transparent, but it prevented
coercion. (I should maybe give `infer_expr` and `infer_expr_inner`
better names.)
2021-05-25 11:15:02 +02: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
bors[bot]
c139eff5b8
Merge #8963
8963: Bump deps r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-24 15:34:52 +00:00
Laurențiu Nicola
74f1b21b08 Bump chalk 2021-05-24 16:27:24 +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
Florian Diebold
4a6cdd776d Record method call substs and use them in call info 2021-05-23 18:24:21 +02:00
Florian Diebold
a5d85a6356 Add test for #8931 and better checking 2021-05-23 12:52:41 +02:00
Florian Diebold
a88c7c04d2 Add last remaining module docstring 2021-05-22 16:39:56 +02:00
Florian Diebold
63614aafad Resolve any lifetime variables to 'static after inference
Chalk's unification can sometimes create lifetime variables, which we
currently don't really deal with, but at least we don't want to leak
them outside of inference.

Should fix #8919.
2021-05-22 14:27:22 +02:00
Florian Diebold
ef558c97d0 Clean up visibilities 2021-05-21 19:51:21 +02:00
Florian Diebold
67f1a08fd8 Some remaining cleanups 2021-05-21 18:23:03 +02:00
Florian Diebold
e9d1550001 Fix test after rebase 2021-05-21 18:23:03 +02:00
Florian Diebold
6e5637983c Record type mismatches for failed coercions in match etc. 2021-05-21 18:23:03 +02:00
Florian Diebold
556c9cebdb Refactor expectation handling
So as to not use `TyKind::Error` as "no expectation".
2021-05-21 18:23:03 +02:00
Florian Diebold
99c73537fa Remove TypeVariableTable 2021-05-21 17:49:09 +02:00
Florian Diebold
9716c0b949 Deal with goals arising from unification 2021-05-21 17:49:09 +02:00
Florian Diebold
4bd446f5b3 Get rid of resolve_ty_as_possible
Instead use shallow resolving where necessary.
2021-05-21 17:49:07 +02:00
Florian Diebold
a78f0076ab Make resolve_ty_shallow return Ty 2021-05-21 17:48:34 +02: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
a3d9cac690 Fix another panic 2021-05-21 17:48:34 +02:00
Florian Diebold
29266ada04 Improve debug printing without TLS 2021-05-21 17:48:34 +02:00
Florian Diebold
7c423f5b88 Fix panic 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
b939a6dcac Fix if/else coercion 2021-05-21 17:48:34 +02:00
Florian Diebold
212f0477f2 Make diverging type variables work again
Chalk doesn't know about the `diverging` flag, so we need to instead
propagate it before fully resolving the variables.
2021-05-21 17:48:34 +02:00
Florian Diebold
32fc944263 Fix handling of diverging branches in match coercion
Fixes #7626.
2021-05-21 17:48:34 +02:00
Florian Diebold
a09079f27a Fix coercion of two closures to a function pointer
Fixes #8604.
2021-05-21 17:48:34 +02:00
Florian Diebold
afa6be2435 Update tests with expected changes 2021-05-21 17:48:34 +02:00
Florian Diebold
3379a52dff Make type resolver a proper folder, make it resolve consts as well 2021-05-21 17:48:34 +02:00
Florian Diebold
278f5b043d Fix fallback to bound vars in unify 2021-05-21 17:48:34 +02:00
Florian Diebold
aebcf7b5d4 Better Debug impl for InternedWrapper 2021-05-21 17:48:34 +02:00
Florian Diebold
0f7f1f0705 Temporary fix for unknown expectations 2021-05-21 17:48:34 +02:00
Florian Diebold
4ca1981c91 Fix warnings & format 2021-05-21 17:48:34 +02:00
Florian Diebold
693582946f Rewrite coercion using the new unification 2021-05-21 17:48:33 +02:00
Florian Diebold
84074cb185 Remove our unification code, use Chalk's instead 2021-05-21 17:48:33 +02:00
Dawer
e2b1c69f74 Check patterns for type match recursively. 2021-05-19 11:08:59 +05:00
Dawer
472317c008 internal: Record mismatches of pattern types. 2021-05-19 11:08:59 +05: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
Dawer
2abb4c99fe Fix false positive "Missing match arm". 2021-05-15 00:18:59 +05: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
Jade
32c600664e Test lowering byte strings some more 2021-05-12 21:22:46 -07: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
bors[bot]
312f1fe20a
Merge #8799
8799: Add basic support for array lengths in types r=flodiebold a=lf-

This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?

Co-authored-by: Jade <software@lfcode.ca>
2021-05-12 14:49:43 +00:00
Jade
f28c053c67 address review by @eddyb 2021-05-11 15:18:45 -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
Jade
dc63fea427 Add basic support for array lengths in types
This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?
2021-05-11 05:25:19 -07:00
Lukas Wirth
41f470fea8 Correctly support SelfType when searching for usages 2021-05-08 22:34:55 +02: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
11c926fd97 Add a test for conditionally compiled tails 2021-05-03 14:14:33 +01:00
Daniel McNab
ebbcf9f458 Fix inference with conditionally compiled tails
Fixes #8378
2021-05-03 14:13:05 +01:00
Florian Diebold
c2aefd5b95 Don't look in super traits for <T as Trait>::Assoc
This isn't actually how it works, you have to specify the exact trait
that has the associated type.

Fixes #8686.
2021-04-29 20:23:02 +02:00
Florian Diebold
2d20ab7eaf Rewrite all_super_trait_refs as an iterator
Doesn't fix the bug I was trying to fix, but now that I did it anyway it
seems fine to keep.
2021-04-29 20:18:41 +02:00
Florian Diebold
b384cfcb81 Handle cycles in generic_defaults more gracefully 2021-04-29 20:00:43 +02:00
Florian Diebold
184a0d7c1e Add test for #8686 2021-04-29 20:00:21 +02:00
Comonad
78f1583bdd fix: closure unify without check ClosureId
closes #8604
2021-04-29 15:26:41 +08:00
Laurențiu Nicola
27c5e2da48 Bump chalk 2021-04-21 19:20:01 +03:00
bors[bot]
e4f7f1e1bd
Merge #8462
8462: Expand macros at type position r=jonas-schievink a=cynecx



Co-authored-by: cynecx <me@cynecx.net>
2021-04-19 13:01:30 +00:00
Jonas Schievink
20c27dbdbe Collect inherent impls in unnamed consts 2021-04-19 01:06:26 +02:00
cynecx
f0507ab7c6 hir_ty: cleanups and extend infinitely_recursive_macro_type test 2021-04-18 20:18:48 +02:00
cynecx
6ed2fd233b hir_ty: keep body::Expander in TyLoweringContext 2021-04-18 19:56:13 +02:00
cynecx
7ed42a3a52 hir_def: refactor expand_macro_type and cleanups 2021-04-17 17:38:45 +02: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
bors[bot]
5274eb12dd
Merge #8539
8539:  fix: Do not propose inherent traits in flyimports and import assists r=flodiebold a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8520

I've went with a separate method approach, since the [highlighted code](https://github.com/rust-analyzer/rust-analyzer/issues/8520#issuecomment-819856337) has not`Type` and uses `Ty` to get his data, but the code I had to change has no access to `Ty` and has `Type` only.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-04-16 17:54:47 +00:00
Jonas Schievink
543d4ef7c5 Fix primitive shadowing with inner items 2021-04-16 19:28:22 +02:00
Kirill Bulatov
739edfd5cf Exclude inherent traits from flyimports 2021-04-16 11:13:17 +03:00
Kirill Bulatov
af8a6049a5 Profile trait solving for all invocations 2021-04-14 19:11:17 +03:00
Kirill Bulatov
75a2605361 Better places for spans 2021-04-14 17:15:37 +03:00
Kirill Bulatov
3390e73816 We need to go deeper 2021-04-14 16:59:08 +03:00
Kirill Bulatov
d1fc9d727b Add a missing span 2021-04-14 15:52:56 +03:00
Jonas Schievink
31594bcd01 decl_check: follow test style guide 2021-04-13 14:13:35 +02:00
bors[bot]
9beed98f2a
Merge #8432
8432: decl_check: consider outer scopes' allows r=jonas-schievink a=lf-

Fix #8417. Also makes it less noisy about no_mangle annotated stuff the
user can do nothing about.

Note: this still is broken with bitfield! macros. A repro in an ignore
test is included here. I believe this bug is elsewhere, and I don't
think I can work around it here.

I would like help filing the remaining bug, as it does actually affect
users, but I don't know how to describe the behaviour (or even if it
is unintended).

Co-authored-by: Jade <software@lfcode.ca>
2021-04-13 12:02:26 +00:00
Jade
26d2653dd6 address review feedback 2021-04-13 01:21:03 -07:00
Florian Diebold
97d6e36dbe Remove assertion in impl collection
This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.
2021-04-11 12:07:58 +02:00
bors[bot]
5b40342d2d
Merge #8465
8465: Include more info in assert r=jonas-schievink a=jonas-schievink

This helped find https://github.com/rust-analyzer/rust-analyzer/issues/8464

changelog skip

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-10 23:42:26 +00:00
Jonas Schievink
5f2efae3ba Include more info in assert 2021-04-11 01:41:40 +02:00
Jonas Schievink
e2c1da36f5 Support macros in pattern position 2021-04-11 01:25:50 +02:00
Lukas Wirth
8113c3a914 Respect test style guidelines in tests::traits 2021-04-10 18:03:27 +02:00
Lukas Wirth
a15b8136ee Add test for binary op return ty with adt 2021-04-10 17:52:24 +02:00
Lukas Wirth
d9554c258b Add manual ops::Add impls to test::traits::closure_2 2021-04-10 17:16:35 +02:00
Lukas Wirth
252eb78dc3 Implement more precise binary op return type prediction 2021-04-10 16:56:32 +02:00
Jonas Schievink
75614b126b Resolve prelude and crate root names in the root DefMap 2021-04-09 15:29:42 +02:00
Florian Diebold
fbe98047d4 More cleanups / module docs 2021-04-09 14:40:58 +02:00
Florian Diebold
8a2c482082 More cleanups 2021-04-09 14:33:31 +02:00
Florian Diebold
2f02977e56 More moving stuff around 2021-04-09 14:28:04 +02:00
Florian Diebold
9fba7cf827 Move some more stuff to better places 2021-04-09 14:18:58 +02:00
Florian Diebold
5ca481bbdc Move ToChalk -> mapping 2021-04-09 14:15:26 +02:00
Florian Diebold
743faa21e7 Reorganize hir_ty modules
Chalk isn't really a 'traits' thing anymore, so it doesn't make sense to
have all the Chalk-related stuff in submodules of `traits`.
2021-04-09 14:11:37 +02:00
bors[bot]
99ed68a109
Merge #8406
8406: Improve indexing of impls r=flodiebold a=flodiebold

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.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-09 10:45:34 +00: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
272a8dce4f Fix crash on syn involving lifetimes returned by Chalk
If we get lifetime variables back in autoderef, just immediately replace
them by static lifetimes for now. Method resolution doesn't really deal
correctly with new variables being introduced (this needs to be fixed
more properly).

This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA
repo.
2021-04-09 11:17:07 +02:00
Jade
4529f1be81 decl_check: consider outer scopes' allows
Fix #8417. Also makes it less noisy about no_mangle annotated stuff the
user can do nothing about.

Note: this still is broken with bitfield! macros. A repro in an ignore
test is included here. I believe this bug is elsewhere, and I don't
think I can work around it here.
2021-04-08 14:43:19 -07:00
Florian Diebold
37ff15ad83 Cleanup 2021-04-08 22:49:10 +02:00
Florian Diebold
417473aa3d Intern Variances
This may be a slight performance improvement.
2021-04-08 22:48:47 +02:00
Florian Diebold
f778e50b71 Don't intern ProgramClause at all
This seems to work best performance/memory-wise.
2021-04-08 22:48:47 +02:00
Florian Diebold
566200342a Intern QuantifiedWhereClauses
Slight performance and memory usage improvement.
2021-04-08 22:48:47 +02:00
Florian Diebold
15b0b55b4e Intern ProgramClauses 2021-04-08 22:48:47 +02:00
Florian Diebold
317c4b972f Intern CanonicalVarKinds
Slight savings in performance and memory.
2021-04-08 22:48:47 +02:00
Florian Diebold
90656f8674 Intern consts & lifetimes
Slight memory usage reduction.
2021-04-08 22:48:47 +02:00
Florian Diebold
37cb6805af Intern types
Performance about the same, memory reduced by ~5%.
2021-04-08 22:48:47 +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
a169fa6a83 Intern VariableKinds 2021-04-08 22:48:47 +02:00
Florian Diebold
d992736e79 Remove unused 2021-04-08 14:36:14 +02:00
Florian Diebold
8040f4a5e3 Replace make_binders by the now equivalent make_only_type_binders 2021-04-08 14:23:17 +02:00
Florian Diebold
8ce6fea325 Remove identity impls for ToChalk 2021-04-08 14:23:17 +02:00
Florian Diebold
a163554857 Fix Canonicalized::apply_solution
Now that we're using Chalk's `substitute` which actually knows about
lifetimes, the hack doesn't work anymore, but we can put in a proper
lifetime.
2021-04-08 14:23:17 +02:00
Florian Diebold
a838a60caa Fix missing match arms 2021-04-08 14:23:17 +02:00
Florian Diebold
f43edb2151 Fix remaining interned_mut call 2021-04-08 14:08:55 +02:00
Florian Diebold
0f058d61ce Replace remaining fold calls 2021-04-08 14:08:55 +02:00
Florian Diebold
caee3b6c2d Replace some fold calls 2021-04-08 14:08:55 +02:00
Florian Diebold
b25b147e86 Fix shifted_{in,out} calls 2021-04-08 14:08:55 +02:00
Florian Diebold
dc0b581736 Fix subst_prefix 2021-04-08 14:08:55 +02:00
Florian Diebold
5794a090bf Get rid of walk_mut [not compiling] 2021-04-08 14:08:55 +02:00
Florian Diebold
1332e72d09 Fix TyBuilder methods 2021-04-08 14:08:55 +02:00
Florian Diebold
b24e6f6030 Impl Fold for CallableSig 2021-04-08 14:08:55 +02:00
Florian Diebold
7e541e69b1 Add HasInterner bounds 2021-04-08 14:08:55 +02:00
Florian Diebold
926bfef0ef Allow unused 2021-04-08 14:08:55 +02:00
Florian Diebold
e5d294765a Remove obsolete Cast impls 2021-04-08 14:08:54 +02:00
Florian Diebold
429bbbd39a Make ToChalk implementations identity 2021-04-08 14:08:54 +02:00
Florian Diebold
77d974ae6b Replace all the types by their Chalk versions 2021-04-08 14:08:54 +02:00
bors[bot]
3191a93185
Merge #8409
8409: Various remaining fixes for Chalk IR move r=flodiebold a=flodiebold

CC #8313

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-07 18:51:36 +00:00
Florian Diebold
dc116f7ce2 Fix return type of Substitution::interned 2021-04-07 20:50:26 +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
9b4ecd3723 Fix return type of self_type_parameter 2021-04-07 20:41:52 +02:00
Florian Diebold
6777a4975d Move hir_trait_id to extension trait 2021-04-07 20:40:01 +02:00
Florian Diebold
86feac18e8 Change TraitRef::hir_fmt_ext to free-standing function 2021-04-07 20:34:58 +02:00
Florian Diebold
4c35df47e8 Move equals_ctor to TyExt
I'd prefer getting rid of it, but it's used in the impl search and not
super easy to replace there (I think ideally the impl search would do
proper unification, but that's a bit more complicated).
2021-04-07 20:08:50 +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
Lukas Wirth
e3a5c15d18 Move Ty::builtin_deref 2021-04-07 13:06:48 +02:00
bors[bot]
a8f1e41f0f
Merge #8394
8394: Infer variants through type aliased enums r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-07 09:35:40 +00:00
Lukas Wirth
41563fd612 Infer variants through type aliased enums 2021-04-07 11:31:50 +02:00
Jonas Schievink
7c1c0e6fea Collect trait impls inside unnamed consts 2021-04-07 03:33:22 +02:00
Florian Diebold
b03969cda9 Remove SolutionVariables, add ConstrainedSubst analogous to Chalk
... just missing the constraints.
2021-04-06 23:46:32 +02:00
Florian Diebold
768ee3e47a Align InferenceVar to Chalk 2021-04-06 21:10:22 +02:00
Florian Diebold
d280538174 Clean up Chalk mapping a bit 2021-04-06 21:10:22 +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
bors[bot]
e6a1c9ca60
Merge #8371
8371: Don't use HirDisplayWrapper when displaying SourceCode r=matklad a=Veykril

The issue was basically that when displaying for `DisplayTarget::SourceCode` some `hir_fmt` functions would create `HirDisplayWrapper`s which would then `fmt` these triggering the Display panic since `fmt::Display` can't fail the same way as `HirDisplay`. Simple fix is to just use `hir_fmt` directly. Should probably write that down somewhere in source, looking for a good spot to put that right now.

Fixes #8077, Fixes #8370


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-06 16:12:30 +00: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
bors[bot]
7d39b13996
Merge #8364
8364: Memory usage improvements r=jonas-schievink a=alexmaco

These are mostly focused on splitting up enum variants with large size differences between variants by `Box`-ing things up.

In my testing this reduces the memory usage somewhere in the low percentages, even though the measurements are quite noisy.

Co-authored-by: Alexandru Macovei <alexnmaco@gmail.com>
2021-04-06 13:43:37 +00: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
Lukas Wirth
a43409fa43 Panic when creating a HirDisplayWrapper with DisplayTarget::SourceCode 2021-04-06 14:42:34 +02:00
Lukas Wirth
ffdb2da49d Don't use HirDisplayWrapper when displaying SourceCode 2021-04-06 14:21:35 +02:00
Lukas Wirth
bc993bbe85 Remove TyExt::dyn_trait_ref 2021-04-06 13:58:51 +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
08dc69599e Use a constructor function for Static lifetimes 2021-04-06 10:50:55 +02:00
Lukas Wirth
b98c681cb7 Always use Static lifetimes in chalk mapping 2021-04-06 10:45:34 +02:00
Lukas Wirth
9da191c7e0 Add Lifetime to DynTy 2021-04-06 10:45:34 +02:00
Lukas Wirth
96756f1b1d Add Lifetime to TyKind::Ref 2021-04-06 10:45:30 +02:00
Florian Diebold
1ae967bf8e Fix shifting of binders in FnPointer
- don't shift in/out for Chalk mapping (we want to have the same
   binders now)
 - do shift in when creating the signature for a closure (though it
   shouldn't matter much)
 - do shift in when lowering a `fn()` type
 - correctly deal with the implied binder in TypeWalk
2021-04-05 23:00:50 +02:00
Florian Diebold
edc59d897d Align FnPointer with Chalk 2021-04-05 22:23:30 +02:00
Florian Diebold
b67148daea Substitution::prefix -> subst_prefix
I probably want to get rid of this function completely later.
2021-04-05 21:58:53 +02:00
Florian Diebold
2a83645e1b Get rid of Substitution::suffix 2021-04-05 21:58:03 +02:00
Florian Diebold
b443e5304e Remove some unused methods, move some to types.rs 2021-04-05 21:58:03 +02:00
Florian Diebold
738174671a Binders::wrap_empty -> wrap_empty_binders 2021-04-05 21:58:03 +02:00
Florian Diebold
2f5a77658b Substitution::single -> from1 2021-04-05 21:58:03 +02:00
Florian Diebold
788533d380 Move ProjectionTy methods to extension trait 2021-04-05 21:58:01 +02:00
bors[bot]
8c96a7d81e
Merge #8353
8353: Replace hir_ty::Lifetime with chalk equivalent r=flodiebold a=Veykril

Our `Lifetime` isn't really used yet so this is a rather simple change

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-05 19:34:50 +00:00
Lukas Wirth
d587ca2991 Replace unused hir_ty::Lifetime with chalk equivalents 2021-04-05 20:46:15 +02:00
Jonas Schievink
f48dd154a5 Use more assoc. type aliases in the chalk interner
Makes it sligthly easier to swap out these types
2021-04-05 20:15:07 +02:00