about summary refs log tree commit diff
path: root/src/libsyntax/print
AgeCommit message (Collapse)AuthorLines
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+14
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-06libsyntax: remove unnecessary `to_string()` callsJorge Aparicio-3/+3
2014-12-06libsyntax: remove unnecessary `as_slice()` callsJorge Aparicio-1/+1
2014-12-01auto merge of #19405 : jfager/rust/de-match-pyramid, r=bstriebors-27/+16
No semantic changes, no enabling `if let` where it wasn't already enabled.
2014-11-30syntax: Make `asm!` clobbers a proper vector.Kang Seonghoon-1/+5
Otherwise `--pretty expanded` diverges.
2014-11-29Replace some verbose match statements with their `if let` equivalent.jfager-27/+16
No semantic changes, no enabling `if let` where it wasn't already enabled.
2014-11-26rollup merge of #19326: huonw/safer-syntaxAlex Crichton-1/+1
This makes it correct (e.g. avoiding null pointers) and safe.
2014-11-26Rote changes due to the fact that ast paths no longer carry this extraneous ↵Niko Matsakis-20/+6
bounds.
2014-11-26Fixup various places that were doing `&T+'a` and do `&(T+'a)`Niko Matsakis-1/+1
2014-11-26Implement the new parsing rules for types in the parser, modifying the AST ↵Niko Matsakis-8/+16
appropriately.
2014-11-26Make syntax::owned_slice a Box<[T]> wrapper.Huon Wilson-1/+1
This makes it correct (e.g. avoiding null pointers) and safe.
2014-11-23rollup merge of #19215: aochagavia/prettyJakub Bukaj-21/+16
Closes https://github.com/rust-lang/rust/issues/19077 I would appreciate any guidance on how to write a test for this. I saw some examples in `test/pretty`, but there are different ways to test... With or without `.pp` files, with a `pp-exact` comment, etc.
2014-11-23Remove type parameters from ExprField and ExprTupFieldAdolfo Ochagavía-16/+2
2014-11-22Fix pretty printing unsafe match armsAdolfo Ochagavía-21/+16
2014-11-21core: Convert Char::escape_default, escape_unicode to iteratorsBrian Anderson-1/+3
[breaking-change]
2014-11-20auto merge of #19113 : nikomatsakis/rust/unboxed-boxed-closure-unification, ↵bors-43/+4
r=acrichto Use the expected type to infer the argument/return types of unboxed closures. Also, in `||` expressions, use the expected type to decide if the result should be a boxed or unboxed closure (and if an unboxed closure, what kind). This supercedes PR #19089, which was already reviewed by @pcwalton.
2014-11-19rollup merge of #19103: huonw/literal-suffixesJakub Bukaj-12/+22
Futureproof Rust for fancier suffixed literals. The Rust compiler tokenises a literal followed immediately (no whitespace) by an identifier as a single token: (for example) the text sequences `"foo"bar`, `1baz` and `1u1024` are now a single token rather than the pairs `"foo"` `bar`, `1` `baz` and `1u` `1024` respectively. The compiler rejects all such suffixes in the parser, except for the 12 numeric suffixes we have now. I'm fairly sure this will affect very few programs, since it's not currently legal to have `<literal><identifier>` in a Rust program, except in a macro invocation. Any macro invocation relying on this behaviour can simply separate the two tokens with whitespace: `foo!("bar"baz)` becomes `foo!("bar" baz)`. This implements [RFC 463](https://github.com/rust-lang/rfcs/blob/master/text/0463-future-proof-literal-suffixes.md), and so closes https://github.com/rust-lang/rust/issues/19088.
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