about summary refs log tree commit diff
path: root/src/libsyntax_ext/format.rs
AgeCommit message (Collapse)AuthorLines
2018-05-26Add `Ident::as_str` helperVadim Petrochenkov-1/+1
2018-05-17Rollup merge of #50610 - estebank:fmt-str, r=KimundiMark Simulacrum-3/+6
Improve format string errors Point at format string position inside the formatting string: ``` error: invalid format string: unmatched `}` found --> $DIR/format-string-error.rs:21:22 | LL | let _ = format!("}"); | ^ unmatched `}` in format string ``` Explain that argument names can't start with an underscore: ``` error: invalid format string: invalid argument name `_foo` --> $DIR/format-string-error.rs:15:23 | LL | let _ = format!("{_foo}", _foo = 6usize); | ^^^^ invalid argument name in format string | = note: argument names cannot start with an underscore ``` Fix #23476. The more accurate spans will only be seen when using `format!` directly, when using `println!` the diagnostics machinery makes the span be the entire statement.
2018-05-17Rename trans to codegen everywhere.Irina Popa-14/+14
2018-05-10Improve format string errorsEsteban Küber-3/+6
- Point at format string position inside the formatting string - Explain that argument names can't start with an underscore
2018-04-24Gensym arguments for format macroJames Sanderson-7/+9
2018-04-06Use `Span::apply_mark` where possibleVadim Petrochenkov-3/+3
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-1/+1
2018-03-05while let all the thingsleonardo.yvens-11/+6
2018-01-16Add secondary span pointing at the statement (error span)Esteban Küber-2/+6
2018-01-15Point at unused arguments for format stringEsteban Küber-10/+2
Avoid overlapping spans by only pointing at the arguments that are not being used in the argument string. Enable libsyntax to have diagnostics with multiple primary spans by accepting `Into<MultiSpan>` instead of `Span`.
2017-11-09Retain information on whether a format argument has explicit positionTommy Ip-16/+34
2017-11-06Make format! positional argument errors clearTommy Ip-8/+41
2017-09-10Use rvalue promotion to 'static instead of static items.Eduard-Mihai Burtescu-36/+3
2017-08-30Make fields of `Span` privateVadim Petrochenkov-7/+5
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-6/+6
Like #43008 (f668999), but _much more aggressive_.
2017-08-01Fixed extra cases found in better checking.Isaac van Bakel-1/+1
2017-07-28format!: use a dummy span rather than callee span for the span base for ↵Nick Cameron-3/+5
temporary variables
2017-07-18Change the error message for multiple unused print paramsPerry Fraser-2/+6
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-5/+8
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-23Removed as many "```ignore" as possible.kennytm-1/+2
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-05-25Hygienize lifetimes.Jeffrey Seyfried-2/+2
2017-03-29Refactor how spans are combined in the parser.Jeffrey Seyfried-11/+4
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-1/+2
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-4/+4
places.
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-2/+3
2016-11-12Rollup merge of #37695 - estebank:unescaped-curly, r=alexcrichtonEduard-Mihai Burtescu-2/+6
On fmt string with unescaped `{` note how to escape On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char. Fix #34300.
2016-11-11On fmt string with unescaped `{` note how to escapeEsteban Küber-2/+6
On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a note explaining how to escape the `{` char.
2016-11-11Add foreign formatting directive detection.Daniel Keep-2/+74
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-09-28libsyntax: clearer names for some AST partsJonas Schievink-1/+1
This applies the HIR changes from the previous commits to the AST, and is thus a syntax-[breaking-change] Renames `PatKind::Vec` to `PatKind::Slice`, since these are called slice patterns, not vec patterns. Renames `TyKind::Vec`, which represents the type `[T]`, to `TyKind::Slice`. Renames `TyKind::FixedLengthVec` to `TyKind::Array`.
2016-09-13Avoid needless reexpansions.Jeffrey Seyfried-11/+8
2016-08-12run rustfmt on libsyntax_ext folderSrinivas Reddy Thatiparthy-68/+89
2016-07-29syntax_ext: format: fix ICE with bad named argumentsWang Xuerui-1/+3
2016-07-14syntax_ext: format: better code documentationWang Xuerui-12/+46
2016-07-14syntax_ext: format: de-duplicate argument objectsWang Xuerui-12/+31
2016-07-14syntax_ext: format: process counts uniquely and separatelyWang Xuerui-11/+62
2016-07-14syntax_ext: format: allow multiple formats for one argumentWang Xuerui-69/+57
This commit removed the restriction of only allowing one type per argument. This is achieved by adding mappings between macro arguments and format placeholders, then taking the mapping into consideration when emitting the Arguments expression. syntax_ext: format: fix implicit positional arguments syntax_ext: format: don't panic if no args given for implicit positional args Check the list lengths before use. Fixes regression of `compile-fail/macro-backtrace-println.rs`. syntax_ext: format: also map CountIsParam indices to expanded args syntax_ext: format: fix ICE in case of malformed format args
2016-07-14syntax_ext: format: rename variants of ArgumentType for clarityWang Xuerui-7/+7
2016-07-14syntax_ext: format: resolve named arguments earlyWang Xuerui-85/+62
Converts named argument references into indices, right after verification as suggested by @alexcrichton. This drastically simplifies the whole process!
2016-07-14syntax_ext: format: separate verification and translation of piecesWang Xuerui-5/+11
2016-07-14format: remove all implicit ref handling outside of libfmt_macrosWang Xuerui-17/+12
format: beautifully get rid of ArgumentNext and CountIsNextParam Now that CountIsNextParam and ArgumentNext are resolved during parse, the need for handling them outside of libfmt_macros is obviated. Note: *one* instance of implicit reference handling still remains, and that's for implementing `all_args_simple`. It's trivial enough though, so in this case it may be tolerable.
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-17/+11
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
2016-06-26Rollup merge of #34436 - jseyfried:no_block_expr, r=eddybJeffrey Seyfried-1/+1
To allow these braced macro invocation, this PR removes the optional expression from `ast::Block` and instead uses a `StmtKind::Expr` at the end of the statement list. Currently, braced macro invocations in blocks can expand into statements (and items) except when they are last in a block, in which case they can only expand into expressions. For example, ```rust macro_rules! make_stmt { () => { let x = 0; } } fn f() { make_stmt! {} //< This is OK... let x = 0; //< ... unless this line is commented out. } ``` Fixes #34418.
2016-06-26Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddybJeffrey Seyfried-5/+6
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26Rollup merge of #34385 - cgswords:tstream, r=nrcJeffrey Seyfried-2/+3
syntax-[breaking-change] cc #31645 (Only breaking because ast::TokenTree is now tokenstream::TokenTree.) This pull request refactors TokenTrees into their own file as src/libsyntax/tokenstream.rs, moving them out of src/libsyntax/ast.rs, in order to prepare for an accompanying TokenStream implementation (per RFC 1566).
2016-06-23Remove field `expr` of `ast::Block`Jeffrey Seyfried-3/+4
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-1/+2
2016-06-21Refactored tokentrees into their own files in preparation for tokenstreams. ↵cgswords-2/+3
Modified tests to point to the new file now.
2016-06-17Fix falloutJeffrey Seyfried-5/+7
2016-05-16syntax_ext: format: remove reference to methods in commentWang Xuerui-1/+1
2016-05-16syntax_ext: format: nest_level's are no moreWang Xuerui-20/+4
`nest_level` is long dead since cac7a2053aba7be214d5e58e13867089638a8f50 (PR #14831), so is `check_positional_ok()`. Let's bid them farewell.