Commit graph

509 commits

Author SHA1 Message Date
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