about summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
2016-05-28Use the span of `#[derive_Eq]` for `#[structural_match]`Jeffrey Seyfried-42/+14
2016-05-28Refactor away `set_expn_info`Jeffrey Seyfried-9/+2
2016-05-28Fix spans of generated `#[derive_*]` attributesJeffrey Seyfried-45/+44
2016-05-25Add a new AST-only type variant `ImplicitSelf`Vadim Petrochenkov-3/+0
2016-05-25Remove ExplicitSelf from ASTVadim Petrochenkov-30/+22
2016-05-23Auto merge of #33735 - jseyfried:concat_idents_in_ty_positions, r=nrcbors-18/+32
Allow `concat_idents!` in type positions as well as in expression positions This allows the `concat_idents!` macro in type positions as well as in expression positions. r? @nrc
2016-05-19Allow `concat_idents!` in type positions as well as in expression positionsJeffrey Seyfried-18/+32
2016-05-18Rollup merge of #33666 - xen0n:no-more-nest-levels, r=nikomatsakisManish Goregaokar-21/+5
syntax_ext: format: nest_level's are no more Just noticed this while working on #33642 and here's a quick fix, shouldn't touch anything else. It's some historic code indeed...
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-05-15Auto merge of #33505 - petrochenkov:self, r=nrcbors-3/+2
Remove ExplicitSelf from HIR `self` argument is already kept in the argument list and can be retrieved from there if necessary, so there's no need for the duplication. The same changes can be applied to AST, I'll make them in the next breaking batch. The first commit also improves parsing of method declarations and fixes https://github.com/rust-lang/rust/issues/33413. r? @eddyb
2016-05-14syntax: Refactor parsing of method declarationsVadim Petrochenkov-3/+2
Fix spans and expected token lists, fix #33413 + other cosmetic improvements Add test for #33413 Convert between `Arg` and `ExplicitSelf` precisely Simplify pretty-printing for methods
2016-05-12Improve derived implementations for enums with lots of fieldless variantsBjörn Steinbrink-7/+42
A number of trait methods like PartialEq::eq or Hash::hash don't actually need a distinct arm for each variant, because the code within the arm only depends on the number and types of the fields in the variants. We can easily exploit this fact to create less and better code for enums with multiple variants that have no fields at all, the extreme case being C-like enums. For nickel.rs and its by now infamous 800 variant enum, this reduces optimized compile times by 25% and non-optimized compile times by 40%. Also peak memory usage is down by almost 40% (310MB down to 190MB). To be fair, most other crates don't benefit nearly as much, because they don't have as huge enums. The crates in the Rust distribution that I measured saw basically no change in compile times (I only tried optimized builds) and only 1-2% reduction in peak memory usage.
2016-05-03Remove unused trait imports introduced while in reviewSeo Sanghyeon-1/+1
2016-05-02fix rebase flawsNiko Matsakis-3/+3
2016-04-27Auto merge of #32791 - LeoTestard:feature-gate-clean, r=nikomatsakisbors-30/+64
Feature gate clean This PR does a bit of cleaning in the feature-gate-handling code of libsyntax. It also fixes two bugs (#32782 and #32648). Changes include: * Change the way the existing features are declared in `feature_gate.rs`. The array of features and the `Features` struct are now defined together by a single macro. `featureck.py` has been updated accordingly. Note: there are now three different arrays for active, removed and accepted features instead of a single one with a `Status` item to tell wether a feature is active, removed, or accepted. This is mainly due to the way I implemented my macro in the first time and I can switch back to a single array if needed. But an advantage of the way it is now is that when an active feature is used, the parser only searches through the list of active features. It goes through the other arrays only if the feature is not found. I like to think that error checking (in this case, checking that an used feature is active) does not slow down compilation of valid code. :) But this is not very important... * Feature-gate checking pass now use the `Features` structure instead of looking through a string vector. This should speed them up a bit. The construction of the `Features` struct should be faster too since it is build directly when parsing features instead of calling `has_feature` dozens of times. * The MacroVisitor pass has been removed, it was mostly useless since the `#[cfg]-stripping` phase happens before (fixes #32648). The features that must actually be checked before expansion are now checked at the time they are used. This also allows us to check attributes that are generated by macro expansion and not visible to MacroVisitor, but are also removed by macro expansion and thus not visible to PostExpansionVisitor either. This fixes #32782. Note that in order for `#[derive_*]` to be feature-gated but still accepted when generated by `#[derive(Trait)]`, I had to do a little bit of trickery with spans that I'm not totally confident into. Please review that part carefully. (It's in `libsyntax_ext/deriving/mod.rs`.):: Note: this is a [breaking change], since programs with feature-gated attributes on macro-generated macro invocations were not rejected before. For example: ```rust macro_rules! bar ( () => () ); macro_rules! foo ( () => ( #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps bar!(); ); ); ``` foo!();
2016-04-26Auto merge of #31414 - durka:clone-copy, r=alexcrichtonbors-32/+96
special-case #[derive(Copy, Clone)] with a shallow clone If a type is Copy then its Clone implementation can be a no-op. Currently `#[derive(Clone)]` generates a deep clone anyway. This can lead to lots of code bloat. This PR detects the case where Copy and Clone are both being derived (the general case of "is this type Copy" can't be determined by a syntax extension) and generates the shallow Clone impl. Right now this can only be done if there are no type parameters (see https://github.com/rust-lang/rust/issues/31085#issuecomment-178988663), but this restriction can be removed after specialization. Fixes #31085.
2016-04-26shallow Clone for #[derive(Copy,Clone)]Alex Burka-32/+96
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when both derives are present, and there are no generics in the type. The faster impl is simply returning *self (which works because the type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs for more details. There are a few types which are Copy but not Clone, in violation of the definition of Copy. These include large arrays and tuples. The very existence of these types is arguably a bug, but in order for this optimization not to change the applicability of #[derive(Copy, Clone)], the faster Clone impl also injects calls to a new function, core::clone::assert_receiver_is_clone, to verify that all members are actually Clone. This is not a breaking change, because pursuant to RFC 1521, any type that implements Copy should not do any observable work in its Clone impl.
2016-04-24Remove some old code from libsyntaxVadim Petrochenkov-8/+7
2016-04-24syntax: Merge keywords and remaining special idents in one listVadim Petrochenkov-10/+8
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-8/+8
2016-04-24syntax: Get rid of token::IdentStyleVadim Petrochenkov-2/+2
2016-04-22Remove the MacroVisitor pass.Leo Testard-30/+64
This pass was supposed to check use of gated features before `#[cfg]`-stripping but this was not the case since it in fact happens after. Checks that are actually important and must be done before macro expansion are now made where the features are actually used. Close #32648. Also ensure that attributes on macro-generated macro invocations are checked as well. Close #32782 and #32655.
2016-04-14Auto merge of #32908 - oli-obk:hygienic_derive_encodable, r=alexcrichtonbors-7/+10
prevent other `encode` methods from breaking `derive(RustcEncodable)` fixes https://github.com/rust-lang-nursery/rustc-serialize/issues/151
2016-04-12prevent other `encode` methods from breaking `derive(RustcEncodable)`Oliver Schneider-7/+10
2016-04-11std: Stabilize APIs for the 1.9 releaseAlex Crichton-6/+6
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes #27719 cc #27751 (deprecating the `Slice` bits) Closes #27754 Closes #27780 Closes #27809 Closes #27811 Closes #27830 Closes #28050 Closes #29453 Closes #29791 Closes #29935 Closes #30014 Closes #30752 Closes #31262 cc #31398 (still need to deal with `before_exec`) Closes #31405 Closes #31572 Closes #31755 Closes #31756
2016-04-06Rollup merge of #32570 - eddyb:tis-but-a-front, r=nikomatsakisManish Goregaokar-3/+1
r? @nikomatsakis Conflicts: src/librustc_save_analysis/lib.rs src/libsyntax/ast_util.rs
2016-04-06Move span into `StructField`Vadim Petrochenkov-4/+4
2016-04-06Get rid of ast::StructFieldKindVadim Petrochenkov-44/+11
2016-04-06syntax: dismantle ast_util.Eduard Burtescu-3/+1
2016-03-27deriving: factor out discriminant_value constructionAlex Burka-37/+33
2016-03-27fix #21714 by using discriminant_value in #[derive(Hash)]Alex Burka-9/+12
This is the same approach taken in #24270, except that this should not be a breaking change because it only changes the output of hash functions, which nobody should be relying on.
2016-03-25fix cargo.toml for new dependencyNiko Matsakis-0/+1
2016-03-25check for both partialeq and eqNiko Matsakis-36/+45
2016-03-25modify #[deriving(Eq)] to emit #[structural_match]Niko Matsakis-2/+47
to careful use of the span from deriving, we can permit it in stable code if it derives from deriving (not-even-a-pun intended)
2016-03-21Auto merge of #32253 - durka:derive-31886, r=alexcrichtonbors-1/+1
derive: assume enum repr defaults to isize derive: assume enum repr defaults to isize Fixes #31886. Spawned from #32139. r? @alexcrichton
2016-03-18Auto merge of #31977 - bluss:partial-eq-save, r=brsonbors-11/+43
derive: Avoid emitting provided PartialEq, PartialOrd methods for c-like enums derive: Avoid emitting provided PartialEq, PartialOrd method for c-like enums `ne` is completely symmetrical with the method `eq`, and we can save rust code size and compilation time here if we only emit one of them when possible. One case where it's easy to recognize is when it's a C-like enum. Most other cases can not omit ne, because any value field may have a custom PartialEq implementation.
2016-03-18derive: assume enum repr defaults to isizeAlex Burka-1/+1
It was originally intended to be i32, but it isn't. Fixes #31886.
2016-03-17Re-add double underscores in derive (fixes #32292)Manish Goregaokar-43/+43
2016-03-15Auto merge of #32251 - durka:derive-2810, r=alexcrichtonbors-114/+136
derive: clean up hygiene derive: clean up hygiene Fixes #2810. Spawned from #32139. r? @alexcrichton
2016-03-15Auto merge of #32250 - durka:derive-31574, r=alexcrichtonbors-11/+18
derive: use intrinsics::unreachable over unreachable!() derive: use intrinsics::unreachable over unreachable!() Fixes #31574. Spawned from #32139. r? @alexcrichton
2016-03-14Add `default` as contextual keyword, and parse it for impl items.Aaron Turon-0/+2
2016-03-14derive: improve hygiene for type parameters (see #2810)Alex Burka-17/+46
When deriving Hash, RustcEncodable and RustcDecodable, the syntax extension needs a type parameter to use in the inner method. They used to use __H, __S and __D respectively. If this conflicts with a type parameter already declared for the item, bad times result (see the test). There is no hygiene for type parameters, but this commit introduces a better heuristic by concatenating the names of all extant type parameters (and prepending __H).
2016-03-14derive: remove most __ strings FIXME(#2810)Alex Burka-48/+48
This changes local variable names in all derives to remove leading double-underscores. As far as I can tell, this doesn't break anything because there is no user code in these generated functions except for struct, field and type parameter names, and this doesn't cause shadowing of those. But I am still a bit nervous.
2016-03-14fix FIXME(#6449) in #[derive(PartialOrd, Ord)]Alex Burka-55/+48
This replaces some `if`s with `match`es. This was originally not possible because using a global path in a match statement caused a "non-constant path in constant expr" ICE. The issue is long since closed, though you still hit it (as an error now, not an ICE) if you try to generate match patterns using pat_lit(expr_path). But it works when constructing the patterns more carefully.
2016-03-14derive: emit intrinsics::unreachable for impls on empty enumsAlex Burka-11/+18
fixes #31574
2016-03-01derive: Emit only PartialOrd::partial_cmp for simple enumsUlrik Sverdrup-24/+35
Using the same logic as for `PartialEq`, when possible define only `partial_cmp` and leave `lt, le, gt, ge` to their default implementations. This works well for c-like enums.
2016-02-29derive: Skip PartialEq::ne for any zero-field enum or structUlrik Sverdrup-17/+15
Also detect unit structs and enums with zero field struct variants.
2016-02-29derive: Avoid emitting PartialEq::ne for c-like enumsUlrik Sverdrup-5/+28
`ne` is completely symmetrical with the method `eq`, and we can save rust code size and compilation time here if we only emit one of them when possible. One case where it's easy to recognize is when it's a C-like enum. Most other cases can not omit ne, because any value field may have a custom PartialEq implementation.
2016-02-23Some refactoring in deriving/debug.rsVadim Petrochenkov-8/+3