mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Fix unwrap on None in expanding format args
This commit is contained in:
parent
dcab226210
commit
30e16e20d0
2 changed files with 41 additions and 4 deletions
|
@ -207,6 +207,44 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_15002() {
|
||||
check(
|
||||
r#"
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! format_args {
|
||||
($fmt:expr) => ({ /* compiler built-in */ });
|
||||
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
|
||||
}
|
||||
|
||||
fn main() {
|
||||
format_args!(x = 2);
|
||||
format_args!(x =);
|
||||
format_args!(x =, x = 2);
|
||||
format_args!("{}", x =);
|
||||
format_args!(=, "{}", x =);
|
||||
format_args!(x = 2, "{}", 5);
|
||||
}
|
||||
"#,
|
||||
expect![[r##"
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! format_args {
|
||||
($fmt:expr) => ({ /* compiler built-in */ });
|
||||
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
|
||||
}
|
||||
|
||||
fn main() {
|
||||
/* error: no rule matches input tokens */;
|
||||
/* error: no rule matches input tokens */;
|
||||
/* error: no rule matches input tokens */;
|
||||
/* error: no rule matches input tokens */::core::fmt::Arguments::new_v1(&["", ], &[::core::fmt::Argument::new(&(), ::core::fmt::Display::fmt), ]);
|
||||
/* error: no rule matches input tokens */;
|
||||
::core::fmt::Arguments::new_v1(&["", ], &[::core::fmt::Argument::new(&(5), ::core::fmt::Display::fmt), ]);
|
||||
}
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_args_expand_with_comma_exprs() {
|
||||
check(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue