diff options
| author | bors <bors@rust-lang.org> | 2022-07-16 14:05:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-16 14:05:52 +0000 |
| commit | 56351589f8c5afe07a9151dd4a75976aebd1a709 (patch) | |
| tree | f808a337116ebb9aa8f47464ea3bf77cad7dd3e3 /src | |
| parent | d695a497bbf4b20d2580b75075faa80230d41667 (diff) | |
| parent | 2902b92769a29d24f9107d2e322ed9c92990da98 (diff) | |
| download | rust-56351589f8c5afe07a9151dd4a75976aebd1a709.tar.gz rust-56351589f8c5afe07a9151dd4a75976aebd1a709.zip | |
Auto merge of #99263 - compiler-errors:issue-99261, r=jyn514
Fix ICE in `named_arguments_used_positionally` lint
Fixes #99261
Fixes #99289
Fixes #99284
Fixes #99273
Fixes #99297
Fixes #99271
This match pattern:
```
FormatSpec { width: Count::CountIsName(s, _), .. }
| FormatSpec { precision: Count::CountIsName(s, _), .. }
```
does not account for when both `width` and `precision` are both `Count::CountIsName`, so split the check for these two fields into two separate `if let`.
Also, remove any future potential for ICEs by removing the index operator altogether.
---
It is still suspicious that this indexing was broken and caused the ICE, as opposed to just causing a spurious lint message.
cc `@PrestonFrom,` who may be familiar with this code because of implementing the lint this touches, perhaps you'd like to look into why named arguments in `FormatSpec.precision` seem to have indices that don't correspond to a span in `Context.arg_spans`?
Edit: Opened #99265 to track a (related?) incorrect argument indexing issue.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/macros/issue-99261.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/macros/issue-99261.rs b/src/test/ui/macros/issue-99261.rs new file mode 100644 index 00000000000..40d26d08cba --- /dev/null +++ b/src/test/ui/macros/issue-99261.rs @@ -0,0 +1,17 @@ +// check-pass + +#![deny(named_arguments_used_positionally)] + +fn main() { + let value: f64 = 314.15926; + let digits_before_decimal = 1; + let digits_after_decimal = 2; + let width = digits_before_decimal + 1 + digits_after_decimal; + + println!( + "{value:0>width$.digits_after_decimal$}", + value = value, + width = width, + digits_after_decimal = digits_after_decimal, + ); +} |
