aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer
Commit message (Collapse)AuthorAgeFilesLines
* correctly infer labelled breaksrobojumper2020-05-311-16/+29
|
* Merge #4653bors[bot]2020-05-301-5/+11
|\ | | | | | | | | | | | | | | 4653: Fix match ergonomics in closure parameters r=matklad a=flodiebold Fixes #4476. Co-authored-by: Florian Diebold <[email protected]>
| * Fix match ergonomics in closure parametersFlorian Diebold2020-05-291-5/+11
| | | | | | | | Fixes #4476.
* | Merge #4651bors[bot]2020-05-291-3/+1
|\ \ | |/ |/| | | | | | | | | | | | | | | | | 4651: Use first match branch in case of type mismatch, not last r=kjeremy a=flodiebold The comment says this was intentional, but I do agree with #4304 that it makes more sense the other way around (for if/else as well). Fixes #4304. Co-authored-by: Florian Diebold <[email protected]>
| * Use first match branch in case of type mismatch, not lastFlorian Diebold2020-05-291-3/+1
| | | | | | | | | | | | | | The comment says this was intentional, but I do agree with #4304 that it makes more sense the other way around (for if/else as well). Fixes #4304.
* | Support raw_ref_op's raw reference operatorrobojumper2020-05-281-14/+23
|/
* Switch to new magic marksAleksey Kladov2020-05-203-9/+9
|
* Apply suggestion of @flodiebold: Get rid of multiple unwrapsRoland Ruckerbauer2020-05-191-12/+10
|
* loop return value inference: coerce_merge branchesRoland Ruckerbauer2020-05-191-15/+23
|
* Infer return type of loops with value breaks.Roland Ruckerbauer2020-05-181-6/+15
|
* Handle `Self` in values and patternsFlorian Diebold2020-05-151-1/+34
| | | | | | | | | I.e. - `Self(x)` or `Self` in tuple/unit struct impls - `Self::Variant(x)` or `Self::Variant` in enum impls - the same in patterns Fixes #4454.
* Handle coercing function types to function pointers in matchFlorian Diebold2020-05-081-11/+23
| | | | | | | | | | | | E.g. in ```rust match x { 1 => function1, 2 => function2, } ``` we need to try coercing both to pointers. Turns out this is a special case in rustc as well (see the link in the comment).
* Add diagnostic for break outside of loopFlorian Diebold2020-05-081-0/+4
|
* Handle break somewhat betterFlorian Diebold2020-05-081-2/+27
| | | | | Still no break-with-value or labels, but at least we know that `loop { break; }` doesn't diverge.
* Implement better handling of divergenceFlorian Diebold2020-05-081-14/+39
| | | | | | | | Divergence here means that for some reason, the end of a block will not be reached. We tried to model this just using the never type, but that doesn't work fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`); so this introduces a `diverges` flag that the type checker keeps track of, like rustc does.
* Fix type of byte literalsFlorian Diebold2020-05-081-2/+2
| | | | They're `&[u8; N]`, not `&[u8]` (see #4374).
* Revert "Merge #4233"Aleksey Kladov2020-05-021-0/+5
| | | | | This reverts commit a5f2b16366f027ad60c58266a66eb7fbdcbda9f9, reversing changes made to c96b2180c1c4206a0a98c280b4d30897eb116336.
* Kill more zombiesAleksey Kladov2020-04-301-5/+0
|
* Rename StructField -> FieldAleksey Kladov2020-04-252-7/+5
|
* Fix goto definition for record patternsAleksey Kladov2020-04-181-0/+6
|
* Fix type equality for dyn TraitFlorian Diebold2020-04-172-5/+41
| | | | | | | Fixes a lot of false type mismatches. (And as always when touching the unification code, I have to say I'm looking forward to replacing it by Chalk's...)
* Switch Chalk to recursive solverFlorian Diebold2020-04-161-0/+1
| | | | + various fixes related to that.
* handle tuple patterns with ellipsisJosh Mcguigan2020-04-131-3/+3
|
* add record pat missing field diagnosticJosh Mcguigan2020-04-101-1/+1
|
* missing match arms diagnosticJosh Mcguigan2020-04-072-3/+15
|
* Upgrade Chalk againFlorian Diebold2020-04-051-11/+17
| | | | | | | The big change here is counting binders, not variables (https://github.com/rust-lang/chalk/pull/360). We have to adapt to the same scheme for our `Ty::Bound`. It's mostly fine though, even makes some things more clear.
* Add inference for literal and range patternsFlorian Diebold2020-04-011-2/+9
|
* Use `dyn Trait` for working with databseAleksey Kladov2020-03-165-37/+35
| | | | | | | It improves compile time in `--release` mode quite a bit, it doesn't really slow things down and, conceptually, it seems closer to what we want the physical architecture to look like (we don't want to monomorphise EVERYTHING in a single leaf crate).
* Resolve `Self::AssocTy` in implsFlorian Diebold2020-03-061-2/+2
| | | | | | | | | | To do this we need to carry around the original resolution a bit, because `Self` gets resolved to the actual type immediately, but you're not allowed to write the equivalent type in a projection. (I tried just comparing the projection base type with the impl self type, but that seemed too dirty.) This is basically how rustc does it as well. Fixes #3249.
*-. Merge #3397 #3398bors[bot]2020-03-021-6/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3397: Minimal viable meta r=matklad a=matklad bors r+ 🤖 3398: Reformat? r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| | * Reformat?Aleksey Kladov2020-03-021-6/+2
| |/
* | Merge #3385bors[bot]2020-03-021-3/+12
|\ \ | |/ |/| | | | | | | | | | | | | | | | | 3385: Fix #3373 r=matklad a=flodiebold Basically, we need to allow variables in the caller self type to unify with the impl's declared self type. That requires some more contortions in the variable handling. I'm looking forward to (hopefully) handling this in a cleaner way when we switch to Chalk's types and unification code. Co-authored-by: Florian Diebold <[email protected]>
| * Fix #3373Florian Diebold2020-03-011-3/+12
| | | | | | | | | | | | | | Basically, we need to allow variables in the caller self type to unify with the impl's declared self type. That requires some more contortions in the variable handling. I'm looking forward to (hopefully) handling this in a cleaner way when we switch to Chalk's types and unification code.
* | handle array pattern matching type inferenceJosh Mcguigan2020-03-011-10/+14
| |
* | remove match statement, handle suffixJosh Mcguigan2020-03-011-12/+9
| |
* | handle arbitrary length slicesJosh Mcguigan2020-03-011-3/+5
| |
* | match single prefix sliceJosh Mcguigan2020-03-011-1/+15
|/
* Do autoderef for indexingFlorian Diebold2020-02-291-5/+21
|
* Fix a common false-positive type mismatchFlorian Diebold2020-02-291-4/+4
| | | | | | | | | E.g. for `&{ some_string() }` in a context where a `&str` is expected, we reported a mismatch inside the block. The problem is that we're passing an expectation of `str` down, but the expectation is more of a hint in this case. There's a long comment in rustc about this, which I just copied. Also, fix reported location for type mismatches in macros.
* Fix handling of binders in canonicalizationFlorian Diebold2020-02-221-64/+35
| | | | I'm looking forward to getting rid of this in favor of Chalk's implementation.
* Implement unsize coercion using proper trait solvingFlorian Diebold2020-02-221-179/+26
|
* Fix handling of const patternsFlorian Diebold2020-02-211-1/+3
| | | | | | | | | E.g. in `match x { None => ... }`, `None` is a path pattern (resolving to the option variant), not a binding. To determine this, we need to try to resolve the name during lowering. This isn't too hard since we already need to resolve names for macro expansion anyway (though maybe a bit hacky). Fixes #1618.
* Normalize associated types in types coming from ChalkFlorian Diebold2020-02-211-1/+4
| | | | Fixes #3232.
* More manual clippy fixesKirill Bulatov2020-02-183-18/+10
|
* Run cargo +nightly fix --clippy -Z unstable-optionsKirill Bulatov2020-02-184-42/+35
|
* Fix coercion of &T to itselfFlorian Diebold2020-02-161-0/+2
| | | | | The autoderef coercion logic did not handle matching placeholders. This led to some type mismatches.
* Don't let unknown match arms fall back to !Florian Diebold2020-02-111-1/+5
|
* Add or- and parenthesized-patternsMatthew Jasper2020-02-092-3/+13
|
* Fix some TODOsFlorian Diebold2020-02-071-1/+0
|
* Deal better with implicit type parameters and argument listsFlorian Diebold2020-02-071-3/+5
|