Skip to content

Commit f3a458f

Browse files
authored
Rollup merge of #99360 - compiler-errors:issue-99331, r=fee1-dead
Do not ICE when we have `-Zunpretty=expanded` with invalid ABI Fixes #99331
2 parents 3c2175b + 26ecd44 commit f3a458f

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,12 @@ impl<'a> PostExpansionVisitor<'a> {
274274
);
275275
}
276276
abi => {
277-
self.sess.parse_sess.span_diagnostic.delay_span_bug(
278-
span,
279-
&format!("unrecognized ABI not caught in lowering: {}", abi),
280-
);
277+
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
278+
self.sess.parse_sess.span_diagnostic.delay_span_bug(
279+
span,
280+
&format!("unrecognized ABI not caught in lowering: {}", abi),
281+
);
282+
}
281283
}
282284
}
283285
}

compiler/rustc_session/src/config.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2707,6 +2707,14 @@ impl PpMode {
27072707
| MirCFG => true,
27082708
}
27092709
}
2710+
pub fn needs_hir(&self) -> bool {
2711+
use PpMode::*;
2712+
match *self {
2713+
Source(_) | AstTree(_) => false,
2714+
2715+
Hir(_) | HirTree | ThirTree | Mir | MirCFG => true,
2716+
}
2717+
}
27102718

27112719
pub fn needs_analysis(&self) -> bool {
27122720
use PpMode::*;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(prelude_import)]
2+
#![no_std]
3+
#[prelude_import]
4+
use ::std::prelude::rust_2015::*;
5+
#[macro_use]
6+
extern crate std;
7+
// revisions: normal expanded
8+
//[expanded] check-pass
9+
//[expanded]compile-flags: -Zunpretty=expanded
10+
11+
extern "路濫狼á́́" fn foo() {}
12+
13+
fn main() {}

src/test/ui/codemap_tests/unicode.stderr renamed to src/test/ui/codemap_tests/unicode.normal.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0703]: invalid ABI: found `路濫狼á́́`
2-
--> $DIR/unicode.rs:1:8
2+
--> $DIR/unicode.rs:5:8
33
|
44
LL | extern "路濫狼á́́" fn foo() {}
55
| ^^^^^^^^^ invalid ABI

src/test/ui/codemap_tests/unicode.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
extern "路濫狼á́́" fn foo() {} //~ ERROR invalid ABI
1+
// revisions: normal expanded
2+
//[expanded] check-pass
3+
//[expanded]compile-flags: -Zunpretty=expanded
4+
5+
extern "路濫狼á́́" fn foo() {} //[normal]~ ERROR invalid ABI
26

37
fn main() { }

0 commit comments

Comments
 (0)