about summary refs log tree commit diff
path: root/src/libsyntax_ext/format_foreign.rs
AgeCommit message (Collapse)AuthorLines
2019-12-30Rename directories for some crates from `syntax_x` to `rustc_x`Vadim Petrochenkov-827/+0
`syntax_expand` -> `rustc_expand` `syntax_pos` -> `rustc_span` `syntax_ext` -> `rustc_builtin_macros`
2019-12-22Format the worldMark Rousskov-94/+85
2019-12-06Rename to `then_some` and `then`varkor-3/+3
2019-12-06Use `to_option` in various placesvarkor-3/+3
2019-06-16Separate libsyntax_ext modulechansuke-215/+2
2019-06-09Introduce InnerSpan abstractionMark Rousskov-12/+14
This should be used when trying to get at subsets of a larger span, especially when the larger span is not available in the code attempting to work with those subsets (especially common in the fmt_macros crate). This is usually a good replacement for (BytePos, BytePos) and (usize, usize) tuples. This commit also removes from_inner_byte_pos, since it took usize arguments, which is error prone.
2019-06-09Shift padding out of suggestions for format stringsMark Rousskov-6/+6
2019-02-10rustc: doc commentsAlexander Regueiro-1/+1
2019-02-04libsyntax_ext => 2018Taiki Endo-16/+14
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-01remove some uses of try!Mark Mansi-1/+1
2018-07-31Use suggestions for shell format argumentsEsteban Küber-34/+46
2018-07-26Rollup merge of #52649 - estebank:fmt-span, r=oli-obkMark Rousskov-28/+74
Point spans to inner elements of format strings - Point at missing positional specifiers in string literal ``` error: invalid reference to positional arguments 3, 4 and 5 (there are 3 arguments) --> $DIR/ifmt-bad-arg.rs:34:38 | LL | format!("{name} {value} {} {} {} {} {} {}", 0, name=1, value=2); | ^^ ^^ ^^ | = note: positional arguments are zero-based ``` - Point at named formatting specifier in string literal ``` error: there is no argument named `foo` --> $DIR/ifmt-bad-arg.rs:37:17 | LL | format!("{} {foo} {} {bar} {}", 1, 2, 3); | ^^^^^ ``` - Update label for formatting string in "multiple unused formatting arguments" to be more correct ``` error: multiple unused formatting arguments --> $DIR/ifmt-bad-arg.rs:42:17 | LL | format!("", 1, 2); //~ ERROR: multiple unused formatting arguments | -- ^ ^ | | | multiple missing formatting specifiers ``` - When using `printf` string formatting, provide a structured suggestion instead of a note ``` error: multiple unused formatting arguments --> $DIR/format-foreign.rs:12:30 | LL | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments | -------------- ^^^^^^^^ ^^^^^^^ ^ | | | multiple missing formatting specifiers | = note: printf formatting not supported; see the documentation for `std::fmt` help: format specifiers in Rust are written using `{}` | LL | println!("{:.2$} {}!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments | ^^^^^^ ^^ ```
2018-07-24Rename method and remove commented out codeEsteban Küber-4/+2
2018-07-24Fix unittestEsteban Küber-24/+26
2018-07-24Use suggestions for `printf` formatEsteban Küber-4/+50
2018-07-23Replace a few expect+format combos with unwrap_or_else+panicljedrz-2/+2
2018-07-14Remove some tests using AST comparisons, fix other testsVadim Petrochenkov-4/+4
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-4/+4
2018-06-26migrate codebase to `..=` inclusive range patternsZack M. Davis-7/+7
These were stabilized in March 2018's #47813, and are the Preferred Way to Do It going forward (q.v. #51043).
2018-05-17Rename trans to codegen everywhere.Irina Popa-2/+2
2018-05-09use fmt::Result where applicableAndre Bogus-1/+1
2018-03-20Implement some trivial size_hints for various iteratorsPhlosioneer-0/+9
This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708.
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-48/+27
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-9/+9
Like #43008 (f668999), but _much more aggressive_.
2016-11-11Add foreign formatting directive detection.Daniel Keep-0/+1013
This teaches `format_args!` how to interpret format printf- and shell-style format directives. This is used in cases where there are unused formatting arguments, and the reason for that *might* be because the programmer is trying to use the wrong kind of formatting string. This was prompted by an issue encountered by simulacrum on the #rust IRC channel. In short: although `println!` told them that they weren't using all of the conversion arguments, the problem was in using printf-syle directives rather than ones `println!` would undertand. Where possible, `format_args!` will tell the programmer what they should use instead. For example, it will suggest replacing `%05d` with `{:0>5}`, or `%2$.*3$s` with `{1:.3$}`. Even if it cannot suggest a replacement, it will explicitly note that Rust does not support that style of directive, and direct the user to the `std::fmt` documentation.