about summary refs log tree commit diff
path: root/src/libsyntax_ext/format.rs
AgeCommit message (Collapse)AuthorLines
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
2019-01-11don't unwrap unexpected tokens in `format!`Andy Russell-1/+1
Fixes #57512.
2019-01-02make `panictry!` private to libsyntaxAndy Russell-21/+27
This commit completely removes usage of the `panictry!` macro from outside libsyntax. The macro causes parse errors to be fatal, so using it in libsyntax_ext caused parse failures *within* a syntax extension to be fatal, which is probably not intended. Furthermore, this commit adds spans to diagnostics emitted by empty extensions if they were missing, à la #56491.
2018-12-31Use structured suggestion for braceless unicode escape squenceEsteban Küber-2/+2
2018-12-31Account for `\xFF` and `\u{FF}` sequences in string format errorsEsteban Küber-0/+45
2018-12-30Improve error recovery for some built-in macrosVadim Petrochenkov-12/+14
2018-12-29Auto merge of #57140 - estebank:str-err, r=varkorbors-2/+9
Tweaks to format string diagnostics Add label spans and fix incorrect spans. Fix #55155, fix #55350.
2018-12-27Make sure feature gate errors are recoverableVadim Petrochenkov-1/+0
2018-12-27Fix `trace_macros` and `log_syntax`Vadim Petrochenkov-3/+3
2018-12-27Do not abort compilation if expansion produces errorsVadim Petrochenkov-2/+2
Fix a number of uncovered deficiencies in diagnostics
2018-12-26Add span label to unused string formatting argumentEsteban Küber-1/+6
Fix #55350.
2018-12-26Point at correct span for arguments in format stringsEsteban Küber-1/+3
When a format string has escaped whitespace characters format arguments were shifted by one per each escaped character. Account for these escaped characters when synthesizing the spans. Fix #55155.
2018-12-26Various changes to string format diagnosticsEsteban Küber-8/+69
- Point at opening mismatched formatting brace - Account for differences between raw and regular strings - Account for differences between the code snippet and `InternedString` - Add more tests
2018-12-25Remove licensesMark Rousskov-10/+0