diff options
author | bors <bors@rust-lang.org> | 2023-01-09 11:40:48 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2023-01-09 11:40:48 +0000 |
commit | 1e20bf38b2adb1130b705d6ce1956a635df10d3b (patch) | |
tree | 764ff8d0ab48762f4f1a4eafb52b575e394dbdbf /tests/rustdoc-js-std/parser-errors.js | |
parent | 814ff01620730f3406797d7aaf210e0bec8f2754 (diff) | |
parent | 9eabc2cde8e76d718de81b6cd4d0091c7a8d9690 (diff) | |
download | rust-1e20bf38b2adb1130b705d6ce1956a635df10d3b.tar.gz |
Auto merge of #13684 - unvalley:extract-expressions-from-format-string, r=Veykril
feat: extract_expressions_from_format_string
closes #13640
- rename to `extract_expressions_from_format_string`
- leave identifier from format string
- but this is from rustc version 1.65.0
- Should I add flag or something?
Note: the assist behaves below cases for now. I'll create an issue for these.
```rs
let var = 1 + 1;
// ok
format!("{var} {1+1}"); // → format!("{var} {}", 1+1);
format!("{var:?} {1+1}"); // → format!("{var:?} {}", 1 + 1);
format!("{var} {var} {1+1}"); // → format!("{var} {var} {}", 1 + 1);
// breaks (need to handle minimum width by postfix`$`)
format!("{var:width$} {1+1}"); // → format!("{var:width\$} {}", 1+1);
format!("{var:.prec$} {1+1}"); // → format!("{var:.prec\$} {}", 1+1);
format!("Hello {:1$}! {1+1}", "x" 5); // → format("Hello {:1\$}! {}", "x", 1+1);
format!("Hello {:width$}! {1+1}", "x", width = 5); // → println!("Hello {:width\$}! {}", "x", 1+1);
```
https://user-images.githubusercontent.com/38400669/204344911-f1f8fbd2-706d-414e-b1ab-d309376efb9b.mov
Diffstat (limited to 'tests/rustdoc-js-std/parser-errors.js')
0 files changed, 0 insertions, 0 deletions