about summary refs log tree commit diff
path: root/src/libsyntax/print
AgeCommit message (Collapse)AuthorLines
2014-11-19Merge the ExprFnBlock and ExprUnboxedClosure into one ExprClosure with an ↵Niko Matsakis-43/+4
optional unboxed closure kind.
2014-11-20Parse and store suffixes on literals.Huon Wilson-12/+22
This adds an optional suffix at the end of a literal token: `"foo"bar`. An actual use of a suffix in a expression (or other literal that the compiler reads) is rejected in the parser. This doesn't switch the handling of numbers to this system, and doesn't outlaw illegal suffixes for them yet.
2014-11-19Refactor QPath to take an ast::TraitRefNiko Matsakis-2/+2
2014-11-19Switch to an independent enum for `Lit*` subtokens.Huon Wilson-12/+12
2014-11-18Convert TyPolyTraitRef to accept arbitary bounds, so that things likeNiko Matsakis-2/+2
`Box<for<'a> Foo<&'a T> + 'a>` can be accepted. Also cleanup the visitor/fold in general, exposing more callbacks.
2014-11-18implement Writer for Vec<u8>Daniel Micay-5/+5
The trait has an obvious, sensible implementation directly on vectors so the MemWriter wrapper is unnecessary. This will halt the trend towards providing all of the vector methods on MemWriter along with eliminating the noise caused by conversions between the two types. It also provides the useful default Writer methods on Vec<u8>. After the type is removed and code has been migrated, it would make sense to add a new implementation of MemWriter with seeking support. The simple use cases can be covered with vectors alone, and ones with the need for seeks can use a new MemWriter implementation.
2014-11-18rollup merge of #18911: canndrew/slice_shift_charJakub Bukaj-1/+1
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that: "bar".slice_shift_char() => (Some('b'), "ar") "ar".slice_shift_char() => (Some('a'), "r") "r".slice_shift_char() => (Some('r'), "") "".slice_shift_char() => (None, "") This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string. This PR changes `slice_shift_char` so that: "bar".slice_shift_char() => Some(('b', "ar")) "ar".slice_shift_char() => Some(('a', "r")) "r".slice_shift_char() => Some(('r', "")) "".slice_shift_char() => None
2014-11-17Switch to purely namespaced enumsSteven Fackler-0/+6
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
2014-11-17change return type of slice_shift_charAndrew Cann-1/+1
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that: "bar".slice_shift_char() => (Some('b'), "ar") "ar".slice_shift_char() => (Some('a'), "r") "r".slice_shift_char() => (Some('r'), "") "".slice_shift_char() => (None, "") This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string. This commit changes slice_shift_char so that: "bar".slice_shift_char() => Some(('b', "ar")) "ar".slice_shift_char() => Some(('a', "r")) "r".slice_shift_char() => Some(('r', "")) "".slice_shift_char() => None [breaking-change]
2014-11-16Complete the removal of ty_nil, ast::LitNil, ast::TyBot and ast::TyUniqJakub Bukaj-47/+55
[breaking-change] This will break any uses of macros that assumed () being a valid literal.
2014-11-07Purge the old `once_fns`, which are not coming backNiko Matsakis-9/+0
2014-11-07Update parser with `for` syntaxNiko Matsakis-13/+18
2014-11-07auto merge of #17830 : pczarn/rust/interp_tt, r=pnkfelixbors-16/+13
Closes #14197 Removes the `matchers` nonterminal. If you're using `$foo:matchers` in a macro, write `$foo:tt` instead. [breaking-change]
2014-11-07Add `ast::SequenceRepetition`Piotr Czarnecki-4/+4
2014-11-06Remove the unboxed closure `|:|` notation from types and trait references ↵Niko Matsakis-50/+6
completely.
2014-11-06Support parenthesized paths `Foo(A,B) -> C` that expand to `Foo<(A,B),C>`. ↵Niko Matsakis-11/+45
These paths also bind anonymous regions (or will, once HRTB is fully working). Fixes #18423.
2014-11-05Remove `Matcher`sPiotr Czarnecki-1/+0
2014-11-05Use `TokenTree`s in lhs of macrosPiotr Czarnecki-12/+10
2014-11-04libsyntax: Forbid escapes in the inclusive range `\x80`-`\xff` inPatrick Walton-3/+8
Unicode characters and strings. Use `\u0080`-`\u00ff` instead. ASCII/byte literals are unaffected. This PR introduces a new function, `escape_default`, into the ASCII module. This was necessary for the pretty printer to continue to function. RFC #326. Closes #18062. [breaking-change]
2014-11-03rollup merge of #18506 : nikomatsakis/assoc-type-boundsAlex Crichton-19/+25
2014-11-03Restructure AST so that the associated type definition carriesNiko Matsakis-19/+25
bounds like any other "type parameter".
2014-11-03Clean-up transmutes in libsyntaxAriel Ben-Yehuda-8/+5
2014-10-30rollup merge of #18445 : alexcrichton/index-mutAlex Crichton-15/+14
Conflicts: src/libcollections/vec.rs
2014-10-30rollup merge of #18430 : bjz/tokenAlex Crichton-10/+9
Conflicts: src/libsyntax/parse/parser.rs
2014-10-30rollup merge of #18398 : aturon/lint-conventions-2Alex Crichton-2/+2
Conflicts: src/libcollections/slice.rs src/libcore/failure.rs src/libsyntax/parse/token.rs src/test/debuginfo/basic-types-mut-globals.rs src/test/debuginfo/simple-struct.rs src/test/debuginfo/trait-pointers.rs
2014-10-30collections: Enable IndexMut for some collectionsAlex Crichton-15/+14
This commit enables implementations of IndexMut for a number of collections, including Vec, RingBuf, SmallIntMap, TrieMap, TreeMap, and HashMap. At the same time this deprecates the `get_mut` methods on vectors in favor of using the indexing notation. cc #18424
2014-10-30Use common variants for open and close delimitersBrendan Zabarauskas-10/+9
This common representation for delimeters should make pattern matching easier. Having a separate `token::DelimToken` enum also allows us to enforce the invariant that the opening and closing delimiters must be the same in `ast::TtDelimited`, removing the need to ensure matched delimiters when working with token trees.
2014-10-29Rename fail! to panic!Steve Klabnik-4/+4
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-28Update code with new lint namesAaron Turon-2/+2
2014-10-28Move token-to-string functions into print::pprustBrendan Zabarauskas-6/+101
2014-10-28Use PascalCase for token variantsBrendan Zabarauskas-1/+1
2014-10-27rollup merge of #18362 : kevinmehall/pprint-struct-pat-shorthandAlex Crichton-2/+4
2014-10-27rollup merge of #18256 : SimonSapin/view_item_to_stringAlex Crichton-0/+4
2014-10-27Preserve struct field pattern shorthand in the prettyprinter.Kevin Mehall-2/+4
Use the `is_shorthand` field introduced by #17813 (ead6c4b) to make the prettyprinter output the shorthand form. Fixes a few places that set `is_shorthand: true` when the pattern is not a PatIdent with the same name as the field.
2014-10-26Add a KleeneOp enum for clarityBrendan Zabarauskas-3/+6
2014-10-26Reduce the size of the TokenTreeBrendan Zabarauskas-1/+2
2014-10-26Use standard capitalisation for TokenTree variantsBrendan Zabarauskas-4/+4
2014-10-26Rename TokenTree variants for clarityBrendan Zabarauskas-3/+3
This should be clearer, and fits in better with the `TTNonterminal` variant. Renames: - `TTTok` -> `TTToken` - `TTDelim` -> `TTDelimited` - `TTSeq` -> `TTSequence`
2014-10-26Add Span and separate open/close delims to TTDelimBrendan Zabarauskas-1/+7
This came up when working [on the gl-rs generator extension](https://github.com/bjz/gl-rs/blob/990383de801bd2e233159d5be07c9b5622827620/src/gl_generator/lib.rs#L135-L146). The new definition of `TTDelim` adds an associated `Span` that covers the whole token tree and enforces the invariant that a delimited sequence of token trees must have an opening and closing delimiter. A `get_span` method has also been added to `TokenTree` type to make it easier to implement better error messages for syntax extensions.
2014-10-24Add a lint for not using field pattern shorthandsP1start-3/+3
Closes #17792.
2014-10-23Add syntax::print::pprint::view_item_to_stringSimon Sapin-0/+4
… similar to the existing `item_to_string`. There may be more missing like this.
2014-10-20auto merge of #18070 : alexcrichton/rust/spring-cleaning, r=aturonbors-47/+46
This is a large spring-cleaning commit now that the 0.12.0 release has passed removing an amount of deprecated functionality. This removes a number of deprecated crates (all still available as cargo packages in the rust-lang organization) as well as a slew of deprecated functions. All `#[crate_id]` support has also been removed. I tried to avoid anything that was recently deprecated, but I may have missed something! The major pain points of this commit is the fact that rustc/syntax have `#[allow(deprecated)]`, but I've removed that annotation so moving forward they should be cleaned up as we go.
2014-10-19Remove a large amount of deprecated functionalityAlex Crichton-47/+46
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
2014-10-19fix printing signed literal in print_literalAleksandr Koshlo-1/+10
2014-10-13auto merge of #17733 : jgallagher/rust/while-let, r=alexcrichtonbors-0/+13
This is *heavily* based on `if let` (#17634) by @jakub- and @kballard This should close #17687
2014-10-11Remove `virtual` structs from the languageJakub Wieczorek-10/+0
2014-10-10Teach libsyntax about `while let`John Gallagher-0/+13
2014-10-09syntax: Convert statics to constantsAlex Crichton-2/+2
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-0/+14
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-03Set the `non_uppercase_statics` lint to warn by defaultP1start-0/+2