summary refs log tree commit diff
path: root/src/libsyntax_ext/format.rs
AgeCommit message (Collapse)AuthorLines
2019-12-06Do not ICE whith a precision flag in formatting str and no format argumentsEsteban Küber-4/+6
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.
2019-05-13Pass a `Symbol` to `check_name`, `emit_feature_err`, and related functions.Nicholas Nethercote-3/+3
2019-04-04Fix cases of conflicting two-phase borrowsMatthew Jasper-2/+2
2019-02-13Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasperMazdak Farrokhzad-2/+2
Rename rustc_errors dependency in rust 2018 crates I think this is a better solution than `use rustc_errors as errors` in `lib.rs` and `use crate::errors` in modules. Related: rust-lang/cargo#5653 cc #58099 r? @Centril
2019-02-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-3/+3
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-2/+2
2019-02-11Require a list of features to allow in `allow_internal_unstable`Oliver Scherer-1/+1
2019-02-10rustc: doc commentsAlexander Regueiro-3/+3
2019-02-04libsyntax_ext => 2018Taiki Endo-16/+17
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-2/+2
2019-01-22Rollup merge of #57537 - sinkuu:fmt_perf, r=alexcrichtonMazdak Farrokhzad-1/+4
Small perf improvement for fmt Added benchmark is based on #10761
2019-01-12Fix simple formatting optimizationShotaro Yamada-1/+4
name old2 ns/iter new2 ns/iter diff ns/iter diff % speedup fmt::write_str_macro1 12,295 12,308 13 0.11% x 1.00 fmt::write_str_macro2 24,079 21,451 -2,628 -10.91% x 1.12 fmt::write_str_macro_debug 238,363 230,807 -7,556 -3.17% x 1.03 fmt::write_str_ref 6,203 6,064 -139 -2.24% x 1.02 fmt::write_str_value 6,225 6,075 -150 -2.41% x 1.02 fmt::write_vec_macro1 17,144 17,121 -23 -0.13% x 1.00 fmt::write_vec_macro2 29,845 26,703 -3,142 -10.53% x 1.12 fmt::write_vec_macro_debug 248,840 242,117 -6,723 -2.70% x 1.03 fmt::write_vec_ref 5,954 6,438 484 8.13% x 0.92 fmt::write_vec_value 5,959 6,439 480 8.06% x 0.93