mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Fix format string highlighting in panic!
This commit is contained in:
parent
161a5e8724
commit
368c5f6023
3 changed files with 59 additions and 3 deletions
|
@ -446,6 +446,31 @@ macro_rules! format_args_nl {
|
|||
($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
|
||||
}
|
||||
|
||||
mod panic {
|
||||
pub macro panic_2015 {
|
||||
() => (
|
||||
$crate::panicking::panic("explicit panic")
|
||||
),
|
||||
($msg:literal $(,)?) => (
|
||||
$crate::panicking::panic($msg)
|
||||
),
|
||||
// Use `panic_str` instead of `panic_display::<&str>` for non_fmt_panic lint.
|
||||
($msg:expr $(,)?) => (
|
||||
$crate::panicking::panic_str($msg)
|
||||
),
|
||||
// Special-case the single-argument case for const_panic.
|
||||
("{}", $arg:expr $(,)?) => (
|
||||
$crate::panicking::panic_display(&$arg)
|
||||
),
|
||||
($fmt:expr, $($arg:tt)+) => (
|
||||
$crate::panicking::panic_fmt($crate::const_format_args!($fmt, $($arg)+))
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_builtin_macro(std_panic)]
|
||||
macro_rules! panic {}
|
||||
|
||||
fn main() {
|
||||
// from https://doc.rust-lang.org/std/fmt/index.html
|
||||
println!("Hello"); // => "Hello"
|
||||
|
@ -495,6 +520,8 @@ fn main() {
|
|||
println!("{ничоси}", ничоси = 92);
|
||||
|
||||
println!("{:x?} {} ", thingy, n2);
|
||||
panic!("{}", 0);
|
||||
panic!("more {}", 1);
|
||||
}"#
|
||||
.trim(),
|
||||
expect_file!["./test_data/highlight_strings.html"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue