aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
Commit message (Collapse)AuthorAgeFilesLines
* Merge #1969bors[bot]2019-10-081-2/+1
|\ | | | | | | | | | | | | | | 1969: restore coloring of attributes r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
| * macro DSL for cfg in testsAleksey Kladov2019-10-081-6/+1
| |
| * use slightly more idiomatic api for cfgAleksey Kladov2019-10-081-1/+5
| |
* | Support inferring `Self` type in enum definitionsice10002019-10-081-0/+19
|/ | | | Signed-off-by: ice1000 <[email protected]>
* Merge #1928bors[bot]2019-10-051-0/+45
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1928: Support `#[cfg(..)]` r=matklad a=oxalica This PR implement `#[cfg(..)]` conditional compilation. It read default cfg options from `rustc --print cfg` with also hard-coded `test` and `debug_assertion` enabled. Front-end settings are **not** included in this PR. There is also a known issue that inner control attributes are totally ignored. I think it is **not** a part of `cfg` and create a separated issue for it. #1949 Fixes #1920 Related: #1073 Co-authored-by: uHOOCCOOHu <[email protected]> Co-authored-by: oxalica <[email protected]>
| * Support cfg attribute on impl blocksuHOOCCOOHu2019-10-021-0/+45
| |
* | Handle divergence in type inference for blocksLaurențiu Nicola2019-10-021-1/+62
|/
* Merge #1815bors[bot]2019-09-271-0/+33
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| |
* | Add SubstsBuilderFlorian Diebold2019-09-261-1/+0
|/ | | | + further refactoring.
* Support all coercion placesuHOOCCOOHu2019-09-251-65/+62
|
* Support custom `CoerceUnsized`uHOOCCOOHu2019-09-251-197/+5
| | | | Split out tests about coercion
* Better handle never type and branch merginguHOOCCOOHu2019-09-251-121/+40
| | | | Split out tests for never type to another file
* Support basic implicit type coerceuHOOCCOOHu2019-09-251-56/+215
|
* Support auto-deref in argument positionuHOOCCOOHu2019-09-251-0/+118
|
* Resolve trait associated itemsFlorian Diebold2019-09-251-8/+7
| | | | E.g. `Default::default` or `<Foo as Default>::default`.
* Implement the call argument checking order hack for closuresFlorian Diebold2019-09-241-0/+80
|
* Make the closure_1 test workFlorian Diebold2019-09-241-27/+27
|
* Make closures impl closure traitsFlorian Diebold2019-09-241-27/+28
|
* Give closures typesFlorian Diebold2019-09-241-16/+14
|
* Handle associated type shorthand (`T::Item`)Florian Diebold2019-09-221-8/+56
| | | | | | | | | | | | 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-171-6/+6
|
* Add test for `T::Item` cyclesFlorian Diebold2019-09-171-0/+42
|
* Add test for `<T>::Item`Florian Diebold2019-09-171-10/+22
|
* Resolve assoc types on type parametersFlorian Diebold2019-09-171-3/+3
| | | | | | 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
|
* Support path starting with a typeuHOOCCOOHu2019-09-151-0/+58
|
* Support bare `Trait` without dynFlorian Diebold2019-09-141-10/+10
|
* Infer box expressionuHOOCCOOHu2019-09-111-0/+31
|
* 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]>
| * Make macro scope a real name scopeuHOOCCOOHu2019-09-091-0/+58
| | | | | | | | Fix some details about module scoping
* | modify testsNiko Matsakis2019-09-091-6/+6
|/ | | | | | | | Some method resolution tests now yield `{unknown}` where they did not before. Other tests now succeed, likely because this is helping the solver steer its efforts.
* Rename `textual_macro` -> `legacy_macro`uHOOCCOOHu2019-09-081-1/+1
| | | | Add comments
* Resolve textual scoped macros inside itemuHOOCCOOHu2019-09-081-0/+35
|
* Fix crash for super trait cyclesFlorian Diebold2019-09-071-0/+21
|
* Fix Chalk environmentsFlorian Diebold2019-09-071-2/+2
| | | | | The clauses need to be wrapped in `FromEnv` clauses for elaboration (i.e. things like inferring `T: Clone` from `T: Copy`) to work correctly.
* Use traits from where clauses for method resolutionFlorian Diebold2019-09-071-11/+10
| | | | | E.g. if we have `T: some::Trait`, we can call methods from that trait without it needing to be in scope.
* Lower `Fn(X, Y) -> Z` pathsFlorian Diebold2019-09-071-8/+8
|
* Lower bounds on trait definition, and resolve assoc types from super traitsFlorian Diebold2019-09-071-5/+5
|
* Add some more testsFlorian Diebold2019-09-071-0/+205
|
* Properly format `impl Trait<Type = Foo>` typesFlorian Diebold2019-09-031-4/+4
| | | | | | It's a bit complicated because we basically have to 'undo' the desugaring, and the result is very dependent on the specifics of the desugaring and will probably produce weird results otherwise.
* Add support for associated type bindings (`where Trait<Type = X>`)Florian Diebold2019-09-031-18/+44
|
* Add test for assoc type bindingsFlorian Diebold2019-09-031-0/+65
|
* Correctly build BodySourceMap for macro-expanded expressionsAleksey Kladov2019-09-031-8/+25
|
* fix hir for new block syntaxAleksey Kladov2019-09-021-1/+1
|
* :arrow_up: instaAleksey Kladov2019-08-291-1167/+1265
|
* Remove redundant testsKirill Bulatov2019-08-261-63/+5
|
* Make infer_block not unify; add back calculate_least_upper_boundFlorian Diebold2019-08-261-10/+12
|