From 8e80ca6470f7bf776b07729c956ef5fdb3ae8a37 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Thu, 25 Aug 2022 02:08:00 +0900 Subject: [PATCH] fix ICE #100948 --- compiler/rustc_ast/src/util/literal.rs | 2 +- src/test/ui/issues/issue-100948.rs | 5 +++++ src/test/ui/issues/issue-100948.stderr | 10 ++++++++++ src/test/ui/issues/issue-100948.stdout | 9 +++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/issues/issue-100948.rs create mode 100644 src/test/ui/issues/issue-100948.stderr create mode 100644 src/test/ui/issues/issue-100948.stdout diff --git a/compiler/rustc_ast/src/util/literal.rs b/compiler/rustc_ast/src/util/literal.rs index 6a02a3b56f616..5e0f784b73469 100644 --- a/compiler/rustc_ast/src/util/literal.rs +++ b/compiler/rustc_ast/src/util/literal.rs @@ -199,7 +199,7 @@ impl LitKind { let symbol = if value { kw::True } else { kw::False }; (token::Bool, symbol, None) } - LitKind::Err => unreachable!(), + LitKind::Err => (token::Err, kw::Empty, None), }; token::Lit::new(kind, symbol, suffix) diff --git a/src/test/ui/issues/issue-100948.rs b/src/test/ui/issues/issue-100948.rs new file mode 100644 index 0000000000000..6dd69bf7030c8 --- /dev/null +++ b/src/test/ui/issues/issue-100948.rs @@ -0,0 +1,5 @@ +// compile-flags: -Zunpretty=hir + +fn main() { + 1u; //~ ERROR invalid suffix `u` for number literal +} diff --git a/src/test/ui/issues/issue-100948.stderr b/src/test/ui/issues/issue-100948.stderr new file mode 100644 index 0000000000000..b72ff9e1770a5 --- /dev/null +++ b/src/test/ui/issues/issue-100948.stderr @@ -0,0 +1,10 @@ +error: invalid suffix `u` for number literal + --> $DIR/issue-100948.rs:4:5 + | +LL | 1u; + | ^^ invalid suffix `u` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error: aborting due to previous error + diff --git a/src/test/ui/issues/issue-100948.stdout b/src/test/ui/issues/issue-100948.stdout new file mode 100644 index 0000000000000..97a367ea21253 --- /dev/null +++ b/src/test/ui/issues/issue-100948.stdout @@ -0,0 +1,9 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// compile-flags: -Zunpretty=hir + +fn main() { + ; + }