about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2015-04-21syntax: Replace [].tail with the stable [1..] syntaxErick Tryzelaar-1/+1
2015-04-21syntax: Remove uses of #[feature(slice_patterns)]Erick Tryzelaar-20/+19
2015-04-21syntax: remove #![feature(box_syntax, box_patterns)]Erick Tryzelaar-33/+33
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0
2015-04-18Auto merge of #23985 - erickt:derive-cleanup, r=ericktbors-512/+496
This extracts some of the minor cleanup patches from #23905.
2015-04-17Rollup merge of #24430 - laumann:trace-macros-flag, r=pnkfelixManish Goregaokar-4/+4
This is the second attempt at turning the trace_macros macro into a compiler flag. See #22619
2015-04-16Auto merge of #24423 - tbelaire:include_bytes, r=alexcrichtonbors-0/+5
This is a little bit tricky, since with include_str!, we know that we are including utf-8 content, so it's safe to store the source as a String in a FileMap. We don't know that for include_bytes!, but I don't think we actually need to track the contents anyways, so I'm passing "". new_filemap does check for the zero length content, and it should be reasonable, howeven I'm not sure if it would be better to pass None instead of Some(Rc::new("")) as the src component of a FileMap. Fixes bug #24348
2015-04-15syntax: Clean up the indentation for #[derive(Eq)]Erick Tryzelaar-12/+14
2015-04-15syntax: Change deriving methods to take a `&mut FnMut(P<Item>)`Erick Tryzelaar-115/+97
This allows #[derive(...)]` to create more than one impl
2015-04-15syntax: Rename deriving/cmp/* to match their current namesErick Tryzelaar-415/+415
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-13/+13
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-14Positive case of `len()` -> `is_empty()`Tamir Duberstein-5/+5
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
2015-04-14include_bytes! now registers the file includedTheo Belaire-0/+5
This is a little bit tricky, since with include_str!, we know that we are including utf-8 content, so it's safe to store the source as a String in a FileMap. We don't know that for include_bytes!, but I don't think we actually need to track the contents anyways, so I'm passing "". new_filemap does check for the zero length content, and it should be reasonable, howeven I'm not sure if it would be better to pass None instead of Some(Rc::new("")) as the src component of a FileMap. Fixes bug #24348
2015-04-14syntax: Remove derive(Rand)Alex Crichton-178/+0
2015-04-14Auto merge of #24312 - rprichard:destabilize-format-args, r=alexcrichtonbors-19/+25
Fixes #22953.
2015-04-14Add "trace-macros" as a compiler flagThomas Jespersen-4/+4
Fixes #22619
2015-04-13Auto merge of #24323 - rprichard:panic-line-type, r=alexcrichtonbors-1/+1
There are syntax extensions that call `std::rt::begin_unwind` passing it a `usize`. I updated the syntax extension to instead pass `u32`, but for bootstrapping reasons, I needed to create a `#[cfg(stage0)]` version of `std::rt::begin_unwind` and therefore also `panic!`.
2015-04-12Use the ecx.call_site() span for generating refs to format_args! internalsRyan Prichard-19/+25
`format_args!` uses `#[allow_internal_unstable]` to access internal functions and structs that are marked unstable. For this to work, the spans on AST nodes referencing unstable internals must be equal (same lo/hi values) to the `format_args!` call site, so that the stability checker can recognize that the AST node was generated by the macro.
2015-04-11Remove the vestigial ExtCtxt::print_backtrace function.Ryan Prichard-12/+0
It was added in 2011-08-05 and reduced to a no-op ten days later.
2015-04-11Propagate macro backtraces more often, improve formatting diagnosticsRyan Prichard-3/+7
* In noop_fold_expr, call new_span in these cases: - ExprMethodCall's identifier - ExprField's identifier - ExprTupField's integer Calling new_span for ExprMethodCall's identifier is necessary to print an acceptable diagnostic for write!(&2, ""). We see this error: <std macros>:2:20: 2:66 error: type `&mut _` does not implement any method in scope named `write_fmt` <std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) ) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With this change, we also see a macro expansion backtrace leading to the write!(&2, "") call site. * After fully expanding a macro, we replace the expansion expression's span with the original span. Call fld.new_span to add a backtrace to this span. (Note that I'm call new_span after bt.pop(), so the macro just expanded isn't on the backtrace.) The motivating example for this change is println!("{}"). The format string literal is concat!($fmt, "arg") and is inside the libstd macro. We need to see the backtrace to find the println! call site. * Add a backtrace to the format_args! format expression span. Addresses #23459
2015-04-11Change the rt::unwind line argument type from usize to u32.Ryan Prichard-1/+1
2015-04-11Auto merge of #24155 - chris-chambers:stmt_macros, r=sfacklerbors-45/+73
Statement macros are now treated somewhat like item macros, in that a statement macro can now expand into a series of statements, rather than just a single statement. This allows statement macros to be nested inside other kinds of macros and expand properly, where previously the expansion would only work when no nesting was present. See: - `src/test/run-pass/macro-stmt_macro_in_expr_macro.rs` - `src/test/run-pass/macro-nested_stmt_macro.rs` This changes the interface of the MacResult trait. make_stmt has become make_stmts and now returns a vector, rather than a single item. Plugin writers who were implementing MacResult will have breakage, as well as anyone using MacEager::stmt. See: - `src/libsyntax/ext/base.rs` This also causes a minor difference in behavior to the diagnostics produced by certain malformed macros. See: - `src/test/compile-fail/macro-incomplete-parse.rs`
2015-04-11Moves expand_stmt's bt_pop so that it balances correctly.Christopher Chambers-3/+4
2015-04-10Simplifications to statement macro handling.Christopher Chambers-14/+11
SmallVector::pop no longer worries about converting a Many repr downward to One or Zero. expand_stmt makes use of `if let` for style purposes.
2015-04-10Eliminates a pointless is_empty test.Christopher Chambers-1/+1
2015-04-10Improves semicolon expansion efficiency, corrects bt_pop placement.Christopher Chambers-16/+15
Implements pop() on SmallVector, and uses it to expand the final semicolon in a statement macro expansion more efficiently. Corrects the placement of the call to fld.cx.bt_pop(). It must run unconditionally to reverse the corresponding push.
2015-04-10fix some comments.Felix S. Klock II-6/+7
2015-04-10Incorporate repr-attr into deriving(PartialOrd) to avoid truncation errors.Felix S. Klock II-13/+38
remove out of date fixme.
2015-04-10Re-add a fixme after some investigation into what's going on.Felix S. Klock II-0/+11
2015-04-10Change `derive` expansions to use `discriminant_value` intrinsic.Felix S. Klock II-30/+27
Fix #15523.
2015-04-08Auto merge of #23998 - nrc:impl-self, r=nikomatsakisbors-41/+2
Closes #23909 r? @nikomatsakis (or anyone else, really)
2015-04-07Improves handling of statement macros.Christopher Chambers-44/+75
Statement macros are now treated somewhat like item macros, in that a statement macro can now expand into a series of statements, rather than just a single statement. This allows statement macros to be nested inside other kinds of macros and expand properly, where previously the expansion would only work when no nesting was present. See: src/test/run-pass/macro-stmt_macro_in_expr_macro.rs src/test/run-pass/macro-nested_stmt_macro.rs This changes the interface of the MacResult trait. make_stmt has become make_stmts and now returns a vector, rather than a single item. Plugin writers who were implementing MacResult will have breakage, as well as anyone using MacEager::stmt. See: src/libsyntax/ext/base.rs This also causes a minor difference in behavior to the diagnostics produced by certain malformed macros. See: src/test/compile-fail/macro-incomplete-parse.rs
2015-04-06Provide context for macro expansions which result in unparsed tokens.Will Hipschman-0/+17
Issue #22425
2015-04-05Add comments suggested by NikoPhil Dawes-22/+0
2015-04-05Work towards a non-panicing parser (libsyntax)Phil Dawes-57/+79
- Functions in parser.rs return PResult<> rather than panicing - Other functions in libsyntax call panic! explicitly for now if they rely on panicing behaviour. - 'panictry!' macro added as scaffolding while converting panicing functions. (This does the same as 'unwrap()' but is easier to grep for and turn into try!()) - Leaves panicing wrappers for the following functions so that the quote_* macros behave the same: - parse_expr, parse_item, parse_pat, parse_arm, parse_ty, parse_stmt
2015-04-03Check uses of `Self` in impls in the compiler rather than during expansionNick Cameron-41/+2
Closes #23909
2015-04-02Auto merge of #23877 - richo:gardening, r=Manishearthbors-11/+22
I also wanted to unignore https://github.com/rust-lang/rust/blob/master/src/libsyntax/ext/expand.rs#L1768-L1777 since the issue it references is closed, but the test fails, and it's internals aren't super clear to me.
2015-04-01cleanup: Test formattingRicho Healey-11/+22
2015-04-01Fallout in libsyntaxNiko Matsakis-3/+3
2015-03-28Rollup merge of #23803 - richo:unused-braces, r=ManishearthManish Goregaokar-2/+2
Pretty much what it says on the tin.
2015-03-28cleanup: Remove unused braces in use statementsRicho Healey-2/+2
2015-03-27rollup merge of #23741: alexcrichton/remove-int-uintAlex Crichton-7/+7
Conflicts: src/librustc/middle/ty.rs src/librustc_trans/trans/adt.rs src/librustc_typeck/check/mod.rs src/libserialize/json.rs src/test/run-pass/spawn-fn.rs
2015-03-27rollup merge of #23776: nrc/allow_trivial_castAlex Crichton-1/+0
r? @alexcrichton
2015-03-27Auto merge of #22930 - Gankro:entry_3, r=aturonbors-6/+4
RFC pending, but this is the patch that does it. Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples. Closes #23508
2015-03-27default => or_insert per RFCAlexis Beingessner-2/+2
2015-03-27Change the trivial cast lints to allow by defaultNick Cameron-1/+0
2015-03-26update everything to use Entry defaultsAlexis-6/+4
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-2/+2
Now that support has been removed, all lingering use cases are renamed.
2015-03-26Auto merge of #23359 - erickt:quote, r=pnkfelixbors-0/+4
This PR allows the quote macros to unquote trait items, impl items, where clauses, and paths.
2015-03-26Auto merge of #21237 - erickt:derive-assoc-types, r=ericktbors-6/+118
This PR adds support for associated types to the `#[derive(...)]` syntax extension. In order to do this, it switches over to using where predicates to apply the type constraints. So now this: ```rust type Trait { type Type; } #[derive(Clone)] struct Foo<A> where A: Trait { a: A, b: <A as Trait>::Type, } ``` Gets expended into this impl: ```rust impl<A: Clone> Clone for Foo<A> where A: Trait, <A as Trait>::Type: Clone, { fn clone(&self) -> Foo<T> { Foo { a: self.a.clone(), b: self.b.clone(), } } } ```