Rust: Move QL doc into annotations.py

This commit is contained in:
Tom Hvitved
2025-01-10 14:27:53 +01:00
parent 166f8916cc
commit 0795c244e9
19 changed files with 125 additions and 29 deletions

View File

@@ -521,7 +521,7 @@ lib/codeql/rust/elements/internal/generated/FieldList.qll 43c13c6e3c9ba75a7a4cb8
lib/codeql/rust/elements/internal/generated/FnPtrTypeRepr.qll d490ab9f2e3654d9abde18a06e534abd99ca62f518ca08670b696a97e9d5c592 01500319820f66cb4bbda6fe7c26270f76ea934efff4bb3cbf88e9b1e07e8be2
lib/codeql/rust/elements/internal/generated/ForExpr.qll 6c1838d952be65acaa9744736e73d9bfdcf58d7b392394223bf6fbfdcc172906 44237a248a5aa326a2544e84bc77f536f118f57a98c51562b71ddc81edfcccb8
lib/codeql/rust/elements/internal/generated/ForTypeRepr.qll 3027879795a6be5bfb370b8c2231b579f9df8afde54345416c6ce2c64bd3dfec f871d73b36f079f473915db298951020e5a05bb5e8e4d570822063afb4807559
lib/codeql/rust/elements/internal/generated/Format.qll 89a0bbeba8288ca52440dadcbb2f4c58e01cbbb000a9e94dfe2e0d272361d89b bf8099688eed34b2bf4e19b613187a64a5d82b2524e053149adb6891350d143c
lib/codeql/rust/elements/internal/generated/Format.qll 934351f8a8ffd914cc3fd88aca8e81bf646236fe34d15e0df7aeeb0b942b203f da9f146e6f52bafd67dcfd3b916692cf8f66031e0b1d5d17fc8dda5eefb99ca0
lib/codeql/rust/elements/internal/generated/FormatArgsArg.qll c762a4af8609472e285dd1b1aec8251421aec49f8d0e5ce9df2cc5e2722326f8 c8c226b94b32447634b445c62bd9af7e11b93a706f8fa35d2de4fda3ce951926
lib/codeql/rust/elements/internal/generated/FormatArgsExpr.qll 8aed8715a27d3af3de56ded4610c6792a25216b1544eb7e57c8b0b37c14bd9c1 590a2b0063d2ecd00bbbd1ce29603c8fd69972e34e6daddf309c915ce4ec1375
lib/codeql/rust/elements/internal/generated/FormatArgument.qll cd05153276e63e689c95d5537fbc7d892615f62e110323759ef02e23a7587407 be2a4531b498f01625effa4c631d51ee8857698b00cfb829074120a0f2696d57

View File

