summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2015-08-03Auto merge of #27134 - fhartwig:derive, r=huonwbors-0/+11
Fixes #25022 This adapts the deriving mechanism to not repeat bounds for the same type parameter. To give an example: for the following code: ```rust #[derive(Clone)] pub struct FlatMap<I, U: IntoIterator, F> { iter: I, f: F, frontiter: Option<U::IntoIter>, backiter: Option<U::IntoIter>, } ``` the latest nightly generates the following impl signature: ```rust impl <I: ::std::clone::Clone, U: ::std::clone::Clone + IntoIterator, F: ::std::clone::Clone> ::std::clone::Clone for FlatMap<I, U, F> where I: ::std::clone::Clone, F: ::std::clone::Clone, U::IntoIter: ::std::clone::Clone, U::IntoIter: ::std::clone::Clone ``` With these changes, the signature changes to this: ```rust impl <I, U: IntoIterator, F> ::std::clone::Clone for FlatMap<I, U, F> where I: ::std::clone::Clone, F: ::std::clone::Clone, U::IntoIter: ::std::clone::Clone ``` (Nothing in the body of the impl changes) Note that the second impl is more permissive, as it doesn't have a `Clone` bound on `U` at all. There was a compile-fail test that failed due to this. I don't understand why we would want the old behaviour (and nobody on IRC could tell me either), so please tell me if there is a good reason that I missed.
2015-07-28remove `get_ident` and `get_name`, make `as_str` soundOliver Schneider-82/+65
2015-07-26Remove `ast::LocalSource` with only one used variantmitaa-4/+1
`LocalSource` indicated wether a let binding originated from for-loop desugaring to enable specialized error messages, but for-loop expansion has changed and this is now achieved through `MatchSource::ForLoopDesugar`.
2015-07-25Auto merge of #27253 - bossmc:unbalanced-delimiters-cause-ice, r=nikomatsakisbors-2/+2
This introduces a test for #23389 and improves the error behaviour to treat the malformed LHS as an error, not a compiler bug. The parse phase that precedes the call to `check_lhs_nt_follows` could possibly be enhanced to police the format itself (which the old code suggests was the original intention), but I'm not sure that's any nicer than just parsing the matcher as generic rust code and then policing the specific requirements for being a macro matcher afterwards (as this does). Fixes #23389
2015-07-24Make ICE an error and use a sensible error messageAndy Caldwell-2/+2
2015-07-23review feedback: common-subexpression-elim across functions in pushpop_safe ↵Felix S. Klock II-4/+4
impl.
2015-07-22Allow unstable code to be injected by placement-`in` expansion.Felix S. Klock II-3/+23
(Over time the stability checking has gotten more finicky; in particular one must attach the (whole) span of the original `in PLACE BLOCK` expression to the injected references to unstable paths, as noted in the comments.) call `push_compiler_expansion` during the placement-`in` expansion.
2015-07-22Add feature-gates for desugaring-based `box` and placement-`in`.Felix S. Klock II-0/+7
update test/compile-fail/feature-gate-box-expr.rs to reflect new feature gates. Part of what lands with Issue 22181.
2015-07-22Revise placement-in expansion to use `push/pop_unsafe` and `move_val_init`.Felix S. Klock II-24/+37
2015-07-22prototype Placer protocol for unstable overloaded-box and placement-in.Felix S. Klock II-0/+114
2015-07-22Hack for "unsafety hygiene" -- `push_unsafe!` and `pop_unsafe!`.Felix S. Klock II-0/+101
Even after expansion, the generated expressions still track depth of such pushes (i.e. how often you have "pushed" without a corresponding "pop"), and we add a rule that in a context with a positive `push_unsafe!` depth, it is effectively an `unsafe` block context. (This way, we can inject code that uses `unsafe` features, but still contains within it a sub-expression that should inherit the outer safety checking setting, outside of the injected code.) This is a total hack; it not only needs a feature-gate, but probably should be feature-gated forever (if possible). ignore-pretty in test/run-pass/pushpop-unsafe-okay.rs
2015-07-21Avoid repeated trait bounds in derived implsFlorian Hartwig-0/+11
2015-07-21Provide a filemap ctor with line infoNick Cameron-2/+2
2015-07-13Auto merge of #27000 - alexcrichton:semi-after-type, r=cmrbors-1/+1
This commit expands the follow set of the `ty` and `path` macro fragments to include the semicolon token as well. A semicolon is already allowed after these tokens, so it's currently a little too restrictive to not have a semicolon allowed. For example: extern { fn foo() -> i32; // semicolon after type } fn main() { struct Foo; Foo; // semicolon after path }
2015-07-12syntax: Allow semi tokens after macro ty/pathAlex Crichton-1/+1
This commit expands the follow set of the `ty` and `path` macro fragments to include the semicolon token as well. A semicolon is already allowed after these tokens, so it's currently a little too restrictive to not have a semicolon allowed. For example: extern { fn foo() -> i32; // semicolon after type } fn main() { struct Foo; Foo; // semicolon after path }
2015-07-10Change some instances of .connect() to .join()Wesley Wiser-2/+2
2015-07-10Auto merge of #26907 - nrc:save-fns, r=brsonbors-3/+4
r? @huonw
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-2/+1
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-07-09save-analysis: API-ify pathsNick Cameron-1/+1
2015-07-09Fix a bug where macros in expression position don't have expansion inidices ↵Nick Cameron-3/+4
in their spans
2015-06-18Auto merge of #26347 - nagisa:macro-exp, r=nrcbors-19/+26
r? @nrc, because breakage was caused by https://github.com/rust-lang/rust/pull/25318
2015-06-16Remove superfluous variableSimonas Kazlauskas-2/+0
2015-06-16Fix file!(), line!() and column!() macrosSimonas Kazlauskas-19/+28
These used to return wrong results in case they were expanded inside compiler’s iternal syntax sugar (closures, if-let) expansions Fixes #26322
2015-06-14Replaced a comment mentioning a fixed issueMarkus Westerlind-3/+5
Replaced it with a comment mentioning the rationale for checking the discriminants first.
2015-06-13Utilize discriminant_value for more efficient derivingMarkus-39/+85
The new code generated for deriving on enums looks something like this: ```rust let __self0_vi = unsafe { std::intrinsics::discriminant_value(&self) } as i32; let __self1_vi = unsafe { std::intrinsics::discriminant_value(&__arg1) } as i32; let __self2_vi = unsafe { std::intrinsics::discriminant_value(&__arg2) } as i32; /// if __self0_vi == __self1_vi && __self0_vi == __self2_vi && ... { match (...) { (Variant1, Variant1, ...) => Body1 (Variant2, Variant2, ...) => Body2, ... _ => ::core::intrinsics::unreachable() } } else { ... // catch-all remainder can inspect above variant index values. } ``` This helps massively for C-like enums since they will be compiled as a single comparison giving observed speedups of up to 8x. For more complex enums the speedup is more difficult to measure but it should not be slower to generate code this way regardless.
2015-06-11Conver reborrows to .iter() calls where appropriateJoshua Landau-1/+1
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-17/+17
2015-06-07change some statics to constantsOliver 'ker' Schneider-0/+1
2015-05-27Auto merge of #25713 - Stebalien:pattern, r=alexcrichtonbors-0/+1
Needed to support: ```rust match X { pattern if Y ... } for pattern in Y {} ``` IMO, this shouldn't require an RFC because it can't interfere with any future language changes (because `pattern if` and `pattern in` are already legal in rust) and can't cause any ambiguity.
2015-05-24Auto merge of #25609 - nikomatsakis:const-fn, r=pnkfelixbors-2/+6
This is a port of @eddyb's `const-fn` branch. I rebased it, tweaked a few things, and added tests as well as a feature gate. The set of tests is still pretty rudimentary, I'd appreciate suggestions on new tests to write. Also, a double-check that the feature-gate covers all necessary cases. One question: currently, the feature-gate allows the *use* of const functions from stable code, just not the definition. This seems to fit our usual strategy, and implies that we might (perhaps) allow some constant functions in libstd someday, even before stabilizing const-fn, if we were willing to commit to the existence of const fns but found some details of their impl unsatisfactory. r? @pnkfelix
2015-05-22Allow patterns to be followed by if and in.Steven Allen-0/+1
Needed to support: match X { pattern if Y ... } for pattern in Y {}
2015-05-22Let MultiItemDecorator take `&Annotatable` (fixes #25683)Manish Goregaokar-34/+34
2015-05-21Make various fixes:Niko Matsakis-0/+1
- add feature gate - add basic tests - adjust parser to eliminate conflict between `const fn` and associated constants - allow `const fn` in traits/trait-impls, but forbid later in type check - correct some merge conflicts
2015-05-21syntax: parse `const fn` for free functions and inherent methods.Eduard Burtescu-2/+5
2015-05-17Make #[derive(Debug)] work with unsized fieldsSteven Fackler-5/+11
Closes #25394
2015-05-17Allow #[derive()] to generate unsafe methodsManish Goregaokar-1/+23
2015-05-17Auto merge of #25387 - eddyb:syn-file-loader, r=nikomatsakisbors-5/+5
This allows compiling entire crates from memory or preprocessing source files before they are tokenized. Minor API refactoring included, which is a [breaking-change] for libsyntax users: * `ParseSess::{next_node_id, reserve_node_ids}` moved to rustc's `Session` * `new_parse_sess` -> `ParseSess::new` * `new_parse_sess_special_handler` -> `ParseSess::with_span_handler` * `mk_span_handler` -> `SpanHandler::new` * `default_handler` -> `Handler::new` * `mk_handler` -> `Handler::with_emitter` * `string_to_filemap(sess source, path)` -> `sess.codemap().new_filemap(path, source)`
2015-05-16Auto merge of #25444 - nikomatsakis:macro-tt-fix, r=pnkfelixbors-34/+78
Permit token trees, identifiers, and blocks to be following by sequences. Fixes #25436. r? @pnkfelix
2015-05-15Permit token trees, identifiers, and blocks to be following byNiko Matsakis-34/+78
sequences. Fixes #25436.
2015-05-15syntax: Unquoting some statements requires trailing semicolonsErick Tryzelaar-3/+11
2015-05-15syntax: Add unquoting ast::{Generics,WhereClause}Erick Tryzelaar-0/+12
2015-05-14syntax: replace sess.span_diagnostic.cm with sess.codemap().Eduard Burtescu-1/+1
2015-05-14syntax: refactor (Span)Handler and ParseSess constructors to be methods.Eduard Burtescu-4/+4
2015-05-13Auto merge of #25318 - nrc:for-expn, r=sfacklerbors-9/+42
r? @sfackler
2015-05-13Merge branch 'master' into mulit-decorNick Cameron-3/+3
2015-05-12RebasingNick Cameron-17/+17
2015-05-12Merge branch 'master' intoNick Cameron-34/+42
2015-05-12Proper spans for for loop expansionNick Cameron-9/+42
2015-05-11Auto merge of #25085 - carols10cents:remove-old-tilde, r=steveklabnikbors-3/+3
There were still some mentions of `~[T]` and `~T`, mostly in comments and debugging statements. I tried to do my best to preserve meaning, but I might have gotten some wrong-- I'm happy to fix anything :)
2015-05-09Rollup merge of #25216 - barosl:no-more-task, r=ManishearthManish Goregaokar-1/+1
I've found that there are still huge amounts of occurrences of `task`s in the documentation. This PR tries to eliminate all of them in favor of `thread`.