diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 54fd070e93cbc..22001d0089609 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -988,16 +988,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { } } Def::Err => { - for segment in &path.segments { - segment.with_parameters(|parameters| { - for ty in ¶meters.types { - self.ast_ty_to_ty(ty); - } - for binding in ¶meters.bindings { - self.ast_ty_to_ty(&binding.ty); - } - }); - } self.set_tainted_by_errors(); return self.tcx().types.err; } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index a0099a48c896b..09294332a4f15 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2009,7 +2009,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> { match self.tables.borrow().node_types().get(id) { Some(&t) => t, - None if self.err_count_since_creation() != 0 => self.tcx.types.err, + None if self.is_tainted_by_errors() => self.tcx.types.err, None => { let node_id = self.tcx.hir.definitions().find_node_for_hir_id(id); bug!("no type for node {}: {} in fcx {}", diff --git a/src/test/compile-fail/type-path-err-node-types.rs b/src/test/compile-fail/type-path-err-node-types.rs index 8f26777b441d4..7ef099d0410a6 100644 --- a/src/test/compile-fail/type-path-err-node-types.rs +++ b/src/test/compile-fail/type-path-err-node-types.rs @@ -8,10 +8,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Type arguments of unresolved types should have their types recorded +// Type arguments in unresolved entities (reporting errors before type checking) +// should have their types recorded. -fn main() { +trait Tr {} + +fn local_type() { let _: Nonexistent; //~ ERROR cannot find type `Nonexistent` in this scope +} - let _ = |a, b: _| -> _ { 0 }; +fn ufcs_trait() { + >::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent` } + +fn ufcs_item() { + NonExistent::Assoc::; //~ ERROR undeclared type or module `NonExistent` +} + +fn method() { + nonexistent.nonexistent::(); //~ ERROR cannot find value `nonexistent` +} + +fn closure() { + let _ = |a, b: _| -> _ { 0 }; // OK +} + +fn main() {}