Skip to content

Commit

Permalink
Rollup merge of rust-lang#99360 - compiler-errors:issue-99331, r=fee1…
Browse files Browse the repository at this point in the history
…-dead

Do not ICE when we have `-Zunpretty=expanded` with invalid ABI

Fixes rust-lang#99331
  • Loading branch information
JohnTitor committed Jul 17, 2022
2 parents c731b40 + 26ecd44 commit af53fea
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
10 changes: 6 additions & 4 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ impl<'a> PostExpansionVisitor<'a> {
);
}
abi => {
self.sess.parse_sess.span_diagnostic.delay_span_bug(
span,
&format!("unrecognized ABI not caught in lowering: {}", abi),
);
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
self.sess.parse_sess.span_diagnostic.delay_span_bug(
span,
&format!("unrecognized ABI not caught in lowering: {}", abi),
);
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,14 @@ impl PpMode {
| MirCFG => true,
}
}
pub fn needs_hir(&self) -> bool {
use PpMode::*;
match *self {
Source(_) | AstTree(_) => false,

Hir(_) | HirTree | ThirTree | Mir | MirCFG => true,
}
}

pub fn needs_analysis(&self) -> bool {
use PpMode::*;
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/codemap_tests/unicode.expanded.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
// revisions: normal expanded
//[expanded] check-pass
//[expanded]compile-flags: -Zunpretty=expanded

extern "路濫狼á́́" fn foo() {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0703]: invalid ABI: found `路濫狼á́́`
--> $DIR/unicode.rs:1:8
--> $DIR/unicode.rs:5:8
|
LL | extern "路濫狼á́́" fn foo() {}
| ^^^^^^^^^ invalid ABI
Expand Down
6 changes: 5 additions & 1 deletion src/test/ui/codemap_tests/unicode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
extern "路濫狼á́́" fn foo() {} //~ ERROR invalid ABI
// revisions: normal expanded
//[expanded] check-pass
//[expanded]compile-flags: -Zunpretty=expanded

extern "路濫狼á́́" fn foo() {} //[normal]~ ERROR invalid ABI

fn main() { }

0 comments on commit af53fea

Please sign in to comment.