aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty.rs
Commit message (Collapse)AuthorAgeFilesLines
* Handle impl/dyn Trait in method resolutionFlorian Diebold2019-08-221-0/+13
| | | | | | | | | | | | | When we have one of these, the `Trait` doesn't need to be in scope to call its methods. So we need to consider this when looking for method candidates. (Actually I think the same is true when we have a bound `T: some::Trait`, but we don't handle that yet). At the same time, since Chalk doesn't handle these types yet, add a small hack to skip Chalk in method resolution and just consider `impl Trait: Trait` always true. This is enough to e.g. get completions for `impl Trait`, but since we don't do any unification we won't infer the return type of e.g. `impl Into<i64>::into()`.
* Add `impl Trait` and `dyn Trait` typesFlorian Diebold2019-08-221-10/+110
| | | | | | | - refactor bounds handling in the AST a bit - add HIR for bounds - add `Ty::Dyn` and `Ty::Opaque` variants and lower `dyn Trait` / `impl Trait` syntax to them
* Improve debug logging a bitFlorian Diebold2019-08-121-0/+14
|
* Add representations of associated typesFlorian Diebold2019-08-121-0/+86
| | | | | | | | | | | | This adds three different representations, copied from the Chalk model: - `Ty::Projection` is an associated type projection written somewhere in the code, like `<Foo as Trait>::Bar`. - `Ty::UnselectedProjection` is similar, but we don't know the trait yet (`Foo::Bar`). - The above representations are normalized to their actual types during type inference. When that isn't possible, for example for `T::Item` inside an `fn foo<T: Iterator>`, the type is normalized to an application type with `TypeCtor::AssociatedType`.
* provide completion in struct patternsEkaterina Babshukova2019-07-211-1/+1
|
* Some renamings for clarityFlorian Diebold2019-07-141-1/+1
|
* Unify `normalize` and `implements` to simplify codeFlorian Diebold2019-07-081-1/+1
|
* Refactor a bit & introduce Environment structFlorian Diebold2019-07-081-1/+1
|
* Add trait obligations for where clauses when calling functions/methodsFlorian Diebold2019-07-061-2/+2
| | | | | E.g. if we call `foo<T: Into<u32>>(x)`, that adds an obligation that `x: Into<u32>`, etc.
* allow rustfmt to reorder importsAleksey Kladov2019-07-041-5/+8
| | | | | | This wasn't a right decision in the first place, the feature flag was broken in the last rustfmt release, and syntax highlighting of imports is more important anyway
* Simplifications / cleanup from reviewFlorian Diebold2019-06-161-0/+1
|
* Somewhat handle variables in the derefed type, and add another testFlorian Diebold2019-06-151-0/+11
|
* Implement autoderef using the Deref traitFlorian Diebold2019-06-151-2/+3
| | | | - add support for other lang item targets, since we need the Deref lang item
* Add basic infrastructure for assoc type projectionFlorian Diebold2019-06-151-1/+10
|
* Fix clippy::or_fun_callAlan Du2019-06-041-1/+1
|
* add union to code_modelAleksey Kladov2019-05-231-0/+1
|
* profile type inferenceAleksey Kladov2019-05-211-1/+1
|
* Add infer for generic default typeEdwin Cheng2019-05-191-1/+1
|
* Handle where clauses in trait solvingFlorian Diebold2019-05-111-1/+30
|
* Add a HirDisplay implementation for TraitRefFlorian Diebold2019-05-071-0/+17
|
* Turn `implements` into a query againFlorian Diebold2019-05-071-1/+1
|
* Differentiate Tuple / FnPtr type constructors by cardinalityFlorian Diebold2019-05-041-7/+9
| | | | | This is necessary because Chalk (reasonably) expects each 'struct' to know how many type parameters it takes.
* Simplify subst / subst_bound_vars a bitFlorian Diebold2019-05-041-12/+2
|
* Canonicalize before doing method resolutionFlorian Diebold2019-05-041-0/+11
|
* Implement Deref<Target=[Ty]> for SubstsFlorian Diebold2019-05-041-17/+18
|
* Chalk integrationFlorian Diebold2019-05-041-1/+48
| | | | | - add proper canonicalization logic - add conversions from/to Chalk IR
* Add Ty::Bound variant for use in Chalk integrationFlorian Diebold2019-05-041-2/+7
|
* Make callable signature handling a bit nicerFlorian Diebold2019-04-141-0/+22
|
* More trait infrastructureFlorian Diebold2019-04-141-0/+11
| | | | | | | | | | - make it possible to get parent trait from method - add 'obligation' machinery for checking that a type implements a trait (and inferring facts about type variables from that) - handle type parameters of traits (to a certain degree) - improve the hacky implements check to cover enough cases to exercise the handling of traits with type parameters - basic canonicalization (will probably also be done by Chalk)
* Make call info to use real name resolutionAleksey Kladov2019-04-111-2/+12
|
* Added ArrayExprKind,Lenard Pratt2019-04-071-1/+1
| | | | | changed the display for fixed array types, Added Array Enum to ra_hir/expr
* Added inference of array lengthLenard Pratt2019-04-071-1/+5
|
* Implement a very naive implements checkFlorian Diebold2019-03-251-4/+19
| | | | ... to make the infer_trait_method_simple test have the correct result.
* Assert in apply_substs that the number of parameters doesn't changeFlorian Diebold2019-03-211-1/+6
| | | | ... and fix a small bug revealed by that.
* Rename name field to ctor as wellFlorian Diebold2019-03-211-14/+14
|
* Some more doc commentsFlorian Diebold2019-03-211-2/+12
|
* TypeName => TypeCtorFlorian Diebold2019-03-211-24/+24
|
* Remove the old variants replaced by Ty::ApplyFlorian Diebold2019-03-211-197/+41
|
* Add Ty::ApplyFlorian Diebold2019-03-211-1/+177
|
* Represent FnPtr and Tuple using SubstsFlorian Diebold2019-03-211-15/+19
|
* Remove FnSig from FnDef typeFlorian Diebold2019-03-161-12/+6
| | | | | It doesn't need to be in there since it's just information from the def. Another step towards aligning Ty with Chalk's representation.
* Refactor FnSig a bitFlorian Diebold2019-03-161-34/+47
|
* Some more Ty displaying cleanupFlorian Diebold2019-03-161-2/+2
|
* Replace Display by a pretty printing trait for TyFlorian Diebold2019-03-161-34/+60
| | | | | This allows removing the names from Adt and FnDef (and more later), as a first step towards aligning more with chalk's Ty :)
* Represent unknown types as {unknown} instead of [unknown]Florian Diebold2019-03-031-1/+1
| | | | Since the latter could actually be a real type...
* A bit of cleanup in ty.rsFlorian Diebold2019-03-021-28/+1
|
* Split ty.rs into several modulesFlorian Diebold2019-02-231-1450/+18
| | | | | | | | | It was just getting too big. We now have: - ty: the `Ty` enum and helpers - ty::infer: actual type inference - ty::lower: lowering from HIR to `Ty` - ty::op: helpers for binary operations, currently
* Fix resolution of associated method calls across cratesFlorian Diebold2019-02-231-0/+9
| | | | | | I think it'll be better to make the path resolution the number of unresolved segments, not the first unresolved index; then this error could simply not have happened. But I'll do that separately.
* Merge #866bors[bot]2019-02-221-6/+46
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | 866: Implement basic support for Associated Methods r=flodiebold a=vipentti This is my attempt at learning to understand how the type inference works by adding basic support for associated methods. Currently it does not resolve associated types or constants. The basic idea is that `Resolver::resolve_path` returns a new `PathResult` type, which has two variants, `FullyResolved` and `PartiallyResolved`, fully resolved matches the previous behavior, where as `PartiallyResolved` contains the `PerNs<Resolution` in addition to a `segment_index` which contains the index of the segment which we failed to resolve. This index can then be used to continue inference in `infer_path_expr` using the `Type` we managed to resolve. This changes some of the previous apis, so looking for feedback and suggestions. This should enable fixing #832 Co-authored-by: Ville Penttinen <[email protected]>
| * Change resolve_path to return the fully resolved path or PerNs::noneVille Penttinen2019-02-221-20/+19
| | | | | | | | | | | | This also adds new pub(crate) resolve_path_segments which returns the PathResult, which may or may not be fully resolved. PathResult is also now pub(crate) since it is an implementation detail.