summary refs log tree commit diff
path: root/src/libsyntax/print
AgeCommit message (Collapse)AuthorLines
2019-12-07Print the visibility in `print_variant`.Mazdak Farrokhzad-0/+1
2019-12-06Rename to `then_some` and `then`varkor-1/+1
2019-12-06Use `to_option` in various placesvarkor-1/+1
2019-12-02syntax: Use `ast::MacArgs` for macro definitionsVadim Petrochenkov-2/+2
2019-12-02syntax: Use `ast::MacArgs` for attributesVadim Petrochenkov-10/+15
2019-12-02syntax: Remove redundant span from `ast::Mac`Vadim Petrochenkov-2/+2
Also remove a couple of redundant `visit_mac` asserts
2019-12-02syntax: Introduce a struct `MacArgs` for macro argumentsVadim Petrochenkov-14/+10
2019-11-24Add raw address of expressions to the AST and HIRMatthew Jasper-17/+20
2019-11-22Rollup merge of #66183 - Centril:empty-vis-trait-decl, r=petrochenkovMazdak Farrokhzad-0/+1
*Syntactically* permit visibilities on trait items & enum variants Fixes #65041 Suppose we have `$vis trait_item` or `$vis enum_variant` and `$vis` is a `:vis` macro fragment. Before this PR, this would fail to parse. This is now instead allowed as per language team consensus in https://github.com/rust-lang/rust/issues/65041#issuecomment-538105286. (See added tests for elaboration.) Moreover, we now also permit visibility modifiers on trait items & enum variants *syntactically* but reject them with semantic checks (in `ast_validation`): ```rust #[cfg(FALSE)] trait Foo { pub fn bar(); } // OK #[cfg(FALSE)] enum E { pub U } // OK ```
2019-11-16ast: Keep string literals in ABIs preciselyVadim Petrochenkov-6/+4
2019-11-16ast: Keep `extern` qualifiers in functions more preciselyVadim Petrochenkov-7/+15
2019-11-14TAIT: remove `OpaqueTy` in AST.Mazdak Farrokhzad-20/+0
2019-11-11syntactically allow visibility on trait item & enum variantMazdak Farrokhzad-0/+1
2019-11-10move syntax::parse -> librustc_parseMazdak Farrokhzad-7/+7
also move MACRO_ARGUMENTS -> librustc_parse
2019-11-10move config.rs to libsyntax_expandMazdak Farrokhzad-2/+5
2019-11-08ast::ItemKind::Fn: use ast::FnSigMazdak Farrokhzad-3/+3
2019-11-08ast::MethodSig -> ast::FnSigMazdak Farrokhzad-1/+1
2019-11-07move syntax::parse::lexer::comments -> syntax::util::commentsMazdak Farrokhzad-1/+1
2019-11-07move parse::classify -> util::classifyMazdak Farrokhzad-2/+2
2019-11-07syntax::parser::token -> syntax::tokenMazdak Farrokhzad-1/+1
2019-11-07parser: don't hardcode ABIs into grammarMazdak Farrokhzad-11/+9
2019-11-06Make doc comments cheaper with `AttrKind`.Nicholas Nethercote-9/+12
`AttrKind` is a new type with two variants, `Normal` and `DocComment`. It's a big performance win (over 10% in some cases) because `DocComment` lets doc comments (which are common) be represented very cheaply. `Attribute` gets some new helper methods to ease the transition: - `has_name()`: check if the attribute name matches a single `Symbol`; for `DocComment` variants it succeeds if the symbol is `sym::doc`. - `is_doc_comment()`: check if it has a `DocComment` kind. - `{get,unwrap}_normal_item()`: extract the item from a `Normal` variant; panic otherwise. Fixes #60935.
2019-11-02Convert `x.as_str().to_string()` to `x.to_string()` where possible.Nicholas Nethercote-3/+3
2019-10-15syntax::parse::sess -> syntax::sessMazdak Farrokhzad-1/+2
2019-10-14pprust: `p1@p2` -> `p1 @ p2`Mazdak Farrokhzad-1/+2
2019-09-30syntax: Support modern attribute syntax in the `meta` matcherVadim Petrochenkov-18/+22
2019-09-29Rollup merge of #63492 - eddyb:cvarargs, r=nagisa,matthewjasperMazdak Farrokhzad-1/+0
Remove redundancy from the implementation of C variadics. This cleanup was first described in https://github.com/rust-lang/rust/issues/44930#issuecomment-497163539: * AST doesn't track `c_variadic: bool` anymore, relying solely on a trailing `CVarArgs` type in fn signatures * HIR doesn't have a `CVarArgs` anymore, relying solely on `c_variadic: bool` * same for `ty::FnSig` (see tests for diagnostics improvements from that) * `{hir,mir}::Body` have one extra argument than the signature when `c_variadic == true` * `rustc_typeck` and `rustc_mir::{build,borrowck}` need to give that argument the right type (which no longer uses a lifetime parameter, but a function-internal scope) * `rustc_target::abi::call` doesn't need special hacks anymore (since it never sees the `VaListImpl` now, it's all inside the body) r? @nagisa / @rkruppe cc @dlrobertson @oli-obk
2019-09-28syntax: don't keep a redundant c_variadic flag in the AST.Eduard-Mihai Burtescu-1/+0
2019-09-27Filter out stmts made for the redundant_semicolon lint when pretty-printingnathanwhit-3/+12
2019-09-26Rename `MetaItem.node` to `MetaItem.kind`varkor-1/+1
2019-09-26Rename `ForeignItem.node` to `ForeignItem.kind`varkor-1/+1
2019-09-26Rename `Item.node` to `Item.kind`varkor-1/+1
2019-09-26Rename `Stmt.node` to `Stmt.kind`varkor-2/+2
2019-09-26Rename `Ty.node` to `Ty.kind`varkor-2/+2
2019-09-26Rename `TraitItem.node` to `TraitItem.kind`varkor-1/+1
2019-09-26Rename `ImplItem.node` to `ImplItem.kind`varkor-1/+1
2019-09-26Rename `Pat.node` to `Pat.kind`varkor-2/+2
2019-09-26Rename `Expr.node` to `Expr.kind`varkor-30/+27
For both `ast::Expr` and `hir::Expr`.
2019-09-17Print syntax contexts and marks when printing hygiene informationMatthew Jasper-0/+2
2019-09-15Print visibility of `macro` itemsMatthew Jasper-2/+6
2019-09-09Resolve attributes in several placesCaio-0/+1
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
2019-09-07Aggregation of cosmetic changes made during work on REPL PRs: libsyntaxAlexander Regueiro-30/+27
2019-09-07Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkovMazdak Farrokhzad-4/+8
Use hygiene for AST passes AST passes are now able to have resolve consider their expansions as if they were opaque macros defined either in some module in the current crate, or a fake empty module with `#[no_implicit_prelude]`. * Add an ExpnKind for AST passes. * Remove gensyms in AST passes. * Remove gensyms in`#[test]`, `#[bench]` and `#[test_case]`. * Allow opaque macros to define tests. * Move tests for unit tests to their own directory. * Remove `Ident::{gensym, is_gensymed}` - `Ident::gensym_if_underscore` still exists. cc #60869, #61019 r? @petrochenkov
2019-09-06Rollup merge of #64111 - Centril:ast-only-patkind-or, r=petrochenkovMazdak Farrokhzad-13/+8
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-05Fix 2018 edition expanded pretty printingMatthew Jasper-4/+8
2019-09-05or-patterns: syntax: adjust pretty printing.Mazdak Farrokhzad-13/+8
2019-09-03use TokenStream rather than &[TokenTree] for built-in macrosAleksey Kladov-5/+1
That way, we don't loose the jointness info
2019-08-27Cleanup: Consistently use `Param` instead of `Arg` #62426Kevin Per-9/+9
2019-08-25pprust: Do not print spaces before some tokensVadim Petrochenkov-1/+13
2019-08-17initial implementation of or-pattern parsingDan Robertson-35/+12
Initial implementation of parsing or-patterns e.g., `Some(Foo | Bar)`. This is a partial implementation of RFC 2535.