mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
fix: to leave Ident in parse_format_exprs
This commit is contained in:
parent
796a106412
commit
13267adb12
1 changed files with 8 additions and 8 deletions
|
@ -140,8 +140,8 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
|
||||||
output.push_str(trimmed);
|
output.push_str(trimmed);
|
||||||
} else if matches!(state, State::Expr) {
|
} else if matches!(state, State::Expr) {
|
||||||
extracted_expressions.push(Arg::Expr(trimmed.into()));
|
extracted_expressions.push(Arg::Expr(trimmed.into()));
|
||||||
} else {
|
} else if matches!(state, State::Ident) {
|
||||||
extracted_expressions.push(Arg::Ident(trimmed.into()));
|
output.push_str(trimmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
output.push(chr);
|
output.push(chr);
|
||||||
|
@ -218,9 +218,9 @@ mod tests {
|
||||||
let test_vector = &[
|
let test_vector = &[
|
||||||
("no expressions", expect![["no expressions"]]),
|
("no expressions", expect![["no expressions"]]),
|
||||||
(r"no expressions with \$0$1", expect![r"no expressions with \\\$0\$1"]),
|
(r"no expressions with \$0$1", expect![r"no expressions with \\\$0\$1"]),
|
||||||
("{expr} is {2 + 2}", expect![["{} is {}; expr, 2 + 2"]]),
|
("{expr} is {2 + 2}", expect![["{expr} is {}; 2 + 2"]]),
|
||||||
("{expr:?}", expect![["{:?}; expr"]]),
|
("{expr:?}", expect![["{expr:?}"]]),
|
||||||
("{expr:1$}", expect![[r"{:1\$}; expr"]]),
|
("{expr:1$}", expect![[r"{expr:1\$}"]]),
|
||||||
("{:1$}", expect![[r"{:1\$}; $1"]]),
|
("{:1$}", expect![[r"{:1\$}; $1"]]),
|
||||||
("{:>padding$}", expect![[r"{:>padding\$}; $1"]]),
|
("{:>padding$}", expect![[r"{:>padding\$}; $1"]]),
|
||||||
("{}, {}, {0}", expect![[r"{}, {}, {0}; $1, $2"]]),
|
("{}, {}, {0}", expect![[r"{}, {}, {0}; $1, $2"]]),
|
||||||
|
@ -230,8 +230,8 @@ mod tests {
|
||||||
("malformed}", expect![["-"]]),
|
("malformed}", expect![["-"]]),
|
||||||
("{{correct", expect![["{{correct"]]),
|
("{{correct", expect![["{{correct"]]),
|
||||||
("correct}}", expect![["correct}}"]]),
|
("correct}}", expect![["correct}}"]]),
|
||||||
("{correct}}}", expect![["{}}}; correct"]]),
|
("{correct}}}", expect![["{correct}}}"]]),
|
||||||
("{correct}}}}}", expect![["{}}}}}; correct"]]),
|
("{correct}}}}}", expect![["{correct}}}}}"]]),
|
||||||
("{incorrect}}", expect![["-"]]),
|
("{incorrect}}", expect![["-"]]),
|
||||||
("placeholders {} {}", expect![["placeholders {} {}; $1, $2"]]),
|
("placeholders {} {}", expect![["placeholders {} {}; $1, $2"]]),
|
||||||
("mixed {} {2 + 2} {}", expect![["mixed {} {} {}; $1, 2 + 2, $2"]]),
|
("mixed {} {2 + 2} {}", expect![["mixed {} {} {}; $1, 2 + 2, $2"]]),
|
||||||
|
@ -239,7 +239,7 @@ mod tests {
|
||||||
"{SomeStruct { val_a: 0, val_b: 1 }}",
|
"{SomeStruct { val_a: 0, val_b: 1 }}",
|
||||||
expect![["{}; SomeStruct { val_a: 0, val_b: 1 }"]],
|
expect![["{}; SomeStruct { val_a: 0, val_b: 1 }"]],
|
||||||
),
|
),
|
||||||
("{expr:?} is {2.32f64:.5}", expect![["{:?} is {:.5}; expr, 2.32f64"]]),
|
("{expr:?} is {2.32f64:.5}", expect![["{expr:?} is {:.5}; 2.32f64"]]),
|
||||||
(
|
(
|
||||||
"{SomeStruct { val_a: 0, val_b: 1 }:?}",
|
"{SomeStruct { val_a: 0, val_b: 1 }:?}",
|
||||||
expect![["{:?}; SomeStruct { val_a: 0, val_b: 1 }"]],
|
expect![["{:?}; SomeStruct { val_a: 0, val_b: 1 }"]],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue