aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge #1815bors[bot]2019-09-272-5/+37
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1815: Support correct `$crate` expansion in macros r=uHOOCCOOHu a=uHOOCCOOHu This PR makes normal use cases of `$crate` from macros work as expected. It makes more macros from `std` work. Type inference works well with `panic`, `unimplemented`, `format`, and maybe more. Sadly that `vec![1, 2, 3]` still not works, but it is not longer an issue about macro. Screenshot: ![Screenshot_20190927_022136](https://user-images.githubusercontent.com/14816024/65714465-b4568f80-e0cd-11e9-8043-dd44c2ae8040.png) Co-authored-by: uHOOCCOOHu <[email protected]>
| * Support `$crate` in item and expr place.uHOOCCOOHu2019-09-261-0/+33
| |
| * Refactor `Name` ready for hygienic macrouHOOCCOOHu2019-09-261-5/+4
| |
* | Add SubstsBuilderFlorian Diebold2019-09-268-116/+66
|/ | | | + further refactoring.
* Support all coercion placesuHOOCCOOHu2019-09-253-96/+216
|
* Support custom `CoerceUnsized`uHOOCCOOHu2019-09-254-247/+476
| | | | Split out tests about coercion
* Better handle never type and branch merginguHOOCCOOHu2019-09-254-181/+391
| | | | Split out tests for never type to another file
* Support basic implicit type coerceuHOOCCOOHu2019-09-252-142/+383
|
* Support auto-deref in argument positionuHOOCCOOHu2019-09-252-1/+161
|
* Resolve trait associated itemsFlorian Diebold2019-09-253-13/+59
| | | | E.g. `Default::default` or `<Foo as Default>::default`.
* Fix retrieval of the Fn traitsFlorian Diebold2019-09-251-3/+2
| | | | | I used the wrong query, so it only used the lang items from the respective crate...
* Merge #1906bors[bot]2019-09-251-2/+5
|\ | | | | | | | | | | | | | | 1906: Add missing lang-items to `def_crates` r=matklad a=sinkuu Co-authored-by: Shotaro Yamada <[email protected]>
| * Add missing lang-items to `def_crates`Shotaro Yamada2019-09-251-2/+5
| |
* | Remove redundant clone()Shotaro Yamada2019-09-252-3/+3
|/
* Implement the call argument checking order hack for closuresFlorian Diebold2019-09-243-12/+108
|
* Make the closure_1 test workFlorian Diebold2019-09-243-27/+40
|
* Make closures impl closure traitsFlorian Diebold2019-09-243-38/+185
|
* Give closures typesFlorian Diebold2019-09-243-20/+36
|
* Upgrade Chalk againFlorian Diebold2019-09-241-3/+6
|
* Upgrade ChalkFlorian Diebold2019-09-231-4/+6
|
* Split off path expression inference code into submoduleFlorian Diebold2019-09-232-172/+199
|
* Handle projection types from ChalkFlorian Diebold2019-09-221-1/+5
|
* Handle associated type shorthand (`T::Item`)Florian Diebold2019-09-222-17/+144
| | | | | | | | | | | | This is only allowed for generic parameters (including `Self` in traits), and special care needs to be taken to not run into cycles while resolving it, because we use the where clauses of the generic parameter to find candidates for the trait containing the associated type, but the where clauses may themselves contain instances of short-hand associated types. In some cases this is even fine, e.g. we might have `T: Trait<U::Item>, U: Iterator`. If there is a cycle, we'll currently panic, which isn't great, but better than overflowing the stack...
* account for impls generated by macrosAleksey Kladov2019-09-181-0/+17
|
* Remove assoc type selection code for now to fix crashesFlorian Diebold2019-09-172-25/+10
|
* Add test for `T::Item` cyclesFlorian Diebold2019-09-171-0/+42
|
* Remove TraitItem and ImplItem in favor of AssocItemFlorian Diebold2019-09-173-23/+20
|
* Small review improvementsFlorian Diebold2019-09-171-5/+3
|
* Add test for `<T>::Item`Florian Diebold2019-09-171-10/+22
|
* Refactor some moreFlorian Diebold2019-09-172-49/+85
| | | | | | Type-relative paths (`<T>::foo`) also need to work in type context, for example `<T>::Item` is legal. So rather than returning the type ref from the resolver function, just check it before.
* Refactor associated item resolution moreFlorian Diebold2019-09-172-124/+120
| | | | | When resolving an associated item in value namespace, use the `Ty` lowering code for the segments before the last instead of replicating it.
* Refactor a bit to prepare for resolving trait assoc itemsFlorian Diebold2019-09-171-30/+27
|
* Resolve assoc types on type parametersFlorian Diebold2019-09-172-24/+61
| | | | | | E.g. `fn foo<T: Iterator>() -> T::Item`. It seems that rustc does this only for type parameters and only based on their bounds, so we also only consider traits from bounds.
* Adapt some testsFlorian Diebold2019-09-171-12/+12
|
* Merge #1817bors[bot]2019-09-163-76/+111
|\ | | | | | | | | | | | | | | 1817: Support path starting with a type r=matklad a=uHOOCCOOHu The path syntax `<Ty>::foo` Co-authored-by: uHOOCCOOHu <[email protected]>
| * Define known paths and group namesuHOOCCOOHu2019-09-152-26/+13
| |
| * Support path starting with a typeuHOOCCOOHu2019-09-152-65/+113
| |
* | Gracefully handle `const _` items in `ConstData`Dylan MacKenzie2019-09-161-1/+1
|/
* Support bare `Trait` without dynFlorian Diebold2019-09-142-12/+11
|
* Upgrade ChalkFlorian Diebold2019-09-142-13/+0
| | | | ... and remove Ty::UnselectedProjection. It'll be handled differently.
* Specify desirable namespace when calling resolveAleksey Kladov2019-09-132-188/+176
| | | | That way, we are able to get rid of a number of unreachable statements
* rename AdtDef -> AdtAleksey Kladov2019-09-122-20/+18
|
* generalize impl_froms to nested enumsAleksey Kladov2019-09-121-19/+9
|
* make various enums "inherit" from AdtDefAleksey Kladov2019-09-122-32/+32
|
* start cleaning up the resolutionAleksey Kladov2019-09-122-36/+12
| | | | | | | Nameres related types, like `PerNs<Resolution>`, can represent unreasonable situations, like a local in a type namespace. We should clean this up, by requiring that call-site specifies the kind of resolution it expects.
* Infer box expressionuHOOCCOOHu2019-09-112-0/+57
|
* Fix typouHOOCCOOHu2019-09-111-1/+1
|
* Merge #1795bors[bot]2019-09-091-0/+58
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1795: Make macro scope a real name scope and fix some details r=matklad a=uHOOCCOOHu This PR make macro's module scope a real name scope in `PerNs`, instead of handling `Either<PerNs, MacroDef>` everywhere. In `rustc`, the macro scope behave exactly the same as type and value scope. It is valid that macros, types and values having exact the same name, and a `use` statement will import all of them. This happened to module `alloc::vec` and macro `alloc::vec!`. So `Either` is not suitable here. There is a trap that not only does `#[macro_use]` import all `#[macro_export] macro_rules`, but also imports all macros `use`d in the crate root. In other words, it just _imports all macros in the module scope of crate root_. (Visibility of `use` doesn't matter.) And it also happened to `libstd` which has `use alloc_crate::vec;` in crate root to re-export `alloc::vec`, which it both a module and a macro. The current implementation of `#[macro_use] extern crate` doesn't work here, so that is why only macros directly from `libstd` like `dbg!` work, while `vec!` from `liballoc` doesn't. This PR fixes this. Another point is that, after some tests, I figure out that _`macro_rules` does NOT define macro in current module scope at all_. It defines itself in legacy textual scope. And if `#[macro_export]` is given, it also is defined ONLY in module scope of crate root. (Then being `macro_use`d, as mentioned above) (Well, the nightly [Declarative Macro 2.0](https://github.com/rust-lang/rust/issues/39412) simply always define in current module scope only, just like normal items do. But it is not yet supported by us) After this PR, in my test, all non-builtin macros are resolved now. (Hover text for documentation is available) So it fixes #1688 . Since compiler builtin macros are marked as `#[rustc_doc_only_macro]` instead of `#[macro_export]`, we can simply tweak the condition to let it resolved, but it may cause expansion error. Some critical notes are also given in doc-comments. <img width="447" alt="Screenshot_20190909_223859" src="https://user-images.githubusercontent.com/14816024/64540366-ac1ef600-d352-11e9-804f-566ba7559206.png"> Co-authored-by: uHOOCCOOHu <[email protected]>
| * StripuHOOCCOOHu2019-09-091-3/+0
| |
| * Make macro scope a real name scopeuHOOCCOOHu2019-09-092-0/+61
| | | | | | | | Fix some details about module scoping