From 3878906121e994aaf878b763ec8b7e141d96125b Mon Sep 17 00:00:00 2001 From: kennytm Date: Sun, 11 Feb 2018 05:05:11 +0800 Subject: [PATCH] Improve debuggability of #48116. 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 | 15 +++++++++++++-- src/tools/compiletest/src/runtest.rs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 8cb25f449b667..a8070c553bdbc 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -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 } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a87809dd7bcfd..bef085e17ea16 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -250,6 +250,7 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { 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); }