diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-20 14:36:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-20 14:36:53 +0000 |
commit | d590f6ce12bf4d0311138846e26951b613f0afd4 (patch) | |
tree | d73816f61ccdaa2b9710ff5c7efbb3b62367c9c3 /crates/ra_hir_ty/src/infer | |
parent | 81a1b14d78d6078c63dd42c09da5a3e171c85a3a (diff) | |
parent | 76d688a328ab53b6264f9e489b88524377a7271d (diff) |
Merge #2592
2592: Add std::ops::Index support for infering r=edwin0cheng a=edwin0cheng
see also #2534
Seem like this can't fix #2534 for this case:
```rust
fn foo3(bar: [usize; 2]) {
let baz = bar[1]; // <--- baz is still unknown ?
println!("{}", baz);
}
```
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/infer')
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 6917c183b..8be567917 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -422,10 +422,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
422 | } | 422 | } |
423 | } | 423 | } |
424 | Expr::Index { base, index } => { | 424 | Expr::Index { base, index } => { |
425 | let _base_ty = self.infer_expr_inner(*base, &Expectation::none()); | 425 | let base_ty = self.infer_expr_inner(*base, &Expectation::none()); |
426 | let _index_ty = self.infer_expr(*index, &Expectation::none()); | 426 | let index_ty = self.infer_expr(*index, &Expectation::none()); |
427 | // FIXME: use `std::ops::Index::Output` to figure out the real return type | 427 | |
428 | Ty::Unknown | 428 | self.resolve_associated_type_with_params( |
429 | base_ty, | ||
430 | self.resolve_ops_index_output(), | ||
431 | &[index_ty], | ||
432 | ) | ||
429 | } | 433 | } |
430 | Expr::Tuple { exprs } => { | 434 | Expr::Tuple { exprs } => { |
431 | let mut tys = match &expected.ty { | 435 | let mut tys = match &expected.ty { |