]> git.lizzy.rs Git - rust.git/commitdiff
Improve debuggability of #48116.
authorkennytm <kennytm@gmail.com>
Sat, 10 Feb 2018 21:05:11 +0000 (05:05 +0800)
committerkennytm <kennytm@gmail.com>
Tue, 13 Feb 2018 14:48:16 +0000 (22:48 +0800)
1. When the invalid condition is hit, write out the relevant variables too
2. In compile-fail/parse-fail tests, check for ICE first, so the invalid
   error patterns won't mask our ICE output.

src/librustc_resolve/resolve_imports.rs
src/tools/compiletest/src/runtest.rs

index 8cb25f449b66711e409e93704526b5dff7b0bd1d..a8070c553bdbcb34dd8bde7bf8435abc2d21ba12 100644 (file)
@@ -1026,6 +1026,8 @@ fn import_path_to_string(names: &[SpannedIdent],
         if names.is_empty() {
             import_directive_subclass_to_string(subclass)
         } else {
+            // FIXME: Remove this entire logic after #48116 is fixed.
+            //
             // Note that this code looks a little wonky, it's currently here to
             // hopefully help debug #48116, but otherwise isn't intended to
             // cause any problems.
@@ -1034,8 +1036,17 @@ fn import_path_to_string(names: &[SpannedIdent],
                 names_to_string(names),
                 import_directive_subclass_to_string(subclass),
             );
-            assert!(!names.is_empty());
-            assert!(!x.starts_with("::"));
+            if names.is_empty() || x.starts_with("::") {
+                span_bug!(
+                    span,
+                    "invalid name `{}` at {:?}; global = {}, names = {:?}, subclass = {:?}",
+                    x,
+                    span,
+                    global,
+                    names,
+                    subclass
+                );
+            }
             return x
         }
     }
index a87809dd7bcfd673dd058fa5d3feb66667925990..bef085e17ea160eb8703745deb55a935e0475a9d 100644 (file)
@@ -250,6 +250,7 @@ fn check_if_test_should_compile(&self, proc_res: &ProcRes) {
     fn run_cfail_test(&self) {
         let proc_res = self.compile_test();
         self.check_if_test_should_compile(&proc_res);
+        self.check_no_compiler_crash(&proc_res);
 
         let output_to_check = self.get_output(&proc_res);
         let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@@ -262,7 +263,6 @@ fn run_cfail_test(&self) {
             self.check_error_patterns(&output_to_check, &proc_res);
         }
 
-        self.check_no_compiler_crash(&proc_res);
         self.check_forbid_output(&output_to_check, &proc_res);
     }