]> git.lizzy.rs Git - rust.git/commitdiff
Do not require semantic types for all syntactic types when there are type errors
authorpetrochenkov <vadim.petrochenkov@gmail.com>
Sat, 30 Sep 2017 13:42:22 +0000 (16:42 +0300)
committerpetrochenkov <vadim.petrochenkov@gmail.com>
Sat, 30 Sep 2017 14:41:00 +0000 (17:41 +0300)
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/mod.rs
src/test/compile-fail/type-path-err-node-types.rs

index 54fd070e93cbcbb4943952386b405461bc83f606..22001d00896098ed7ddb09f79390617cc573ef95 100644 (file)
@@ -988,16 +988,6 @@ pub fn def_to_ty(&self,
                 }
             }
             Def::Err => {
-                for segment in &path.segments {
-                    segment.with_parameters(|parameters| {
-                        for ty in &parameters.types {
-                            self.ast_ty_to_ty(ty);
-                        }
-                        for binding in &parameters.bindings {
-                            self.ast_ty_to_ty(&binding.ty);
-                        }
-                    });
-                }
                 self.set_tainted_by_errors();
                 return self.tcx().types.err;
             }
index a0099a48c896bc73bf28b6962bff527239bc61f1..09294332a4f1540f05d945a7f6ef142ce2a4c041 100644 (file)
@@ -2009,7 +2009,7 @@ pub fn to_ty(&self, ast_t: &hir::Ty) -> Ty<'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 {}",
index 8f26777b441d4e5849befc3c6fa855f053501db0..7ef099d0410a60730ae508196157339bcf56162a 100644 (file)
@@ -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<T> {}
+
+fn local_type() {
     let _: Nonexistent<u8, Assoc = u16>; //~ ERROR cannot find type `Nonexistent` in this scope
+}
 
-    let _ = |a, b: _| -> _ { 0 };
+fn ufcs_trait() {
+    <u8 as Tr<u8>>::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent`
 }
+
+fn ufcs_item() {
+    NonExistent::Assoc::<u8>; //~ ERROR undeclared type or module `NonExistent`
+}
+
+fn method() {
+    nonexistent.nonexistent::<u8>(); //~ ERROR cannot find value `nonexistent`
+}
+
+fn closure() {
+    let _ = |a, b: _| -> _ { 0 }; // OK
+}
+
+fn main() {}