remove match statement, handle suffix
This commit is contained in:
parent
d0e282f6b1
commit
b9ef7a6b98
2 changed files with 11 additions and 14 deletions
|
@ -185,21 +185,18 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
self.write_pat_ty(pat, bound_ty);
|
self.write_pat_ty(pat, bound_ty);
|
||||||
return inner_ty;
|
return inner_ty;
|
||||||
}
|
}
|
||||||
Pat::Slice { prefix, slice, suffix } => {
|
Pat::Slice { prefix, slice: _slice, suffix } => {
|
||||||
if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected {
|
let ty = if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Slice, parameters }) = expected {
|
||||||
match (prefix.as_slice(), slice, suffix.as_slice()) {
|
for pat_id in prefix.iter().chain(suffix) {
|
||||||
(prefix_pat_ids, None, []) => {
|
self.infer_pat(*pat_id, parameters.as_single(), default_bm);
|
||||||
for pat_id in prefix_pat_ids {
|
|
||||||
self.infer_pat(*pat_id, parameters.as_single(), default_bm);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ty::apply_one(TypeCtor::Slice, parameters.as_single().clone())
|
|
||||||
},
|
|
||||||
_ => Ty::Unknown,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameters.as_single().clone()
|
||||||
} else {
|
} else {
|
||||||
Ty::Unknown
|
Ty::Unknown
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Ty::apply_one(TypeCtor::Slice, ty)
|
||||||
}
|
}
|
||||||
_ => Ty::Unknown,
|
_ => Ty::Unknown,
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,8 +53,8 @@ fn test(x: &i32) {
|
||||||
[140; 141) 'g': {unknown}
|
[140; 141) 'g': {unknown}
|
||||||
[144; 145) 'e': {unknown}
|
[144; 145) 'e': {unknown}
|
||||||
[158; 205) 'if let... }': ()
|
[158; 205) 'if let... }': ()
|
||||||
[165; 170) '[val]': {unknown}
|
[165; 170) '[val]': [{unknown}]
|
||||||
[173; 176) 'opt': {unknown}
|
[173; 176) 'opt': [{unknown}]
|
||||||
[177; 205) '{ ... }': ()
|
[177; 205) '{ ... }': ()
|
||||||
[191; 192) 'h': {unknown}
|
[191; 192) 'h': {unknown}
|
||||||
[195; 198) 'val': {unknown}
|
[195; 198) 'val': {unknown}
|
||||||
|
|
Loading…
Add table
Reference in a new issue