aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
Commit message (Collapse)AuthorAgeFilesLines
* Use correct substs for super trait assoc typesFlorian Diebold2020-06-191-0/+28
| | | | | | | | When referring to an associated type of a super trait, we used the substs of the subtrait. That led to the #4931 crash if the subtrait had less parameters, but it could also lead to other incorrectness if just the order was different. Fixes #4931.
* Fix substs in resolve_value_path for ImplSelfVincent Rouillé2020-06-191-0/+32
| | | | Fixes #4953.
* Make known paths use `core` instead of `std`Jonas Schievink2020-06-112-16/+18
|
* Fix type parameter defaultsFlorian Diebold2020-06-054-83/+137
| | | | | They should not be applied in expression or pattern contexts, unless there are other explicitly given type args.
* Review fixesFlorian Diebold2020-06-051-15/+58
|
* Implement return position impl trait / opaque type supportFlorian Diebold2020-06-051-1/+46
| | | | | | | | | | | | | This is working, but I'm not that happy with how the lowering works. We might need an additional representation between `TypeRef` and `Ty` where names are resolved and `impl Trait` bounds are separated out, but things like inference variables don't exist and `impl Trait` is always represented the same way. Also note that this doesn't implement correct handling of RPIT *inside* the function (which involves turning the `impl Trait`s into variables and creating obligations for them). That intermediate representation might help there as well.
* correctly infer labelled breaksrobojumper2020-05-311-10/+10
|
* labelled break testrobojumper2020-05-311-0/+54
|
* Merge #4653bors[bot]2020-05-301-0/+50
|\ | | | | | | | | | | | | | | 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-0/+50
| | | | | | | | Fixes #4476.
* | Merge #4651bors[bot]2020-05-291-1/+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-1/+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.
* | | Merge #4652bors[bot]2020-05-291-5/+49
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | 4652: Upgrade Chalk r=kjeremy a=flodiebold Fixes #4072. Co-authored-by: Florian Diebold <[email protected]>
| * | Upgrade ChalkFlorian Diebold2020-05-291-5/+49
| |/ | | | | | | Fixes #4072.
* / Support raw_ref_op's raw reference operatorrobojumper2020-05-282-6/+31
|/
* Use Chalk's Ty::Function for function pointer typesFlorian Diebold2020-05-221-0/+32
| | | | | | Function pointers can be 'higher-ranked' over lifetimes, which is why they're not an application type in Chalk, but since we don't model lifetimes it doesn't matter for us yet.
* Use Chalk's built-in representation of function item typesFlorian Diebold2020-05-221-0/+42
|
* Add some tests for Chalk built-in trait implsFlorian Diebold2020-05-221-0/+78
|
* Switch to new magic marksAleksey Kladov2020-05-205-18/+17
|
* loop return value inference: add testsRoland Ruckerbauer2020-05-191-0/+63
|
* Merge #4497bors[bot]2020-05-181-0/+31
|\ | | | | | | | | | | | | | | | | | | | | | | 4497: Create LowerCtx on the fly r=matklad a=edwin0cheng Previously we create `LowerCtx` at the beginning of lowering, however, the hygiene content is in fact changing between macro expression expanding. This PR change it to create the `LowerCtx` on the fly to fix above bug. However, #4465 is not fixed by this PR, the goto-def is still not work yet. It only fixed the infer part. Co-authored-by: Edwin Cheng <[email protected]>
| * Create LowerCtx on the flyEdwin Cheng2020-05-171-0/+31
| |
* | Add more tests for Fn traitsHrvoje Ban2020-05-181-0/+132
| |
* | Allow calling dyn trait super trait methods without the super trait in scopeFlorian Diebold2020-05-161-0/+31
|/ | | | | This also removes some vestiges of the old impl trait support which I think aren't currently in use.
* Handle `Self` in values and patternsFlorian Diebold2020-05-152-0/+83
| | | | | | | | | 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.
* Omit default types in HirDisplay SourceCode modeTimo Freiberg2020-05-101-0/+27
|
* infer: Make expected rhs type for plain assign the lhs typeEmil Lauridsen2020-05-101-0/+29
| | | | | | | | | | | | | This fixes an issue where the following code sample would fail to infer the type contained in the option: ```rust fn main() { let mut end = None; // TODO: Fix inference for this in RA loop { end = Some(true); } } ```
* Merge #4175bors[bot]2020-05-091-0/+23
|\ | | | | | | | | | | | | | | | | | | | | | | 4175: Introduce HirDisplay method for rendering source code & use it in add_function assist r=flodiebold a=TimoFreiberg Next feature for #3639. So far the only change in the new `HirDisplay` method is that paths are qualified, but more changes will be necessary (omitting the function name from function types, returning an error instead of printing `"{unknown}"`, probably more). Is that approach okay? Co-authored-by: Timo Freiberg <[email protected]>
| * New HirDisplay method for displaying sourcecodeTimo Freiberg2020-05-081-0/+23
| |
* | Handle coercing function types to function pointers in matchFlorian Diebold2020-05-081-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* | Handle break somewhat betterFlorian Diebold2020-05-081-1/+71
| | | | | | | | | | 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-084-9/+114
|/ | | | | | | | 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-082-8/+9
| | | | They're `&[u8; N]`, not `&[u8]` (see #4374).
* Rename ImplItem to AssocItemEdwin Cheng2020-05-051-2/+2
|
* Merge #4305bors[bot]2020-05-051-0/+29
|\ | | | | | | | | | | | | | | 4305: Favor types for record type struct in name resolution r=matklad a=edwin0cheng Fixed #4235 Co-authored-by: Edwin Cheng <[email protected]>
| * Add test for issueEdwin Cheng2020-05-041-0/+29
| |
* | Remove whitespacesEdwin Cheng2020-05-031-1/+1
| |
* | Support macro for trait itemsEdwin Cheng2020-05-031-19/+21
|/
* Merge #4234bors[bot]2020-05-021-0/+26
|\ | | | | | | | | | | | | | | | | | | | | | | 4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng This PR implements `#[macro_export(local_inner_macros)]` support. Note that the rustc implementation is quite [hacky][1] too. :) [1]: https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456 Co-authored-by: Edwin Cheng <[email protected]>
| * Support local_inner_macrosEdwin Cheng2020-05-011-0/+26
| |
* | Add smoke test for decorated blocksAleksey Kladov2020-05-021-0/+32
| |
* | Add testEdwin Cheng2020-05-011-0/+40
|/
* Merge #4173bors[bot]2020-04-271-4/+29
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4173: Use core instead of std for builtin derive macros r=edwin0cheng a=edwin0cheng Fixed #4087. We can't use `$crate` here right now because : 1. We have to able to detect `macro` 2.0 in collecting phase for finding `rustc_builtin_macro` attrs. 2. And we have to make hygiene works for builtin derive macro. r= @flodiebold Co-authored-by: Edwin Cheng <[email protected]>
| * Use empty-deps tricks to detect it is coreEdwin Cheng2020-04-271-6/+5
| |
| * Add testEdwin Cheng2020-04-271-0/+26
| |
| * Use core instead of std for builtin derive macrosEdwin Cheng2020-04-271-4/+4
| |
* | For associated type shorthand (T::Item), use the substs from the where clauseFlorian Diebold2020-04-261-0/+30
|/ | | | | So e.g. if we have `fn foo<T: SomeTrait<u32>>() -> T::Item`, we want to lower that to `<T as SomeTrait<u32>>::Item` and not `<T as SomeTrait<_>>::Item`.
* Convert tests to text-sizeAleksey Kladov2020-04-257-2192/+2192
|
* Fix wrong substitution codeFlorian Diebold2020-04-231-0/+41
| | | | | | | We need to shift in when we're substituting inside a binder. This should fix #4053 (it doesn't fix the occasional overflow that also occurs on the Diesel codebase though).
* Correctly infer types in guard expressionsAleksey Kladov2020-04-181-0/+26
| | | | | | | The root cause was that we forgot to add bindings from the arm to the guard expression closes #3980