review comments
This commit is contained in:
parent
3e6b84474d
commit
daed674815
@ -821,11 +821,11 @@ pub fn try_coerce(
|
||||
|
||||
let (adjustments, _) = self.register_infer_ok_obligations(ok);
|
||||
self.apply_adjustments(expr, adjustments);
|
||||
if expr_ty.references_error() {
|
||||
Ok(self.tcx.types.err)
|
||||
Ok(if expr_ty.references_error() {
|
||||
self.tcx.types.err
|
||||
} else {
|
||||
Ok(target)
|
||||
}
|
||||
target
|
||||
})
|
||||
}
|
||||
|
||||
/// Same as `try_coerce()`, but without side-effects.
|
||||
|
@ -3751,36 +3751,25 @@ pub fn check_decl_local(&self, local: &'tcx hir::Local) {
|
||||
|
||||
if let Some(ref init) = local.init {
|
||||
let init_ty = self.check_decl_initializer(local, &init);
|
||||
if init_ty.references_error() {
|
||||
// Override the types everywhere with `types.err` to avoid knock down errors.
|
||||
self.write_ty(local.hir_id, init_ty);
|
||||
self.write_ty(local.pat.hir_id, init_ty);
|
||||
self.locals.borrow_mut().insert(local.hir_id, LocalTy {
|
||||
decl_ty: t,
|
||||
revealed_ty: init_ty,
|
||||
});
|
||||
self.locals.borrow_mut().insert(local.pat.hir_id, LocalTy {
|
||||
decl_ty: t,
|
||||
revealed_ty: init_ty,
|
||||
});
|
||||
}
|
||||
self.overwrite_local_ty_if_err(local, t, init_ty);
|
||||
}
|
||||
|
||||
self.check_pat_top(&local.pat, t, None);
|
||||
let pat_ty = self.node_ty(local.pat.hir_id);
|
||||
debug!("check_decl_local pat_ty {:?}", pat_ty);
|
||||
if pat_ty.references_error() {
|
||||
self.overwrite_local_ty_if_err(local, t, pat_ty);
|
||||
}
|
||||
|
||||
fn overwrite_local_ty_if_err(&self, local: &'tcx hir::Local, decl_ty: Ty<'tcx>, ty: Ty<'tcx>) {
|
||||
if ty.references_error() {
|
||||
// Override the types everywhere with `types.err` to avoid knock down errors.
|
||||
self.write_ty(local.hir_id, pat_ty);
|
||||
self.write_ty(local.pat.hir_id, pat_ty);
|
||||
self.locals.borrow_mut().insert(local.hir_id, LocalTy {
|
||||
decl_ty: t,
|
||||
revealed_ty: pat_ty,
|
||||
});
|
||||
self.locals.borrow_mut().insert(local.pat.hir_id, LocalTy {
|
||||
decl_ty: t,
|
||||
revealed_ty: pat_ty,
|
||||
});
|
||||
self.write_ty(local.hir_id, ty);
|
||||
self.write_ty(local.pat.hir_id, ty);
|
||||
let local_ty = LocalTy {
|
||||
decl_ty,
|
||||
revealed_ty: ty,
|
||||
};
|
||||
self.locals.borrow_mut().insert(local.hir_id, local_ty);
|
||||
self.locals.borrow_mut().insert(local.pat.hir_id, local_ty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn main() {
|
||||
let baz = ().foo(); //~ ERROR no method named `foo` found for type `()` in the current scope
|
||||
<i32 as std::str::FromStr>::from_str(&baz); // No complains about `str` being unsized
|
||||
<i32 as std::str::FromStr>::from_str(&baz); // No complaints about `str` being unsized
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user