about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-0/+16
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-08auto merge of #17838 : vadimcn/rust/macros, r=alexcrichtonbors-1/+10
2014-10-07Fix the most egregious instances of "local ambiguity: multiple parsing ↵Vadim Chugunov-1/+10
options..." error in macros, which often occurs when trying to match parts of Rust syntax. For example, this matcher: `fn $name:ident( $($param:ident : $pty:ty),* )` would fail when parsing `fn foo()`, because macro parser wouldn't realize that an ident cannot start with `)`. This resolves #5902, and at least partially mitigates #9364 and #3232.
2014-10-06syntax: Parse outer attributes in quote_method!Ben Gamari-7/+2
Fixes #17782.
2014-10-02syntax: ast: remove TyBox and UnBox.Eduard Burtescu-5/+0
2014-10-01auto merge of #17678 : fhahn/rust/issue-17628-infinite-recursion, r=alexcrichtonbors-0/+12
This is a patch for #17628, thanks to @kmcallister for your helpful hints!
2014-10-01Limit recursion depth for macro expansions, closes #17628Florian Hahn-0/+12
2014-10-01auto merge of #17630 : sfackler/rust/cfg-warnings, r=brsonbors-3/+0
Closes #17490
2014-09-30Turn on cfg format warningsSteven Fackler-3/+0
2014-09-30Update after the fall out from the syntax::ptr changesJakub Wieczorek-30/+36
2014-09-30Update based on PR feedbackKevin Ballard-20/+16
2014-09-30Produce a better error for irrefutable `if let` patternsKevin Ballard-2/+2
Modify ast::ExprMatch to include a new value of type ast::MatchSource, making it easy to tell whether the match was written literally or produced via desugaring. This allows us to customize error messages appropriately.
2014-09-30Desugar 'if let' into the appropriate 'match'Kevin Ballard-1/+90
2014-09-29rollup merge of #17592 : kmcallister/inline-asm-locAlex Crichton-1/+12
2014-09-29rollup merge of #17576 : kmcallister/hide-quotesAlex Crichton-49/+51
2014-09-29auto merge of #17409 : farcaller/rust/patch-1, r=huonwbors-2/+6
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.
2014-09-29Fixed quote_method!() implementationVladimir Pouzanov-2/+6
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.
2014-09-28Keep ExpnId abstract by providing conversionsKeegan McAllister-1/+1
2014-09-28auto merge of #17527 : sfackler/rust/cfg-syntax, r=alexcrichtonbors-31/+13
We'll need a snapshot before we can convert the codebase over and turn on the deprecation warnings. cc #17490 This is sitting on top of #17506
2014-09-27Convert cfg syntax to new systemSteven Fackler-31/+13
This removes the ability to use `foo(bar)` style cfgs. Switch them to `foo_bar` or `foo="bar"` instead. [breaking-change]
2014-09-27Translate inline assembly errors back to source locationsKeegan McAllister-1/+12
Fixes #17552.
2014-09-27auto merge of #17506 : sfackler/rust/cfg-attr, r=alexcrichtonbors-0/+59
cc #17490 Reopening of #16230
2014-09-26Hide the quote_*! macros when the feature gate is offKeegan McAllister-49/+51
This makes it easier to experiment with improved quasiquoting as an ordinary plugin library. The list of quote macros in feature_gate.rs was already out of sync; this commit also prevents that problem in the future.
2014-09-25auto merge of #17378 : Gankro/rust/hashmap-entry, r=aturonbors-7/+9
Deprecates the `find_or_*` family of "internal mutation" methods on `HashMap` in favour of the "external mutation" Entry API as part of RFC 60. Part of #17320, but this still needs to be done on the rest of the maps. However they don't have any internal mutation methods defined, so they can be done without deprecating or breaking anything. Work on `BTree` is part of the complete rewrite in #17334. The implemented API deviates from the API described in the RFC in two key places: * `VacantEntry.set` yields a mutable reference to the inserted element to avoid code duplication where complex logic needs to be done *regardless* of whether the entry was vacant or not. * `OccupiedEntry.into_mut` was added so that it is possible to return a reference into the map beyond the lifetime of the Entry itself, providing functional parity to `VacantEntry.set`. This allows the full find_or_insert functionality to be implemented using this API. A PR will be submitted to the RFC to amend this. [breaking-change]
2014-09-24handling fallout from entry apiAlexis Beingessner-7/+9
2014-09-24Remove unused enum variantsJakub Wieczorek-8/+1
2014-09-24Fix rebase falloutSteven Fackler-13/+11
2014-09-23Add a cfg_attr syntax extensionSteven Fackler-0/+61
This extends cfg-gating to attributes. ```rust #[cfg_attr(<cfg pattern>, <attr>)] ``` will expand to ```rust #[<attr>] ``` if the `<cfg pattern>` matches the current cfg environment, and nothing if it does not. The grammar for the cfg pattern has a simple recursive structure: * `value` and `key = "value"` are cfg patterns, * `not(<cfg pattern>)` is a cfg pattern and matches if `<cfg pattern>` does not. * `all(<cfg pattern>, ...)` is a cfg pattern and matches if all of the `<cfg pattern>`s do. * `any(<cfg pattern>, ...)` is a cfg pattern and matches if any of the `<cfg pattern>`s do. Examples: ```rust // only derive Show for assert_eq! in tests #[cfg_attr(test, deriving(Show))] struct Foo { ... } // only derive Show for assert_eq! in tests and debug builds #[cfg_attr(any(test, not(ndebug)), deriving(Show))] struct Foo { ... } // ignore a test in certain cases #[test] #[cfg_attr(all(not(target_os = "linux"), target_endian = "big"), ignore)] fn test_broken_thing() { ... } // Avoid duplication when fixing staging issues in rustc #[cfg_attr(not(stage0), lang="iter")] pub trait Iterator<T> { ... } ```
2014-09-23auto merge of #17402 : steveklabnik/rust/update_manual, r=brsonbors-1/+1
Because I'm still :mask: :mask: :mask: , I figured some mindless tasks would be better than trying to finish the ownership guide. The manual has long been waiting for some :heart: :heart: :heart: , and so I gave it a quick once-over. I made small commits in case any of the changes are a bit weird, I mostly did a few things: 1. changed 'manual' to 'reference.' I feel like this name is better. If it's not, It's not a huge deal. it shouldn't be `rust.md` though. 2. word wrapped everything appropriately. Changes 1&2 are in the first commit, so that its' easier to see the changes in the later ones. 3. fixed other small style issues 4. removed references to things that are in the standard library, and not the language itself There's still lots of gross in here, but I didn't want to pile on too too many changes. /cc @brson @nikomatsakis
2014-09-22librustc: Parse and resolve higher-rank lifetimes in traits.Patrick Walton-1/+2
They will ICE during typechecking if used, because they depend on trait reform. This is part of unboxed closures.
2014-09-22manual -> reference & formattingSteve Klabnik-1/+1
'reference' sounds better than 'manual' to me here, and rust.html is certainly wrong. I also wrapped everything to 80 cols.
2014-09-22auto merge of #17339 : treeman/rust/doc-things, r=alexcrichtonbors-156/+129
Also some cleanup to conform to documentation style.
2014-09-20auto merge of #17319 : kmcallister/rust/method-macro-bt, r=pcwaltonbors-1/+4
We were leaving these on the stack, causing spurious backtraces.
2014-09-19rollup merge of #17338 : nick29581/variants-namespaceAlex Crichton-22/+23
2014-09-19rollup merge of #17314 : eddyb/span-no-gcAlex Crichton-83/+72
2014-09-19Allow syntax extensions to return multiple items, closes #16723.Florian Hahn-16/+11
This patch replaces `MacItem` with `MacItems`.
2014-09-19Add enum variants to the type namespaceNick Cameron-22/+23
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
2014-09-18syntax: use an index in CodeMap instead of Gc for ExpnInfo.Eduard Burtescu-83/+72
2014-09-17librustc: Implement associated types behind a feature gate.Patrick Walton-1/+4
The implementation essentially desugars during type collection and AST type conversion time into the parameter scheme we have now. Only fully qualified names--e.g. `<T as Foo>::Bar`--are supported.
2014-09-17Pop the expansion context after expanding a method macroKeegan McAllister-1/+4
We were leaving these on the stack, causing spurious backtraces. I've confirmed that this test fails without the fix.
2014-09-17doc: Remove "see above".Jonas Hietala-4/+3
2014-09-17doc: Backticks and spelling mistakes.Jonas Hietala-13/+13
2014-09-17doc: Cleanup.Jonas Hietala-149/+123
Remove ~~~ for code block specification. Use /// Over /** */ for doc blocks.
2014-09-16Fallout from renamingAaron Turon-40/+40
2014-09-14Add help diagnostic messagesP1start-0/+4
This adds ‘help’ diagnostic messages to rustc. This is used for anything that provides help to the user, particularly the `--explain` messages that were previously integrated into the relevant error message.
2014-09-14syntax: tests: fix fallout from using ptr::P.Eduard Burtescu-1/+2
2014-09-14syntax: fix fallout from using ptr::P.Eduard Burtescu-1108/+1032
2014-09-13auto merge of #17162 : sfackler/rust/decorator-traits, r=huonwbors-39/+53
The other extension types already worked this way and it can be useful to track some state along with the extension. I also removed the `BasicMacroExpander` and `BasicIdentMacroExpander` since the span inside of them was never used. The expander function types now directly implement the relevant trait.
2014-09-12Track the visited AST's lifetime throughout Visitor.Eduard Burtescu-4/+4
2014-09-12Remove largely unused context from Visitor.Eduard Burtescu-23/+22