varkor
9f1269f23c
Rename to then_some
and then
2019-12-06 12:24:54 +00:00
varkor
e3a8ea4e18
Use to_option
in various places
2019-12-06 12:23:23 +00:00
chansuke
ce51e653c7
Separate libsyntax_ext module
2019-06-16 14:17:01 +03:00
Mark Rousskov
b1c357e0c3
Introduce InnerSpan abstraction
...
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-09 14:09:36 -06:00
Mark Rousskov
a859440092
Shift padding out of suggestions for format strings
2019-06-09 14:06:34 -06:00
Alexander Regueiro
c3e182cf43
rustc: doc comments
2019-02-10 23:42:32 +00:00
Taiki Endo
94f121ff3f
libsyntax_ext => 2018
2019-02-04 21:49:54 +09:00
Mark Rousskov
2a663555dd
Remove licenses
2018-12-25 21:08:33 -07:00
Mark Mansi
e7e96921c2
remove some uses of try!
2018-12-01 15:48:55 -06:00
Esteban Küber
75ff0ddb43
Use suggestions for shell format arguments
2018-07-31 14:16:36 -07:00
Mark Rousskov
2aec4e882c
Rollup merge of #52649 - estebank:fmt-span, r=oli-obk
...
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-26 09:18:30 -06:00
Esteban Küber
7bd94e0738
Rename method and remove commented out code
2018-07-24 20:37:38 -07:00
Esteban Küber
3298b9f8c7
Fix unittest
2018-07-24 18:44:34 -07:00
Esteban Küber
4d8aa5989c
Use suggestions for printf
format
2018-07-24 16:01:38 -07:00
ljedrz
fe588d894f
Replace a few expect+format combos with unwrap_or_else+panic
2018-07-23 14:47:13 +02:00
Vadim Petrochenkov
e3acb341b2
Remove some tests using AST comparisons, fix other tests
2018-07-14 14:57:14 +03:00
Vadim Petrochenkov
4d1a30c92b
Remove most of PartialEq
impls from AST and HIR structures
2018-07-14 14:56:57 +03:00
Zack M. Davis
057715557b
migrate codebase to ..=
inclusive range patterns
...
These were stabilized in March 2018's #47813 , and are the Preferred Way
to Do It going forward (q.v. #51043 ).
2018-06-26 07:53:30 -07:00
Irina Popa
b63d7e2b1c
Rename trans to codegen everywhere.
2018-05-17 15:08:30 +03:00
Andre Bogus
e333725664
use fmt::Result where applicable
2018-05-09 02:01:37 +02:00
Phlosioneer
619003d1d4
Implement some trivial size_hints for various iterators
...
This also implements ExactSizeIterator where applicable.
Addresses most of the Iterator traits mentioned in #23708 .
2018-03-20 05:33:59 -04:00
Matt Brubeck
3024c1434a
Use Try syntax for Option in place of macros or match
2017-12-09 14:18:33 -08:00
Zack M. Davis
1b6c9605e4
use field init shorthand EVERYWHERE
...
Like #43008 (f668999
), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Daniel Keep
455723c638
Add foreign formatting directive detection.
...
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.
2016-11-11 15:23:15 +11:00