Change:
Because of the method error, doesn't get a type (not even , AFAICT), and then it gets inferred to from another call in the function, which results in the unsized variable error.
cc
I'd expect a simple fix for this would be to actually set as 's type, so it can't be inferred to anything else, although that could make other errors less informative.
I just spent a lot of time looking at a error. The errors were hidden by a couple of screens of "doc comment not used by rustdoc" warnings. Because was unknown, the compiler assumed it implemented no traits at all, leading to misleading errors below and user confusion: "why isn't it when this other similar type similar is?", "how can I find out if a type is " and so on. I don't know if works like that, but in this case it might be better to assume that the type implements any trait it's required to.
That doesn't really work out, since the issue here is that inference gets a free pass instead of inferring which would at least signal anything. The fix seems simple, I really don't know why I haven't tried it yet
I'm not saying that the type should be inferred to something else from the code below (like you said it was happening in the issue description) -- that seems bad. But on the other hand the compiler should probably not report an error every place the type or variable is used.
I just reread, and: That's not relevant here - the problem is inference flows up into the variable, which is correct in other cases but in this case it infers the slice type which is unsized. The error is a mere side-effect.
The underlying cause is that we have two maps for →, a general one and one for locals. When type checking we write to the general one but the one for locals is only written to once, during initialization, and the we read from it. If we kept it up to date or read from the general map, the knock-down error wouldn't appear.

Discussion:
// Just ignore error types. if a.references_error() || b.references_error() { <del> return success(vec![], b, vec![]); </del> <ins> return success(vec![], self.fcx.tcx.types.err, vec![]); </ins> } if a.is_never() {

let (adjustments, _) = self.register_infer_ok_obligations(ok); self.apply_adjustments(expr, adjustments); <del> Ok(target) </del> <ins> Ok(if expr_ty.references_error() { self.tcx.types.err } else { target }) </ins> } /// Same as `try_coerce()`, but without side-effects.

use self::TupleArgumentsFlag::*; /// The type of a local binding, including the revealed type for anon types. <del> #[derive(Copy, Clone)] </del> <ins> #[derive(Copy, Clone, Debug)] </ins> pub struct LocalTy<'tcx> { decl_ty: Ty<'tcx>, revealed_ty: Ty<'tcx>

if let Some(ref init) = local.init { let init_ty = self.check_decl_initializer(local, &init); <del> if init_ty.references_error() { self.write_ty(local.hir_id, init_ty); } </del> <ins> self.overwrite_local_ty_if_err(local, t, init_ty); </ins> } self.check_pat_top(&local.pat, t, None); let pat_ty = self.node_ty(local.pat.hir_id); <del> if pat_ty.references_error() { self.write_ty(local.hir_id, pat_ty); </del> <ins> 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, 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); </ins> } }

<ins> 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 complaints about `str` being unsized } </ins>

<ins> error[E0599]: no method named `foo` found for type `()` in the current scope --> $DIR/issue-33575.rs:2:18 | LL |     let baz = ().foo(); |                  ^^^ method not found in `()` error: aborting due to previous error For more information about this error, try `rustc --explain E0599`. </ins>