about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-05-15Updates with core::fmt changesAlex Crichton-9/+9
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15syntax: Add a macro, format_args_method!()Alex Crichton-29/+62
Currently, the format_args!() macro takes as its first argument an expression which is the callee of an ExprCall. This means that if format_args!() is used with calling a method a closure must be used. Consider this code, however: format_args!(|args| { foo.writer.write_fmt(args) }, "{}", foo.field) The closure borrows the entire `foo` structure, disallowing the later borrow of `foo.field`. To preserve the semantics of the `write!` macro, it is also impossible to borrow specifically the `writer` field of the `foo` structure because it must be borrowed mutably, but the `foo` structure is not guaranteed to be mutable itself. This new macro is invoked like: format_args_method!(foo.writer, write_fmt, "{}", foo.field) This macro will generate an ExprMethodCall which allows the borrow checker to understand that `writer` and `field` should be borrowed separately. This macro is not strictly necessary, with DST or possibly UFCS other workarounds could be used. For now, though, it looks like this is required to implement the `write!` macro.
2014-05-15auto merge of #14234 : alexcrichton/rust/rollup, r=alexcrichtonbors-1/+11
Let's try this again!
2014-05-15Add `EntryPat` and `NodePat` variants to ast_map.Felix S. Klock II-1/+11
Add `EntryPat` and `NodePat` variants to ast_map, so that lookups for id 1 in `let S{val: _x /* pat 2 */} /* pat 1 */ = ...` will actually resolve to the pattern `S{ ... }`, rather than "unknown node", in a function like `node_id_to_str`.
2014-05-15auto merge of #14040 : hannobraun/rust/force-color-output, r=alexcrichtonbors-6/+20
This pull request fixes #12881. Two caveats: 1. As explained in the commit message, this doesn't include a regression test. If this is unacceptable, please let me know, I'll see what I can do. 1. I'm getting some test failures on make check, all from debuginfo. I suspect this is due to #13680 and not related to my changes (I have GDB 7.7). This is the list of failed tests: > [debuginfo-gdb] debuginfo/basic-types-globals.rs > [debuginfo-gdb] debuginfo/basic-types-mut-globals.rs > [debuginfo-gdb] debuginfo/basic-types.rs > [debuginfo-gdb] debuginfo/borrowed-basic.rs > [debuginfo-gdb] debuginfo/borrowed-managed-basic.rs > [debuginfo-gdb] debuginfo/borrowed-struct.rs > [debuginfo-gdb] debuginfo/borrowed-unique-basic.rs > [debuginfo-gdb] debuginfo/box.rs > [debuginfo-gdb] debuginfo/by-value-non-immediate-argument.rs > [debuginfo-gdb] debuginfo/by-value-self-argument-in-trait-impl.rs > [debuginfo-gdb] debuginfo/closure-in-generic-function.rs > [debuginfo-gdb] debuginfo/evec-in-struct.rs > [debuginfo-gdb] debuginfo/function-arg-initialization.rs > [debuginfo-gdb] debuginfo/function-prologue-stepping-no-split-stack.rs > [debuginfo-gdb] debuginfo/generic-function.rs > [debuginfo-gdb] debuginfo/generic-functions-nested.rs > [debuginfo-gdb] debuginfo/generic-method-on-generic-struct.rs > [debuginfo-gdb] debuginfo/generic-static-method-on-struct-and-enum.rs > [debuginfo-gdb] debuginfo/generic-struct.rs > [debuginfo-gdb] debuginfo/lexical-scope-in-stack-closure.rs > [debuginfo-gdb] debuginfo/lexical-scope-in-unique-closure.rs > [debuginfo-gdb] debuginfo/method-on-generic-struct.rs > [debuginfo-gdb] debuginfo/method-on-tuple-struct.rs > [debuginfo-gdb] debuginfo/name-shadowing-and-scope-nesting.rs > [debuginfo-gdb] debuginfo/recursive-struct.rs > [debuginfo-gdb] debuginfo/self-in-generic-default-method.rs > [debuginfo-gdb] debuginfo/shadowed-argument.rs > [debuginfo-gdb] debuginfo/shadowed-variable.rs > [debuginfo-gdb] debuginfo/simd.rs > [debuginfo-gdb] debuginfo/simple-lexical-scope.rs > [debuginfo-gdb] debuginfo/simple-struct.rs > [debuginfo-gdb] debuginfo/simple-tuple.rs > [debuginfo-gdb] debuginfo/static-method-on-struct-and-enum.rs > [debuginfo-gdb] debuginfo/tuple-struct.rs > [debuginfo-gdb] debuginfo/var-captured-in-nested-closure.rs > [debuginfo-gdb] debuginfo/var-captured-in-sendable-closure.rs > [debuginfo-gdb] debuginfo/var-captured-in-stack-closure.rs I can provide the full output on request.
2014-05-15Add compiler flag to configure output coloringHanno Braun-6/+20
This adds the flag --color, which allows the user to force coloring or turn it off. The default behavior stays the same as before (colorize, if output goes to tty). Why this is beneficial is explained in issue #12881. Please note that this commit doesn't include any regression tests. I thought about how I'd write a test for this and it doesn't seem to be worth the effort to me for a UI change like this. Fixes #12881.
2014-05-15syntax::visit: pub `walk_explicit_self` so impls can call it as defaults do.Felix S. Klock II-3/+13
drive-by: added some doc.
2014-05-14Removed unnecessary arguments for walk_* functionsMichael Darakananda-12/+7
2014-05-13syntax: Improve --pretty normal slightlyAlex Crichton-2/+8
When printing doc comments, always put a newline after them in a macro invocation to ensure that a line-doc-comment doesn't consume remaining tokens on the line.
2014-05-13syntax: Preserve attributes in #[deriving]Alex Crichton-11/+25
Now that the #[deriving] attribute is removed, the raw_pointers_deriving lint was broken. This commit restores the lint by preserving lint attributes across #[deriving] to the implementations and using #[automatically_derived] as the trigger for activating the lint.
2014-05-13syntax: Print suffixed token literals correctlyAlex Crichton-0/+3
Previously, literals "1i" were printed as "1". This fixes the numeric-method-autoexport test for pretty printing.
2014-05-13syntax: Fix parsing << with closure typesAlex Crichton-6/+54
This uses the trick of replacing the << token with a < token to parse closure types correctly. Closes #13324
2014-05-13syntax: Fix printing INT64_MINAlex Crichton-12/+29
Integers are always parsed as a u64 in libsyntax, but they're stored as i64. The parser and pretty printer both printed an i64 instead of u64, sometimes introducing an extra negative sign.
2014-05-13Touch up and rebase previous commitsAlex Crichton-29/+13
* Added `// no-pretty-expanded` to pretty-print a test, but not run it through the `expanded` variant. * Removed #[deriving] and other expanded attributes after they are expanded * Removed hacks around &str and &&str and friends (from both the parser and the pretty printer). * Un-ignored a bunch of tests
2014-05-13libsyntax: Workaround pprust `for` issueklutzy-1/+1
2014-05-13pprust: Remove unnecessary && of `print_tt`klutzy-4/+4
2014-05-13pprust: Print `&&e` instead of `& &e`klutzy-5/+0
2014-05-13pprust: Fix asm outputklutzy-14/+19
2014-05-13pprust: Add parentheses to some Exprklutzy-3/+45
Some `Expr` needs parentheses when printed. For example, without parentheses, `ExprUnary(UnNeg, ExprBinary(BiAdd, ..))` becomes `-lhs + rhs` which is wrong. Those cases don't appear in ordinary code (since parentheses are explicitly added) but they can appear in manually crafted ast by extensions.
2014-05-12Cleanup some ugly variable names, now that we have `let`-hygiene.Paul Stansifer-14/+14
2014-05-12Add some long-overdue documentation on the INTERPOLATED helper macros.Paul Stansifer-1/+6
2014-05-12Add the patch number to version strings. Closes #13289Brian Anderson-1/+1
2014-05-11core: Remove the cast moduleAlex Crichton-14/+14
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-09Register new snapshotsAlex Crichton-8/+2
2014-05-08auto merge of #13985 : alexcrichton/rust/libfmt, r=brsonbors-16/+7
This code does not belong in libstd, and rather belongs in a dedicated crate. In the future, the syntax::ext::format module should move to the fmt_macros crate (hence the name of the crate), but for now the fmt_macros crate will only contain the format string parser. The entire fmt_macros crate is marked #[experimental] because it is not meant for general consumption, only the format!() interface is officially supported, not the internals. This is a breaking change for anyone using the internals of std::fmt::parse. Some of the flags have moved to std::fmt::rt, while the actual parsing support has all moved to the fmt_macros library. [breaking-change]
2014-05-08std: Extract format string parsing out of libstdAlex Crichton-16/+7
This code does not belong in libstd, and rather belongs in a dedicated crate. In the future, the syntax::ext::format module should move to the fmt_macros crate (hence the name of the crate), but for now the fmt_macros crate will only contain the format string parser. The entire fmt_macros crate is marked #[experimental] because it is not meant for general consumption, only the format!() interface is officially supported, not the internals. This is a breaking change for anyone using the internals of std::fmt::parse. Some of the flags have moved to std::fmt::rt, while the actual parsing support has all moved to the fmt_macros library. [breaking-change]
2014-05-08libsyntax: Remove uses of `~str` from libsyntax, and fix falloutPatrick Walton-555/+670
2014-05-08auto merge of #13835 : alexcrichton/rust/localdata, r=brsonbors-27/+19
This commit brings the local_data api up to modern rust standards with a few key improvements: * All functionality is now exposed as a method on the keys themselves. Instead of importing std::local_data, you now use "key.set()" and "key.get()". * All closures have been removed in favor of RAII functionality. This means that get() and get_mut() no long require closures, but rather return Option<SmartPointer> where the smart pointer takes care of relinquishing the borrow and also implements the necessary Deref traits * The modify() function was removed to cut the local_data interface down to its bare essentials (similarly to how RefCell removed set/get). [breaking-change]
2014-05-07std: Modernize the local_data apiAlex Crichton-27/+19
This commit brings the local_data api up to modern rust standards with a few key improvements: * The `pop` and `set` methods have been combined into one method, `replace` * The `get_mut` method has been removed. All interior mutability should be done through `RefCell`. * All functionality is now exposed as a method on the keys themselves. Instead of importing std::local_data, you now use "key.replace()" and "key.get()". * All closures have been removed in favor of RAII functionality. This means that get() and get_mut() no long require closures, but rather return Option<SmartPointer> where the smart pointer takes care of relinquishing the borrow and also implements the necessary Deref traits * The modify() function was removed to cut the local_data interface down to its bare essentials (similarly to how RefCell removed set/get). [breaking-change]
2014-05-07auto merge of #14005 : alexcrichton/rust/extern-unsafe, r=pcwaltonbors-24/+25
Previously, the parser would not allow you to simultaneously implement a function with a different abi as well as being unsafe at the same time. This extends the parser to allow functions of the form: unsafe extern fn foo() { // ... } The closure type grammar was also changed to reflect this reversal, types previously written as "extern unsafe fn()" must now be written as "unsafe extern fn()". The parser currently has a hack which allows the old style, but this will go away once a snapshot has landed. Closes #10025 [breaking-change]
2014-05-07core: Inherit possible string functionalityAlex Crichton-5/+0
This moves as much allocation as possible from teh std::str module into core::str. This includes essentially all non-allocating functionality, mostly iterators and slicing and such. This primarily splits the Str trait into only having the as_slice() method, adding a new StrAllocating trait to std::str which contains the relevant new allocation methods. This is a breaking change if any of the methods of "trait Str" were overriden. The old functionality can be restored by implementing both the Str and StrAllocating traits. [breaking-change]
2014-05-07auto merge of #13958 : pcwalton/rust/detilde, r=pcwaltonbors-83/+124
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. r? @brson or @alexcrichton or whoever
2014-05-07auto merge of #13914 : alexcrichton/rust/pile-o-rustdoc-fixes, r=brsonbors-6/+2
Lots of assorted things here and there, all the details are in the commits. Closes #11712
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-83/+124
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-06rustc: Enable writing "unsafe extern fn() {}"Alex Crichton-24/+25
Previously, the parser would not allow you to simultaneously implement a function with a different abi as well as being unsafe at the same time. This extends the parser to allow functions of the form: unsafe extern fn foo() { // ... } The closure type grammar was also changed to reflect this reversal, types previously written as "extern unsafe fn()" must now be written as "unsafe extern fn()". The parser currently has a hack which allows the old style, but this will go away once a snapshot has landed. Closes #10025 [breaking-change]
2014-05-05auto merge of #13936 : Armavica/rust/lint_check-range, r=kballardbors-1/+1
Some cases were not correctly handled by this lint, for instance `let a = 42u8; a < 0` and `let a = 42u8; a > 255`. It led to the discovery of two useless comparisons, which I removed.
2014-05-04Remove two useless comparisonsVirgile Andreani-1/+1
according to the updated type_limits lint.
2014-05-04auto merge of #13920 : Ryman/rust/inner_attr_doc, r=alexcrichtonbors-1/+2
Also updated the comment for `parse_inner_attrs_and_next` and removed extra whitespace on line endings.
2014-05-04auto merge of #13908 : pcwalton/rust/box-pattern, r=alexcrichtonbors-0/+13
r? @alexcrichton
2014-05-04auto merge of #13898 : nikomatsakis/rust/type-bounds-b, r=acrichtobors-9/+13
This is needed to bootstrap fix for #5723.
2014-05-03Remove comment about semicolons for inner attributes from docs and adjust ↵Kevin Butler-1/+2
comments.
2014-05-03auto merge of #13773 : brson/rust/boxxy, r=alexcrichtonbors-42/+43
`box` is the way you allocate in future-rust.
2014-05-03Temporary patch to accept arbitrary lifetimes (behind feature gate) in bound ↵Niko Matsakis-9/+13
lists. This is needed to bootstrap fix for #5723.
2014-05-03auto merge of #13868 : FlaPer87/rust/opt-in-phase1, r=alexcrichtonbors-0/+51
This is a first patch towards an opt-in built-in trait world. This patch removes the restriction on built-in traits and allows such traits to be derived. [RFC#3] cc #13231 @nikomatsakis r?
2014-05-03syntax: Fix duplicate attributes on module filesAlex Crichton-6/+2
The outer attributes were manually appended when a module file was parsed, but the attributes were also added higher up the stack of parsing (when the module finished parsing). This removes the append in parsing the module file. Closes #13826
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-42/+43
2014-05-02libsyntax: Add `box PAT` to the pattern grammar. RFC #14.Patrick Walton-0/+13
2014-05-02auto merge of #13879 : huonw/rust/more-re, r=alexcrichtonbors-17/+35
Commits for details. This shouldn't change the generated code at all (except for switching to `LitBinary` from an explicit ExprVec of individual ExprLit bytes for `prefix_bytes`).
2014-05-02syntax: implement ToSource for more things in the quasiquoter.Huon Wilson-0/+23
The last few primitive types were missing.
2014-05-02syntax: store char literals/tokens as `char`s rather than u32s.Huon Wilson-17/+12
Clearly storing them as `char` is semantically nicer, but this also fixes a bug whereby `quote_expr!(cx, 'a')` wasn't working, because the code created by quotation was not matching the actual AST definitions.