forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#99263 - compiler-errors:issue-99261, r=jyn514
Fix ICE in `named_arguments_used_positionally` lint Fixes rust-lang#99261 Fixes rust-lang#99289 Fixes rust-lang#99284 Fixes rust-lang#99273 Fixes rust-lang#99297 Fixes rust-lang#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 rust-lang#99265 to track a (related?) incorrect argument indexing issue.
- Loading branch information
Showing
4 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
); | ||
} |