aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
Commit message (Collapse)AuthorAgeFilesLines
* Update the rest of the testsAleksey Kladov2020-06-296-413/+276
|
* (T): make typification tests more data drivenAleksey Kladov2020-06-292-133/+74
|
* (Partially) fix handling of type params depending on type paramsFlorian Diebold2020-06-291-0/+45
| | | | | | | | If the first type parameter gets inferred, that's still not handled correctly; it'll require some more refactoring: E.g. if we have `Thing<T, F=fn() -> T>` and then instantiate `Thing<_>`, that gets turned into `Thing<_, fn() -> _>` before the `_` is instantiated into a type variable -- so afterwards, we have two type variables without any connection to each other.
* Track unsafe blocks, don't trigger missing unsafe diagnostic when unsafe ↵Paul Daniel Faria2020-06-271-0/+1
| | | | exprs within unsafe block
* Merge #4982bors[bot]2020-06-272-23/+27
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4982: Bump chalk r=matklad a=lnicola This passes the tests, but fails in a weird way on `analysis-stats`: ``` thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-solve-0.14.0/src/clauses/builtin_traits/fn_family.rs:96:20 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:78 3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt at src/libstd/sys_common/backtrace.rs:59 4: core::fmt::write at src/libcore/fmt/mod.rs:1076 5: std::io::Write::write_fmt at src/libstd/io/mod.rs:1537 6: std::sys_common::backtrace::_print at src/libstd/sys_common/backtrace.rs:62 7: std::sys_common::backtrace::print at src/libstd/sys_common/backtrace.rs:49 8: std::panicking::default_hook::{{closure}} at src/libstd/panicking.rs:198 9: std::panicking::default_hook at src/libstd/panicking.rs:218 10: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:477 11: rust_begin_unwind at src/libstd/panicking.rs:385 12: core::panicking::panic_fmt at src/libcore/panicking.rs:86 13: core::panicking::panic at src/libcore/panicking.rs:51 14: chalk_solve::clauses::builtin_traits::fn_family::add_fn_trait_program_clauses 15: chalk_solve::clauses::builder::ClauseBuilder<I>::push_binders 16: chalk_solve::clauses::program_clauses_that_could_match 17: chalk_solve::clauses::program_clauses_for_goal 18: chalk_solve::recursive::Solver<I>::solve_new_subgoal 19: <chalk_solve::recursive::Solver<I> as chalk_solve::recursive::solve::SolveDatabase<I>>::solve_goal 20: chalk_solve::recursive::Solver<I>::solve_root_goal 21: chalk_solve::solve::Solver<I>::solve_limited 22: ra_hir_ty::traits::trait_solve_query 23: salsa::runtime::Runtime<DB>::execute_query_implementation 24: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade 25: salsa::derived::slot::Slot<DB,Q,MP>::read 26: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch 27: salsa::QueryTable<DB,Q>::get 28: <T as ra_hir_ty::db::HirDatabase>::trait_solve 29: ra_hir_ty::infer::InferenceContext::resolve_ty_as_possible 30: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner 31: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce 32: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::check_call_arguments 33: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_method_call 34: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner 35: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr 36: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_method_call 37: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner 38: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce 39: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner 40: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner 41: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce 42: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner 43: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce 44: ra_hir_ty::infer::infer_query 45: salsa::runtime::Runtime<DB>::execute_query_implementation 46: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade 47: salsa::derived::slot::Slot<DB,Q,MP>::read 48: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch 49: ra_hir_ty::db::infer_wait 50: rust_analyzer::cli::analysis_stats::analysis_stats 51: rust_analyzer::main 52: std::rt::lang_start::{{closure}} 53: std::rt::lang_start_internal::{{closure}} at src/libstd/rt.rs:52 54: std::panicking::try::do_call at src/libstd/panicking.rs:297 55: std::panicking::try at src/libstd/panicking.rs:274 56: std::panic::catch_unwind at src/libstd/panic.rs:394 57: std::rt::lang_start_internal at src/libstd/rt.rs:51 58: main 59: __libc_start_main 60: _start note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ``` It's as if we're returning `None` for a well-known trait that `chalk` asks about. That seems to happen for `Deref`, `CoerceUnsized` and `Try`. r? @flodiebold Co-authored-by: Laurențiu Nicola <[email protected]>
| * Bump chalkLaurențiu Nicola2020-06-262-23/+27
| |
* | Merge #5033bors[bot]2020-06-271-0/+46
|\ \ | |/ |/| | | | | | | | | | | 5033: Order of glob imports should not affect import shadowing r=Nashenas88 a=Nashenas88 Fixes #5032 Co-authored-by: Paul Daniel Faria <[email protected]>
| * Split glob import map to per-ns, switch ExprCollector to use a simpler push_resPaul Daniel Faria2020-06-261-0/+46
| |
* | Infer type for slice wildcard patternsadamrk2020-06-252-0/+27
|/
* Fix string literal inference in matchLaurențiu Nicola2020-06-241-0/+57
|
* Use only one code-path for parsing fixturesAleksey Kladov2020-06-238-2692/+2692
| | | | | This removes leading newlines everywhere, shifting all ranges in tests by one
* Remove RelativePathBuf from fixtureAleksey Kladov2020-06-221-1/+1
| | | | | The paths in fixture are not really relative (the default one is `/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.
* Merge #4958bors[bot]2020-06-201-0/+223
|\ | | | | | | | | | | | | | | | | 4958: Infer FnSig via Fn traits r=flodiebold a=adamrk Addresses https://github.com/rust-analyzer/rust-analyzer/issues/4481. When inferring types check if the callee implements one of the builtin `Fn` traits. Also autoderef the callee before trying to figure out it's `FnSig`. Co-authored-by: adamrk <[email protected]>
| * Push obligation instead of matching on solutionadamrk2020-06-201-4/+4
| |
| * Add test for dyn Fn Outputadamrk2020-06-201-0/+68
| |
| * move tests to ra_hir_tyadamrk2020-06-201-0/+155
| |
* | Shift bound variables correctly when using assoc type shorthandFlorian Diebold2020-06-191-0/+91
| | | | | | | | | | Fixes #4885. Fixes #4800.
* | 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).