about summary refs log tree commit diff
path: root/src/libsyntax_ext/format.rs
AgeCommit message (Collapse)AuthorLines
2019-12-30Rename directories for some crates from `syntax_x` to `rustc_x`Vadim Petrochenkov-1233/+0
`syntax_expand` -> `rustc_expand` `syntax_pos` -> `rustc_span` `syntax_ext` -> `rustc_builtin_macros`
2019-12-22Format the worldMark Rousskov-116/+114
2019-11-25Tweak duplicate fmt arg errorEsteban Küber-1/+2
2019-11-09Rollup merge of #66134 - estebank:unknown-formatting-trait, r=nikomatsakisMazdak Farrokhzad-33/+55
Point at formatting descriptor string when it is invalid When a formatting string contains an invalid descriptor, point at it instead of the argument: ``` error: unknown format trait `foo` --> $DIR/ifmt-bad-arg.rs:86:17 | LL | println!("{:foo}", 1); | ^^^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait ```
2019-11-07syntax::parser::token -> syntax::tokenMazdak Farrokhzad-1/+1
2019-11-06Rollup merge of #66139 - euclio:pluralize, r=nagisaMazdak Farrokhzad-2/+2
use American spelling for `pluralize!`
2019-11-06Rollup merge of #65776 - nnethercote:rename-LocalInternedString-and-more, ↵Mazdak Farrokhzad-1/+1
r=estebank Rename `LocalInternedString` and more This PR renames `LocalInternedString` as `SymbolStr`, removes an unnecessary `impl` from it, improves comments, and cleans up some `SymbolStr` uses. r? @estebank
2019-11-05Provide structured suggestions for valid formatting descriptorsEsteban Küber-1/+22
2019-11-05Point at formatting descriptor string when it is invalidEsteban Küber-33/+34
When a formatting string contains an invalid descriptor, point at it instead of the argument: ``` error: unknown format trait `foo` --> $DIR/ifmt-bad-arg.rs:86:17 | LL | println!("{:foo}", 1); | ^^^ | = note: the only appropriate formatting traits are: - ``, which uses the `Display` trait - `?`, which uses the `Debug` trait - `e`, which uses the `LowerExp` trait - `E`, which uses the `UpperExp` trait - `o`, which uses the `Octal` trait - `p`, which uses the `Pointer` trait - `b`, which uses the `Binary` trait - `x`, which uses the `LowerHex` trait - `X`, which uses the `UpperHex` trait ```
2019-11-05use American spelling for `pluralize!`Andy Russell-2/+2
2019-11-05Do not ICE whith a precision flag in formatting str and no format argumentsEsteban Küber-4/+6
2019-11-02Simplify various `Symbol` use points.Nicholas Nethercote-1/+1
Including removing a bunch of unnecessary `.as_str()` calls, and a bunch of unnecessary sigils.
2019-10-23Tweak format string error to point at arguments alwaysEsteban Küber-1/+4
Add secondary span labels with no text to make it clear when there's a mismatch bewteen the positional arguments in a format string and the arguments to the macro. This shouldn't affect experienced users, but it should make it easier for newcomers to more clearly understand how `format!()` and `println!()` are supposed to be used. ``` error: 2 positional arguments in format string, but there is 1 argument --> file8.rs:2:14 | 2 | format!("{} {}", 1); | ^^ ^^ - ``` instead of ``` error: 2 positional arguments in format string, but there is 1 argument --> file8.rs:2:14 | 2 | format!("{} {}", 1); | ^^ ^^ ```
2019-10-16move syntax::ext to new crate syntax_expandMazdak Farrokhzad-1/+1
2019-09-25Fix format macro expansions spans to be macro-generatedStephen Crane-6/+6
New Exprs generated as part of the format macro expansion should get the macro expansion span which has an expansion context, not the span of the format string which does not.
2019-09-23cleanup librustc_errors Handler code.Mazdak Farrokhzad-2/+2
2019-09-20factor out pluralisation remains after #64280gaolei-1/+2
2019-09-15Give more `Idents` spansMatthew Jasper-11/+11
2019-09-14Auto merge of #64080 - estebank:parse-format-comma, r=zackmdavisbors-4/+12
Be accurate on `format!` parse error expectations Fix https://github.com/rust-lang/rust/issues/57277.
2019-09-06Correct pluralisation of various diagnostic messagesvarkor-1/+1
2019-09-06Rollup merge of #64111 - Centril:ast-only-patkind-or, r=petrochenkovMazdak Farrokhzad-1/+1
or-patterns: Uniformly use `PatKind::Or` in AST & Fix/Cleanup resolve Following up on work in https://github.com/rust-lang/rust/pull/63693 and https://github.com/rust-lang/rust/pull/61708, in this PR we: - Uniformly use `PatKind::Or(...)` in AST: - Change `ast::Arm.pats: Vec<P<Pat>>` => `ast::Arm.pat: P<Pat>` - Change `ast::ExprKind::Let.0: Vec<P<Pat>>` => `ast::ExprKind::Let.0: P<Pat>` - Adjust `librustc_resolve/late.rs` to correctly handle or-patterns at any level of nesting as a result. In particular, the already-bound check which rejects e.g. `let (a, a);` now accounts for or-patterns. The consistency checking (ensures no missing bindings and binding mode consistency) also now accounts for or-patterns. In the process, a bug was found in the current compiler which allowed: ```rust enum E<T> { A(T, T), B(T) } use E::*; fn foo() { match A(0, 1) { B(mut a) | A(mut a, mut a) => {} } } ``` The new algorithms took a few iterations to get right. I tried several clever schemes but ultimately a version based on a stack of hashsets and recording product/sum contexts was chosen since it is more clearly correct. - Clean up `librustc_resolve/late.rs` by, among other things, using a new `with_rib` function to better ensure stack dicipline. - Do not push the change in AST to HIR for now to avoid doing too much in this PR. To cope with this, we introduce a temporary hack in `rustc::hir::lowering` (clearly marked in the diff). cc https://github.com/rust-lang/rust/issues/54883 cc @dlrobertson @matthewjasper r? @petrochenkov
2019-09-05or-patterns: syntax: adjust derive, format, and building.Mazdak Farrokhzad-1/+1
2019-09-03use TokenStream rather than &[TokenTree] for built-in macrosAleksey Kladov-5/+5
That way, we don't loose the jointness info
2019-09-01Be accurate on `format!` parse error expectationsEsteban Küber-4/+12
2019-08-23Audit uses of `apply_mark` in built-in macrosVadim Petrochenkov-6/+5
Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API. The new API is much less error prone and doesn't rely on macros having default transparency.
2019-08-15Remove `Spanned` from `mk_name_value_item_str` and `expr_to_spanned_string`Vadim Petrochenkov-8/+8
2019-08-13syntax: Remove `DummyResult::expn_only`Vadim Petrochenkov-1/+1
2019-08-09Rollup merge of #63114 - matthewjasper:hygienic-format-args, r=petrochenkovMazdak Farrokhzad-2/+2
Remove gensym in format_args This also fixes some things to allow us to export opaque macros from libcore: * Don't consider items that are only reachable through opaque macros as public/exported (so they aren't linted as needing docs) * Mark private items reachable from the root of libcore as unstable - they are now reachable (in principle) in other crates via macros in libcore r? @petrochenkov
2019-08-05Remove gensym from format_argsMatthew Jasper-2/+2
2019-08-03Rollup merge of #63146 - Mark-Simulacrum:clean-attr, r=petrochenkovMazdak Farrokhzad-1/+0
Cleanup syntax::attr Mostly removing needless arguments to constructors r? @petrochenkov
2019-07-31fix dedupEsteban Küber-1/+1
2019-07-31Replace AstBuilder with inherent methodsMark Rousskov-1/+0
2019-07-29review commentsEsteban Küber-1/+1
2019-07-29Improve handling of invalid references in `format!()`Esteban Küber-13/+34
2019-07-29On `format!()` arg count mismatch provide extra infoEsteban Küber-15/+92
When positional width and precision formatting flags are present in a formatting string that has an argument count mismatch, provide extra information pointing at them making it easiser to understand where the problem may lay: ``` error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:78:15 | LL | println!("{} {:.*} {}", 1, 3.2, 4); | ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:81:15 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); | ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag | | | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 3 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:84:15 | LL | println!("{} {:07$} {}", 1, 3.2, 4); | ^^ ^^---^ ^^ | | | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html ```
2019-07-23Rollup merge of #62791 - estebank:type-ascription, r=petrochenkovMark Rousskov-1/+4
Handle more cases of typos misinterpreted as type ascription Fix #60933, #54516. CC #47666, #34255, #48016.
2019-07-20Auto merge of #62710 - estebank:bad-named-args, r=petrochenkovbors-15/+24
Specific error for positional args after named args in `format!()` When writing positional arguments after named arguments in the `format!()` and `println!()` macros, provide a targeted diagnostic. Follow up to https://github.com/rust-lang/rust/pull/57522/files#r247278885
2019-07-19Handle more cases of typos misinterpreted as type ascriptionEsteban Küber-1/+4
2019-07-19Adjust other names after the `Mark` renamingVadim Petrochenkov-4/+4
2019-07-15Specific error for positional args after named args in `format!()`Esteban Küber-15/+24
When writing positional arguments after named arguments in the `format!()` and `println!()` macros, provide a targeted diagnostic.
2019-07-07syntax: Migrate built-in macros to the regular stability checkingVadim Petrochenkov-30/+17
2019-06-18rustc: remove 'x: 'y bounds (except from comments/strings).Eduard-Mihai Burtescu-1/+1
2019-06-15Remove unnecessary `.clone()`Shotaro Yamada-1/+1
2019-06-09Introduce InnerSpan abstractionMark Rousskov-8/+6
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-4/+4
2019-06-09Use Symbol for named arguments in fmt_macrosMark Rousskov-13/+12
2019-06-07parser: `self.span` -> `self.token.span`Vadim Petrochenkov-2/+2
2019-06-06syntax: Remove duplicate span from `token::Ident`Vadim Petrochenkov-3/+3
2019-06-06syntax: Use `Token` in `Parser`Vadim Petrochenkov-1/+1
2019-05-27Pass symbols to `ExtCtxt::std_path` instead of strings.Nicholas Nethercote-5/+5
Because this function is hot. Also remove the dead `ty_option` function.