Skip to content

Commit 7984c89

Browse files
committed
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.
1 parent 4d2d3fc commit 7984c89

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/librustc_resolve/resolve_imports.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,8 @@ fn import_path_to_string(names: &[SpannedIdent],
10261026
if names.is_empty() {
10271027
import_directive_subclass_to_string(subclass)
10281028
} else {
1029+
// FIXME: Remove this entire logic after #48116 is fixed.
1030+
//
10291031
// Note that this code looks a little wonky, it's currently here to
10301032
// hopefully help debug #48116, but otherwise isn't intended to
10311033
// cause any problems.
@@ -1034,8 +1036,17 @@ fn import_path_to_string(names: &[SpannedIdent],
10341036
names_to_string(names),
10351037
import_directive_subclass_to_string(subclass),
10361038
);
1037-
assert!(!names.is_empty());
1038-
assert!(!x.starts_with("::"));
1039+
if names.is_empty() || x.starts_with("::") {
1040+
span_bug!(
1041+
span,
1042+
"invalid name `{}` at {:?}; global = {}, names = {:?}, subclass = {:?}",
1043+
x,
1044+
span,
1045+
global,
1046+
names,
1047+
subclass
1048+
);
1049+
}
10391050
return x
10401051
}
10411052
}

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ impl<'test> TestCx<'test> {
250250
fn run_cfail_test(&self) {
251251
let proc_res = self.compile_test();
252252
self.check_if_test_should_compile(&proc_res);
253+
self.check_no_compiler_crash(&proc_res);
253254

254255
let output_to_check = self.get_output(&proc_res);
255256
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@@ -262,7 +263,6 @@ impl<'test> TestCx<'test> {
262263
self.check_error_patterns(&output_to_check, &proc_res);
263264
}
264265

265-
self.check_no_compiler_crash(&proc_res);
266266
self.check_forbid_output(&output_to_check, &proc_res);
267267
}
268268

0 commit comments

Comments
 (0)