mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
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 <edwin0cheng@gmail.com>
This commit is contained in:
commit
d590f6ce12
5 changed files with 61 additions and 5 deletions
|
@ -422,10 +422,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
}
|
||||
}
|
||||
Expr::Index { base, index } => {
|
||||
let _base_ty = self.infer_expr_inner(*base, &Expectation::none());
|
||||
let _index_ty = self.infer_expr(*index, &Expectation::none());
|
||||
// FIXME: use `std::ops::Index::Output` to figure out the real return type
|
||||
Ty::Unknown
|
||||
let base_ty = self.infer_expr_inner(*base, &Expectation::none());
|
||||
let index_ty = self.infer_expr(*index, &Expectation::none());
|
||||
|
||||
self.resolve_associated_type_with_params(
|
||||
base_ty,
|
||||
self.resolve_ops_index_output(),
|
||||
&[index_ty],
|
||||
)
|
||||
}
|
||||
Expr::Tuple { exprs } => {
|
||||
let mut tys = match &expected.ty {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue