about summary refs log tree commit diff
path: root/src/libsyntax_ext/format.rs
AgeCommit message (Collapse)AuthorLines
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.
2016-04-24syntax: Merge keywords and remaining special idents in one listVadim Petrochenkov-4/+3
Simplify the macro used for generation of keywords Make `Keyword::ident` private
2016-04-24syntax: Make static/super/self/Self keywords + special ident cleanupVadim Petrochenkov-2/+2
2016-04-24syntax: Get rid of token::IdentStyleVadim Petrochenkov-1/+1
2016-02-11Remove some unnecessary indirection from AST structuresVadim Petrochenkov-1/+1
2016-02-11[breaking-change] don't glob export ast::Mutablity variantsOliver 'ker' Schneider-3/+3
2016-02-11[breaking-change] don't glob export ast::Item_ variantsOliver 'ker' Schneider-1/+1
2016-02-11[breaking-change] don't pub export ast::Stmt_ variantsOliver Schneider-1/+1
2016-02-11[breaking-change] don't pub export ast::Lit_ variantsOliver Schneider-1/+1
2016-02-11[breaking-change] don't pub export ast::Ty_ variantsOliver Schneider-1/+1
2016-02-11[breaking-change] don't glob export ast::Expr_ variantsOliver Schneider-1/+1
2016-02-11[breaking-change] don't glob export ast::Decl_ variantsOliver Schneider-1/+1
2016-01-22Extended save-analysis to support generated code, alterned some spans in ↵Daniel Campbell-3/+3
format_args! and derive to maintain compatability
2015-12-31Cut out a bunch of Result and panictry! boilerplate from libsyntax.Nick Cameron-2/+2
[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2015-12-30use structured errorsNick Cameron-4/+5
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-0/+716