about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-08-31auto merge of #16809 : nick29581/rust/dst-bug-3, r=alexcrichtonbors-13/+6
This corrects a rebasing error. Also adds a test so it won't happen again. r?
2014-08-31auto merge of #16788 : Manishearth/rust/raw-ptr-syntax-ty, r=huonwbors-1/+16
@huonw , r? :) #16781
2014-08-30rollup merge of #16839 : treeman/issue-15358Alex Crichton-1/+1
2014-08-30auto merge of #16859 : alexcrichton/rust/snapshots, r=huonwbors-26/+0
2014-08-30auto merge of #16419 : huonw/rust/pretty-expanded-hygiene, r=pnkfelixbors-3/+7
Different Identifiers and Names can have identical textual representations, but different internal representations, due to the macro hygiene machinery (syntax contexts and gensyms). This provides a way to see these internals by compiling with `--pretty expanded,hygiene`. This is useful for debugging & hacking on macros (e.g. diagnosing https://github.com/rust-lang/rust/issues/15750/https://github.com/rust-lang/rust/issues/15962 likely would've been faster with this functionality). E.g. ```rust #![feature(macro_rules)] // minimal junk #![no_std] macro_rules! foo { ($x: ident) => { y + $x } } fn bar() { foo!(x) } ``` ```rust #![feature(macro_rules)] // minimal junk #![no_std] fn bar /* 61#0 */() { y /* 60#2 */ + x /* 58#3 */ } ```
2014-08-30rustc: implement a pretty mode to print ident/name's ctxt & gensyms.Huon Wilson-3/+7
`--pretty expanded,hygiene` is helpful with debugging macro issues, since two identifiers/names can be textually the same, but different internally (resulting in weird "undefined variable" errors).
2014-08-29Fix formatting, update copyright datesPythoner6-5/+5
2014-08-29Add support for labeled while loops.Pythoner6-12/+28
2014-08-29Register new snapshotsAlex Crichton-26/+0
2014-08-30Unify non-snake-case lints and non-uppercase statics lintsP1start-2/+2
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint. Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint. New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint. [breaking-change]
2014-08-29Tweak error message for use of a keyword in ident position.Jonas Hietala-1/+1
Closes #15358
2014-08-28Forbid ~str and ~[]Nick Cameron-13/+6
This corrects a rebasing error. Also adds a test so it won't happen again.
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-463/+426
2014-08-27Allow *-pointers in PtrTy (fixes #16781)Manish Goregaokar-1/+16
2014-08-27auto merge of #16689 : wickerwaka/rust/crate-as, r=pcwaltonbors-5/+15
For review. Not sure about the link_attrs stuff. Will work on converting all the tests. extern crate "foobar" as foo; extern crate foobar as foo; Implements remaining part of RFC #47. Addresses issue #16461. Removed link_attrs from rust.md, they don't appear to be supported by the parser.
2014-08-26Rebasing changesNick Cameron-14/+17
2014-08-26DST coercions and DST structsNick Cameron-97/+35
[breaking-change] 1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code. 2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible. 3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-25auto merge of #16699 : treeman/rust/issue-8492, r=alexcrichtonbors-13/+13
Closes #8492. I did not find this suggestion in the [guidelines][] but it's mentioned in the [old style guide][]. [guidelines]: https://github.com/rust-lang/rust-guidelines [old style guide]: https://github.com/rust-lang/rust/wiki/Note-style-guide/73c864a10a8e231e2a6630e5a3461f1d3022a20a
2014-08-24auto merge of #16646 : P1start/rust/trailing-commas, r=alexcrichtonbors-18/+25
This lets the parser understand trailing commas in method calls, method definitions, enum variants, and type parameters. Closes #14240. Closes #15887.
2014-08-24Adjust the error messages to match the pattern "expected foo, found bar"Jonas Hietala-13/+13
Closes #8492
2014-08-23extern crate foobar as foo;wickerwaka-5/+15
Implements remaining part of RFC #47. Addresses issue #16461. Removed link_attrs from rust.md, they don't appear to be supported by the parser. Changed all the tests to use the new extern crate syntax Change pretty printer to use 'as' syntax
2014-08-23Add support for trailing commas in more placesP1start-18/+25
This lets the parser understand trailing commas in method calls, method definitions, enum variants, and type parameters. Closes #14240. Closes #15887.
2014-08-21syntax: Fix complexity of string parsing. Closes #16624.Brian Anderson-5/+16
2014-08-20librustc: handle repr on structs, require it for ffi, unify with packedCorey Richardson-25/+20
As of RFC 18, struct layout is undefined. Opting into a C-compatible struct layout is now down with #[repr(C)]. For consistency, specifying a packed layout is now also down with #[repr(packed)]. Both can be specified. To fix errors caused by this, just add #[repr(C)] to the structs, and change #[packed] to #[repr(packed)] Closes #14309 [breaking-change]
2014-08-19Fix double evaluation of read+write operandsPiotr Czarnecki-23/+19
Stop read+write expressions from expanding into two occurences in the AST. Add a bool to indicate whether an operand in output position if read+write or not. Fixes #14936
2014-08-18libsyntax: Remove the `use foo = bar` syntax from the language in favorPatrick Walton-4/+10
of `use bar as foo`. Change all uses of `use foo = bar` to `use bar as foo`. Implements RFC #47. Closes #16461. [breaking-change]
2014-08-18Forbid extern statics from appearing in patternsJakub Wieczorek-15/+0
Fixes #16149.
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-47/+51
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-15auto merge of #16424 : pcwalton/rust/where-clauses, r=nikomatsakisbors-103/+299
These `where` clauses are accepted everywhere generics are currently accepted and desugar during type collection to the type parameter bounds we have today. A new keyword, `where`, has been added. Therefore, this is a breaking change. Change uses of `where` to other identifiers. [breaking-change] r? @nikomatsakis (or whoever)
2014-08-15auto merge of #16435 : vadimcn/rust/windows, r=pcwaltonbors-8/+8
Using "win32" to mean "Windows" is confusing, especially now, that Rust supports win64 builds. Let's call spade a spade.
2014-08-14librustc: Implement simple `where` clauses.Patrick Walton-103/+299
These `where` clauses are accepted everywhere generics are currently accepted and desugar during type collection to the type parameter bounds we have today. A new keyword, `where`, has been added. Therefore, this is a breaking change. Change uses of `where` to other identifiers. [breaking-change]
2014-08-14auto merge of #16468 : pcwalton/rust/as-renaming-import, r=alexcrichtonbors-8/+16
The old syntax will be removed after a snapshot. RFC #47. Issue #16461. r? @brson
2014-08-14libsyntax: Accept `use foo as bar;` in lieu of `use bar as foo;`Patrick Walton-8/+16
The old syntax will be removed after a snapshot. RFC #47. Issue #16461.
2014-08-14librustc: Stop assuming that implementations and traits only containPatrick Walton-148/+256
methods. This paves the way to associated items by introducing an extra level of abstraction ("impl-or-trait item") between traits/implementations and methods. This new abstraction is encoded in the metadata and used throughout the compiler where appropriate. There are no functional changes; this is purely a refactoring.
2014-08-14auto merge of #16122 : pcwalton/rust/lifetimes-in-unboxed-closures, r=pnkfelixbors-99/+152
This patch primarily does two things: (1) it prevents lifetimes from leaking out of unboxed closures; (2) it allows unboxed closure type notation, call notation, and construction notation to construct closures matching any of the three traits. This breaks code that looked like: let mut f; { let x = &5i; f = |&mut:| *x + 10; } Change this code to avoid having a reference escape. For example: { let x = &5i; let mut f; // <-- move here to avoid dangling reference f = |&mut:| *x + 10; } I believe this is enough to consider unboxed closures essentially implemented. Further issues (for example, higher-rank lifetimes) should be filed as followups. Closes #14449. [breaking-change] r? @pnkfelix
2014-08-14librustc: Tie up loose ends in unboxed closures.Patrick Walton-99/+152
This patch primarily does two things: (1) it prevents lifetimes from leaking out of unboxed closures; (2) it allows unboxed closure type notation, call notation, and construction notation to construct closures matching any of the three traits. This breaks code that looked like: let mut f; { let x = &5i; f = |&mut:| *x + 10; } Change this code to avoid having a reference escape. For example: { let x = &5i; let mut f; // <-- move here to avoid dangling reference f = |&mut:| *x + 10; } I believe this is enough to consider unboxed closures essentially implemented. Further issues (for example, higher-rank lifetimes) should be filed as followups. Closes #14449. [breaking-change]
2014-08-14auto merge of #16332 : brson/rust/slicestab, r=aturonbors-3/+3
This implements some of the recommendations from https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md. Explanation in commits.
2014-08-14auto merge of #15929 : pcwalton/rust/by-ref-closures, r=alexcrichtonbors-19/+50
by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12831. r? @alexcrichton
2014-08-13librustc: Parse, but do not fully turn on, the `ref` keyword forPatrick Walton-19/+50
by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12381.
2014-08-13core: Change the argument order on splitn and rsplitn for strs.Brian Anderson-3/+3
This makes it consistent with the same functions for slices, and allows the search closure to be specified last. [breaking-change]
2014-08-13quote_expr macro: embed Ident using special encoding that preserves hygiene.Felix S. Klock II-31/+345
This adds support to `quote_expr!` and friends for round-trip hygienic preservation of Ident. Here are the pieces of the puzzle: * adding a method for encoding Ident for re-reading into token tree. * Support for reading such encoded Idents in the lexer. Note that one must peek ahead for MOD_SEP after scan_embedded_hygienic_ident. * To ensure that encoded Idents are only read when we are in the midst of expanding a `quote_expr` or similar, added a `read_embedded_ident` flag on `StringReader`. * pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
2014-08-12libsyntax: Don't strip types and lifetimes from single-segment paths inPatrick Walton-1/+10
patterns. This breaks code like: fn main() { match Some("foo") { None::<int> => {} Some(_) => {} } } Change this code to not contain a type error. For example: fn main() { match Some("foo") { None::<&str> => {} Some(_) => {} } } Closes #16353. [breaking-change]
2014-08-12Replace #[cfg(target_os = "win32")] with #[cfg(target_os = "windows")]Vadim Chugunov-1/+1
2014-08-12Replace all references to "Win32" with "Windows".Vadim Chugunov-8/+8
For historical reasons, "Win32" has been used in Rust codebase to mean "Windows OS in general". This is confusing, especially now, that Rust supports Win64 builds. [breaking-change]
2014-08-09Helper method for `pprust::State` for printing instances of `ast_map::Node`.Felix S. Klock II-0/+29
2014-08-09refactored pprust::State constructor methods out from `pprust::print_crate`.Felix S. Klock II-24/+51
(Groundwork for pretty-printing only selected items in an input crate.)
2014-08-09ast_map: Added iterator over all node id's that match a path suffix.Felix S. Klock II-1/+132
This is useful e.g. for tools need a node-id, such as the flowgraph pretty printer, since it can avoids the need to first pretty-print the whole expanded,identified input in order to find out what the node-id actually is. It currently only supports path suffixes thst are made up of module names (e.g. you cannot use the type instantiation form `a::<int>::b` or `option::Option::unwrap_or` as a path suffix for this tool, though the tool will produce paths that have non-modulues in the portion of the path that is not included in the suffix). (addressed review feedback too)
2014-08-08auto merge of #16285 : alexcrichton/rust/rename-share, r=huonwbors-3/+3
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use` statement, but the `NoShare` struct is no longer part of `std::kinds::marker` due to #12660 (the build cannot bootstrap otherwise). All code referencing the `Share` trait should now reference the `Sync` trait, and all code referencing the `NoShare` type should now reference the `NoSync` type. The functionality and meaning of this trait have not changed, only the naming. Closes #16281 [breaking-change]
2014-08-07Rename `Share` to `Sync`Alex Crichton-3/+3
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use` statement, but the `NoShare` struct is no longer part of `std::kinds::marker` due to #12660 (the build cannot bootstrap otherwise). All code referencing the `Share` trait should now reference the `Sync` trait, and all code referencing the `NoShare` type should now reference the `NoSync` type. The functionality and meaning of this trait have not changed, only the naming. Closes #16281 [breaking-change]
2014-08-07Temporary bootstrapping hack: introduce syntax for r egion bounds like `'b:'a`,Niko Matsakis-48/+149
meaning `'b outlives 'a`. Syntax currently does nothing but is needed for full fix to #5763. To use this syntax, the issue_5763_bootstrap feature guard is required.