@@ -42,38 +42,14 @@ module Impl {
override int getIndex() { result = index }
/**
* Gets the name or position reference of this format, if any. For example `name` and `0` in:
* ```rust
* let name = "Alice";
* println!("{name} in wonderland");
* println!("{0} in wonderland", name);
* ```
*/
override FormatArgument getArgumentRef() {
result.getParent() = this and result = Synth::TFormatArgument(_, _, 0, _, _, _)
}
/**
* Gets the name or position reference of the width parameter in this format, if any. For example `width` and `1` in:
* ```rust
* let width = 6;
* println!("{:width$}", PI);
* println!("{:1$}", PI, width);
* ```
*/
override FormatArgument getWidthArgument() {
result.getParent() = this and result = Synth::TFormatArgument(_, _, 1, _, _, _)
}
/**
* Gets the name or position reference of the width parameter in this format, if any. For example `prec` and `1` in:
* ```rust
* let prec = 6;
* println!("{:.prec$}", PI);
* println!("{:.1$}", PI, prec);
* ```
*/
override FormatArgument getPrecisionArgument() {
result.getParent() = this and result = Synth::TFormatArgument(_, _, 2, _, _, _)
}

View File

@@ -42,6 +42,13 @@ module Generated {
/**
* Gets the argument reference of this format, if it exists.
*
* For example `name` and `0` in:
* ```rust
* let name = "Alice";
* println!("{name} in wonderland");
* println!("{0} in wonderland", name);
* ```
*/
FormatArgument getArgumentRef() { none() }
@@ -52,6 +59,13 @@ module Generated {
/**
* Gets the width argument of this format, if it exists.
*
* For example `width` and `1` in:
* ```rust
* let width = 6;
* println!("{:width$}", PI);
* println!("{:1$}", PI, width);
* ```
*/
FormatArgument getWidthArgument() { none() }
@@ -62,6 +76,13 @@ module Generated {
/**
* Gets the precision argument of this format, if it exists.
*
* For example `prec` and `1` in:
* ```rust
* let prec = 6;
* println!("{:.prec$}", PI);
* println!("{:.1$}", PI, prec);
* ```
*/
FormatArgument getPrecisionArgument() { none() }

View File

@@ -32,7 +32,7 @@ FieldExpr/gen_field_expr.rs 9a70500d592e0a071b03d974a55558b3bc0df531ff11bce5898f
FnPtrTypeRepr/gen_fn_ptr_type_repr.rs 46af312570a9caec11e14ba05190e95e750c32565559f1622a132f7145320253 46af312570a9caec11e14ba05190e95e750c32565559f1622a132f7145320253
ForExpr/gen_for_expr.rs 67decf3073e1a9363d9df05a5a64a6059349e50b81356f480f7aeb352189136d 67decf3073e1a9363d9df05a5a64a6059349e50b81356f480f7aeb352189136d
ForTypeRepr/gen_for_type_repr.rs 5108a5d63ce440305b92dd87387c22a0a57abfd19d88e03e1984e1537779f4a4 5108a5d63ce440305b92dd87387c22a0a57abfd19d88e03e1984e1537779f4a4
FormatArgsExpr/gen_format.rs 38adb675e5d635a08fb5353982a03a484b34e92042a15ae3b57f0ff40479b59f 38adb675e5d635a08fb5353982a03a484b34e92042a15ae3b57f0ff40479b59f
FormatArgsExpr/gen_format.rs e9d8e7b98d0050ad6053c2459cb21faab00078e74245336a5962438336f76d33 e9d8e7b98d0050ad6053c2459cb21faab00078e74245336a5962438336f76d33
FormatArgsExpr/gen_format_args_arg.rs 53ffd6abe4cd899c57d1973b31df0edc1d5eaa5835b19172ec4cda15bb3db28f 53ffd6abe4cd899c57d1973b31df0edc1d5eaa5835b19172ec4cda15bb3db28f
FormatArgsExpr/gen_format_args_expr.rs 72c806ed163e9dcce2d0c5c8664d409b2aa635c1022c91959f9e8ae084f05bf2 72c806ed163e9dcce2d0c5c8664d409b2aa635c1022c91959f9e8ae084f05bf2
FormatArgsExpr/gen_format_argument.rs 350d370e6f1db03d756384a3dbdb294697d241ff7c28d159cf57748abe99cfe9 350d370e6f1db03d756384a3dbdb294697d241ff7c28d159cf57748abe99cfe9

View File

@@ -1,5 +1,11 @@
| gen_format.rs:5:21:5:22 | {} | getParent: | gen_format.rs:5:14:5:32 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | no | hasPrecisionArgument: | no |
| gen_format.rs:7:21:7:46 | {value:#width$.precision$} | getParent: | gen_format.rs:7:14:7:47 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | yes | hasWidthArgument: | yes | hasPrecisionArgument: | yes |
| gen_format.rs:11:15:11:20 | {name} | getParent: | gen_format.rs:11:14:11:35 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | yes | hasWidthArgument: | no | hasPrecisionArgument: | no |
| gen_format.rs:12:15:12:17 | {0} | getParent: | gen_format.rs:12:14:12:38 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | yes | hasWidthArgument: | no | hasPrecisionArgument: | no |
| gen_format.rs:16:15:16:23 | {:width$} | getParent: | gen_format.rs:16:14:16:28 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | yes | hasPrecisionArgument: | no |
| gen_format.rs:17:15:17:19 | {:1$} | getParent: | gen_format.rs:17:14:17:31 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | yes | hasPrecisionArgument: | no |
| gen_format.rs:21:15:21:23 | {:.prec$} | getParent: | gen_format.rs:21:14:21:28 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | no | hasPrecisionArgument: | yes |
| gen_format.rs:22:15:22:20 | {:.1$} | getParent: | gen_format.rs:22:14:22:31 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | no | hasPrecisionArgument: | yes |
| gen_format_args_arg.rs:5:26:5:27 | {} | getParent: | gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | no | hasPrecisionArgument: | no |
| gen_format_args_expr.rs:6:19:6:20 | {} | getParent: | gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | getIndex: | 1 | hasArgumentRef: | no | hasWidthArgument: | no | hasPrecisionArgument: | no |
| gen_format_args_expr.rs:6:26:6:29 | {:?} | getParent: | gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | getIndex: | 3 | hasArgumentRef: | no | hasWidthArgument: | no | hasPrecisionArgument: | no |

View File

@@ -1,4 +1,11 @@
| gen_format.rs:5:26:5:32 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:12:35:12:38 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:16:27:16:28 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:17:23:17:24 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:17:27:17:31 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:21:27:21:28 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:22:24:22:25 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format.rs:22:28:22:31 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format_args_arg.rs:5:32:5:38 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format_args_expr.rs:6:33:6:33 | FormatArgsArg | hasExpr: | yes | hasName: | no |
| gen_format_args_expr.rs:6:36:6:36 | FormatArgsArg | hasExpr: | yes | hasName: | no |

View File

@@ -1,4 +1,11 @@
| gen_format.rs:5:26:5:32 | FormatArgsArg | gen_format.rs:5:26:5:32 | "world" |
| gen_format.rs:12:35:12:38 | FormatArgsArg | gen_format.rs:12:35:12:38 | name |
| gen_format.rs:16:27:16:28 | FormatArgsArg | gen_format.rs:16:27:16:28 | PI |
| gen_format.rs:17:23:17:24 | FormatArgsArg | gen_format.rs:17:23:17:24 | PI |
| gen_format.rs:17:27:17:31 | FormatArgsArg | gen_format.rs:17:27:17:31 | width |
| gen_format.rs:21:27:21:28 | FormatArgsArg | gen_format.rs:21:27:21:28 | PI |
| gen_format.rs:22:24:22:25 | FormatArgsArg | gen_format.rs:22:24:22:25 | PI |
| gen_format.rs:22:28:22:31 | FormatArgsArg | gen_format.rs:22:28:22:31 | prec |
| gen_format_args_arg.rs:5:32:5:38 | FormatArgsArg | gen_format_args_arg.rs:5:32:5:38 | "world" |
| gen_format_args_expr.rs:6:33:6:33 | FormatArgsArg | gen_format_args_expr.rs:6:33:6:33 | 1 |
| gen_format_args_expr.rs:6:36:6:36 | FormatArgsArg | gen_format_args_expr.rs:6:36:6:36 | 2 |

View File

@@ -1,5 +1,11 @@
| gen_format.rs:5:14:5:32 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:7:14:7:47 | FormatArgsExpr | getNumberOfArgs: | 0 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:11:14:11:35 | FormatArgsExpr | getNumberOfArgs: | 0 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:12:14:12:38 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:16:14:16:28 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:17:14:17:31 | FormatArgsExpr | getNumberOfArgs: | 2 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:21:14:21:28 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format.rs:22:14:22:31 | FormatArgsExpr | getNumberOfArgs: | 2 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | getNumberOfArgs: | 1 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 1 |
| gen_format_args_expr.rs:5:17:5:27 | FormatArgsExpr | getNumberOfArgs: | 0 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 0 |
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | getNumberOfArgs: | 2 | getNumberOfAttrs: | 0 | hasTemplate: | yes | getNumberOfFormats: | 2 |

View File

@@ -1,4 +1,11 @@
| gen_format.rs:5:14:5:32 | FormatArgsExpr | 0 | gen_format.rs:5:26:5:32 | FormatArgsArg |
| gen_format.rs:12:14:12:38 | FormatArgsExpr | 0 | gen_format.rs:12:35:12:38 | FormatArgsArg |
| gen_format.rs:16:14:16:28 | FormatArgsExpr | 0 | gen_format.rs:16:27:16:28 | FormatArgsArg |
| gen_format.rs:17:14:17:31 | FormatArgsExpr | 0 | gen_format.rs:17:23:17:24 | FormatArgsArg |
| gen_format.rs:17:14:17:31 | FormatArgsExpr | 1 | gen_format.rs:17:27:17:31 | FormatArgsArg |
| gen_format.rs:21:14:21:28 | FormatArgsExpr | 0 | gen_format.rs:21:27:21:28 | FormatArgsArg |
| gen_format.rs:22:14:22:31 | FormatArgsExpr | 0 | gen_format.rs:22:24:22:25 | FormatArgsArg |
| gen_format.rs:22:14:22:31 | FormatArgsExpr | 1 | gen_format.rs:22:28:22:31 | FormatArgsArg |
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | 0 | gen_format_args_arg.rs:5:32:5:38 | FormatArgsArg |
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 0 | gen_format_args_expr.rs:6:33:6:33 | FormatArgsArg |
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 1 | gen_format_args_expr.rs:6:36:6:36 | FormatArgsArg |

View File

@@ -1,5 +1,11 @@
| gen_format.rs:5:14:5:32 | FormatArgsExpr | 0 | gen_format.rs:5:21:5:22 | {} |
| gen_format.rs:7:14:7:47 | FormatArgsExpr | 0 | gen_format.rs:7:21:7:46 | {value:#width$.precision$} |
| gen_format.rs:11:14:11:35 | FormatArgsExpr | 0 | gen_format.rs:11:15:11:20 | {name} |
| gen_format.rs:12:14:12:38 | FormatArgsExpr | 0 | gen_format.rs:12:15:12:17 | {0} |
| gen_format.rs:16:14:16:28 | FormatArgsExpr | 0 | gen_format.rs:16:15:16:23 | {:width$} |
| gen_format.rs:17:14:17:31 | FormatArgsExpr | 0 | gen_format.rs:17:15:17:19 | {:1$} |
| gen_format.rs:21:14:21:28 | FormatArgsExpr | 0 | gen_format.rs:21:15:21:23 | {:.prec$} |
| gen_format.rs:22:14:22:31 | FormatArgsExpr | 0 | gen_format.rs:22:15:22:20 | {:.1$} |
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | 0 | gen_format_args_arg.rs:5:26:5:27 | {} |
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 0 | gen_format_args_expr.rs:6:19:6:20 | {} |
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | 1 | gen_format_args_expr.rs:6:26:6:29 | {:?} |

View File

@@ -1,5 +1,11 @@
| gen_format.rs:5:14:5:32 | FormatArgsExpr | gen_format.rs:5:14:5:23 | "Hello {}\\n" |
| gen_format.rs:7:14:7:47 | FormatArgsExpr | gen_format.rs:7:14:7:47 | "Value {value:#width$.precisio... |
| gen_format.rs:11:14:11:35 | FormatArgsExpr | gen_format.rs:11:14:11:35 | "{name} in wonderland\\n" |
| gen_format.rs:12:14:12:38 | FormatArgsExpr | gen_format.rs:12:14:12:32 | "{0} in wonderland\\n" |
| gen_format.rs:16:14:16:28 | FormatArgsExpr | gen_format.rs:16:14:16:24 | "{:width$}\\n" |
| gen_format.rs:17:14:17:31 | FormatArgsExpr | gen_format.rs:17:14:17:20 | "{:1$}\\n" |
| gen_format.rs:21:14:21:28 | FormatArgsExpr | gen_format.rs:21:14:21:24 | "{:.prec$}\\n" |
| gen_format.rs:22:14:22:31 | FormatArgsExpr | gen_format.rs:22:14:22:21 | "{:.1$}\\n" |
| gen_format_args_arg.rs:5:17:5:39 | FormatArgsExpr | gen_format_args_arg.rs:5:18:5:29 | "Hello, {}!" |
| gen_format_args_expr.rs:5:17:5:27 | FormatArgsExpr | gen_format_args_expr.rs:5:18:5:26 | "no args" |
| gen_format_args_expr.rs:6:17:6:37 | FormatArgsExpr | gen_format_args_expr.rs:6:18:6:30 | "{} foo {:?}" |

View File

@@ -1,6 +1,12 @@
| gen_format.rs:7:22:7:26 | value | getParent: | gen_format.rs:7:21:7:46 | {value:#width$.precision$} | hasVariable: | yes |
| gen_format.rs:7:29:7:33 | width | getParent: | gen_format.rs:7:21:7:46 | {value:#width$.precision$} | hasVariable: | yes |
| gen_format.rs:7:36:7:44 | precision | getParent: | gen_format.rs:7:21:7:46 | {value:#width$.precision$} | hasVariable: | yes |
| gen_format.rs:11:16:11:19 | name | getParent: | gen_format.rs:11:15:11:20 | {name} | hasVariable: | yes |
| gen_format.rs:12:16:12:16 | 0 | getParent: | gen_format.rs:12:15:12:17 | {0} | hasVariable: | no |
| gen_format.rs:16:17:16:21 | width | getParent: | gen_format.rs:16:15:16:23 | {:width$} | hasVariable: | yes |
| gen_format.rs:17:17:17:17 | 1 | getParent: | gen_format.rs:17:15:17:19 | {:1$} | hasVariable: | no |
| gen_format.rs:21:18:21:21 | prec | getParent: | gen_format.rs:21:15:21:23 | {:.prec$} | hasVariable: | yes |
| gen_format.rs:22:18:22:18 | 1 | getParent: | gen_format.rs:22:15:22:20 | {:.1$} | hasVariable: | no |
| gen_format_args_expr.rs:7:20:7:20 | b | getParent: | gen_format_args_expr.rs:7:19:7:21 | {b} | hasVariable: | no |
| gen_format_args_expr.rs:7:28:7:28 | a | getParent: | gen_format_args_expr.rs:7:27:7:31 | {a:?} | hasVariable: | no |
| gen_format_args_expr.rs:9:20:9:20 | x | getParent: | gen_format_args_expr.rs:9:19:9:21 | {x} | hasVariable: | yes |

View File

@@ -1,6 +1,9 @@
| gen_format.rs:7:22:7:26 | value | gen_format.rs:7:22:7:26 | value |
| gen_format.rs:7:29:7:33 | width | gen_format.rs:7:29:7:33 | width |
| gen_format.rs:7:36:7:44 | precision | gen_format.rs:7:36:7:44 | precision |
| gen_format.rs:11:16:11:19 | name | gen_format.rs:11:16:11:19 | name |
| gen_format.rs:16:17:16:21 | width | gen_format.rs:16:17:16:21 | width |
| gen_format.rs:21:18:21:21 | prec | gen_format.rs:21:18:21:21 | prec |
| gen_format_args_expr.rs:9:20:9:20 | x | gen_format_args_expr.rs:9:20:9:20 | x |
| gen_format_args_expr.rs:9:25:9:25 | y | gen_format_args_expr.rs:9:25:9:25 | y |
| gen_format_argument.rs:5:22:5:26 | value | gen_format_argument.rs:5:22:5:26 | value |

View File

@@ -1,6 +1,9 @@
| gen_format.rs:7:22:7:26 | value |
| gen_format.rs:7:29:7:33 | width |
| gen_format.rs:7:36:7:44 | precision |
| gen_format.rs:11:16:11:19 | name |
| gen_format.rs:16:17:16:21 | width |
| gen_format.rs:21:18:21:21 | prec |
| gen_format_args_expr.rs:9:20:9:20 | x |
| gen_format_args_expr.rs:9:25:9:25 | y |
| gen_format_argument.rs:5:22:5:26 | value |

View File

@@ -1,4 +1,6 @@
| gen_format.rs:7:21:7:46 | {value:#width$.precision$} | gen_format.rs:7:22:7:26 | value |
| gen_format.rs:11:15:11:20 | {name} | gen_format.rs:11:16:11:19 | name |
| gen_format.rs:12:15:12:17 | {0} | gen_format.rs:12:16:12:16 | 0 |
| gen_format_args_expr.rs:7:19:7:21 | {b} | gen_format_args_expr.rs:7:20:7:20 | b |
| gen_format_args_expr.rs:7:27:7:31 | {a:?} | gen_format_args_expr.rs:7:28:7:28 | a |
| gen_format_args_expr.rs:9:19:9:21 | {x} | gen_format_args_expr.rs:9:20:9:20 | x |

View File

@@ -1,3 +1,5 @@
| gen_format.rs:7:21:7:46 | {value:#width$.precision$} | gen_format.rs:7:36:7:44 | precision |
| gen_format.rs:21:15:21:23 | {:.prec$} | gen_format.rs:21:18:21:21 | prec |
| gen_format.rs:22:15:22:20 | {:.1$} | gen_format.rs:22:18:22:18 | 1 |
| gen_format_argument.rs:5:21:5:46 | {value:#width$.precision$} | gen_format_argument.rs:5:36:5:44 | precision |
| gen_format_argument.rs:7:21:7:30 | {0:#1$.2$} | gen_format_argument.rs:7:28:7:28 | 2 |

View File

@@ -1,3 +1,5 @@
| gen_format.rs:7:21:7:46 | {value:#width$.precision$} | gen_format.rs:7:29:7:33 | width |
| gen_format.rs:16:15:16:23 | {:width$} | gen_format.rs:16:17:16:21 | width |
| gen_format.rs:17:15:17:19 | {:1$} | gen_format.rs:17:17:17:17 | 1 |
| gen_format_argument.rs:5:21:5:46 | {value:#width$.precision$} | gen_format_argument.rs:5:29:5:33 | width |
| gen_format_argument.rs:7:21:7:30 | {0:#1$.2$} | gen_format_argument.rs:7:25:7:25 | 1 |

View File

@@ -5,4 +5,19 @@ fn test_format() -> () {
println!("Hello {}", "world");
// or the `{value:#width$.precision$}` in:
println!("Value {value:#width$.precision$}");
// # argument_ref
// For example `name` and `0` in:
let name = "Alice";
println!("{name} in wonderland");
println!("{0} in wonderland", name);
// # width_argument
// For example `width` and `1` in:
let width = 6;
println!("{:width$}", PI);
println!("{:1$}", PI, width);
// # precision_argument
// For example `prec` and `1` in:
let prec = 6;
println!("{:.prec$}", PI);
println!("{:.1$}", PI, prec);
}

View File

@@ -1878,9 +1878,30 @@ class Format(Locatable):
"""
parent: FormatArgsExpr
index: int
argument_ref: optional["FormatArgument"] | child
width_argument: optional["FormatArgument"] | child
precision_argument: optional["FormatArgument"] | child
argument_ref: optional["FormatArgument"] | child | desc("""
For example `name` and `0` in:
```rust
let name = "Alice";
println!("{name} in wonderland");
println!("{0} in wonderland", name);
```
""")
width_argument: optional["FormatArgument"] | child | desc("""
For example `width` and `1` in:
```rust
let width = 6;
println!("{:width$}", PI);
println!("{:1$}", PI, width);
```
""")
precision_argument: optional["FormatArgument"] | child | desc("""
For example `prec` and `1` in:
```rust
let prec = 6;
println!("{:.prec$}", PI);
println!("{:.1$}", PI, prec);
```
""")
@synth.on_arguments(parent=FormatArgsExpr, index=int, kind=int, name=string, positional=boolean, offset=int)