about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2015-03-27Rollup merge of #23712 - nikomatsakis:reflect-trait, r=FlaPer87Manish Goregaokar-1/+6
This PR introduces a `Reflect` marker trait which is a supertrait of `Any`. The idea is that `Reflect` is defined for all concrete types, but is not defined for type parameters unless there is a `T:Reflect` bound. This is intended to preserve the parametricity property. This allows the `Any` interface to be stabilized without committing us to unbounded reflection that is not easily detectable by the caller. The implementation of `Reflect` relies on an experimental variant of OIBIT. This variant behaves differently for objects, since it requires that all types exposed as part of the object's *interface* are `Reflect`, but isn't concerned about other types that may be closed over. In other words, you don't have to write `Foo+Reflect` in order for `Foo: Reflect` to hold (where `Foo` is a trait). Given that `Any` is slated to stabilization and hence that we are committed to some form of reflection, the goal of this PR is to leave our options open with respect to parametricity. I see the options for full stabilization as follows (I think an RFC would be an appropriate way to confirm whichever of these three routes we take): 1. We make `Reflect` a lang-item. 2. We stabilize some version of the OIBIT variation I implemented as a general mechanism that may be appropriate for other use cases. 3. We give up on preserving parametricity here and just have `impl<T> Reflect for T` instead. In that case, `Reflect` is a harmless but not especially useful trait going forward. cc @aturon cc @alexcrichton cc @glaebhoerl (this is more-or-less your proposal, as I understood it) cc @reem (this is more-or-less what we discussed on IRC at some point) cc @FlaPer87 (vaguely pertains to OIBIT)
2015-03-27Rollup merge of #23625 - fhahn:issue-23620-ice-unicode-bytestring, ↵Manish Goregaokar-11/+29
r=alexcrichton closes #23620 This PR patches the issue mentioned in #23620, but there is also an ICE for invalid escape sequences in byte literals. This is due to the fact that the `scan_byte` function returns ` token::intern(\"??\") ` for invalid bytes, resulting in an ICE later on. Is there a reason for this behavior? Shouldn't `scan_byte` fail when it encounters an invalid byte? And I noticed a small inconsistency in the documentation. According to the formal byte literal definition in http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals , a byte string literal contains `string_body *`, but according to the text (and the behavior of the lexer) it should not accept unicode escape sequences. Hence it should be replaced by `byte_body *`. If this is valid, I can add this fix to this PR.
2015-03-27Rollup merge of #23738 - alexcrichton:snapshots, r=cmrManish Goregaokar-1/+1
2015-03-27Prevent ICEs when parsing invalid escapes, closes #23620Florian Hahn-11/+29
2015-03-27Auto merge of #22930 - Gankro:entry_3, r=aturonbors-7/+4
RFC pending, but this is the patch that does it. Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples. Closes #23508
2015-03-27default => or_insert per RFCAlexis Beingessner-3/+2
2015-03-26update everything to use Entry defaultsAlexis-6/+4
2015-03-26Implement `Reflect` trait with a variant on the standard OIBITNiko Matsakis-1/+6
semantics that tests the *interface* of trait objects, rather than what they close over.
2015-03-26Auto merge of #23359 - erickt:quote, r=pnkfelixbors-29/+41
This PR allows the quote macros to unquote trait items, impl items, where clauses, and paths.
2015-03-26Register new snapshotsAlex Crichton-1/+1
2015-03-26Auto merge of #21237 - erickt:derive-assoc-types, r=ericktbors-6/+118
This PR adds support for associated types to the `#[derive(...)]` syntax extension. In order to do this, it switches over to using where predicates to apply the type constraints. So now this: ```rust type Trait { type Type; } #[derive(Clone)] struct Foo<A> where A: Trait { a: A, b: <A as Trait>::Type, } ``` Gets expended into this impl: ```rust impl<A: Clone> Clone for Foo<A> where A: Trait, <A as Trait>::Type: Clone, { fn clone(&self) -> Foo<T> { Foo { a: self.a.clone(), b: self.b.clone(), } } } ```
2015-03-24rollup merge of #23546: alexcrichton/hyphensAlex Crichton-28/+31
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
2015-03-24rustc: Add support for `extern crate foo as bar`Alex Crichton-28/+31
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
2015-03-24syntax: Update #[derive(...)] to work with phantom and associated typesErick Tryzelaar-6/+118
Closes #7671, #19839
2015-03-24syntax: Allow quotes to insert pathErick Tryzelaar-0/+2
2015-03-24syntax: Allow where strings to be parsed independent from genericsErick Tryzelaar-16/+25
This allows quasiquoting to insert where clauses.
2015-03-24syntax: add {trait_item,impl_item,where_clause}_to_stringErick Tryzelaar-13/+14
2015-03-25Change lint names to pluralsNick Cameron-1/+1
2015-03-25Add trivial cast lints.Nick Cameron-11/+12
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-23rollup merge of #23506: alexcrichton/remove-some-deprecated-thingsAlex Crichton-292/+29
Conflicts: src/test/run-pass/deprecated-no-split-stack.rs
2015-03-23rollup merge of #23601: nikomatsakis/by-value-indexAlex Crichton-3/+3
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`. r? @japaric cc @aturon @Gankro
2015-03-23rollup merge of #23538: aturon/conversionAlex Crichton-5/+6
Conflicts: src/librustc_back/rpath.rs
2015-03-23rollup merge of #23211: FlaPer87/oibit-send-and-friendsAlex Crichton-0/+7
Fixes #23225 r? @nikomatsakis
2015-03-23Add generic conversion traitsAaron Turon-5/+6
This commit: * Introduces `std::convert`, providing an implementation of RFC 529. * Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all in favor of the corresponding generic conversion traits. Consequently, various IO APIs now take `AsRef<Path>` rather than `AsPath`, and so on. Since the types provided by `std` implement both traits, this should cause relatively little breakage. * Deprecates many `from_foo` constructors in favor of `from`. * Changes `PathBuf::new` to take no argument (creating an empty buffer, as per convention). The previous behavior is now available as `PathBuf::from`. * De-stabilizes `IntoCow`. It's not clear whether we need this separate trait. Closes #22751 Closes #14433 [breaking-change]
2015-03-23Fallout in stdlib, rustdoc, rustc, etc. For most maps, converted uses ofNiko Matsakis-3/+3
`[]` on maps to `get` in rustc, since stage0 and stage1+ disagree about how to use `[]`.
2015-03-20Auto merge of #23512 - oli-obk:result_ok_unwrap, r=alexcrichtonbors-5/+5
because then the call to `unwrap()` will not print the error object.
2015-03-20Feature gate defaulted traitsFlavio Percoco-0/+7
2015-03-20don't use Result::ok just to be able to use unwrap/unwrap_orOliver Schneider-5/+5
2015-03-19Added missing impl_to_source! and impl_to_tokens! for TraitItem.Vladimir Pouzanov-0/+6
2015-03-19Added missing impl_to_source! and impl_to_tokens! for ImplItem.Vladimir Pouzanov-0/+6
This fixes several use cases that were broken after #23265 landed.
2015-03-19Auto merge of #23507 - jbcrail:fix-comment-spelling, r=alexcrichtonbors-1/+1
I corrected misspelled comments in several crates.
2015-03-19Fix spelling errors in comments.Joseph Crail-1/+1
I corrected misspelled comments in several crates.
2015-03-19Rollup merge of #23428 - Manishearth:ast-doc, r=steveklabnikManish Goregaokar-15/+42
I often have to run `ast-json` or look into the pretty-printer source to figure out what the fields of an AST enum mean. I've tried to document most of what I know (and some semi-obvious stuff). r? @steveklabnik f? @eddyb
2015-03-19Rollup merge of #23494 - mdinger:patch-1, r=steveklabnikManish Goregaokar-1/+1
Typo
2015-03-19Rollup merge of #23475 - nikomatsakis:closure-ret-syntax, r=acrichtoManish Goregaokar-17/+31
Require braces when a closure has an explicit return type. This is a [breaking-change]: instead of a closure like `|| -> i32 22`, prefer `|| -> i32 { 22 }`. Fixes #23420.
2015-03-19Space and punctuation fixesManish Goregaokar-14/+41
2015-03-19Address huon's commentsManish Goregaokar-1/+1
2015-03-19Update ast.rsmdinger-1/+1
Typo
2015-03-18rustc: Remove some long deprecated features:Alex Crichton-292/+29
* no_split_stack was renamed to no_stack_check * deriving was renamed to derive * `use foo::mod` was renamed to `use foo::self`; * legacy lifetime definitions in closures have been replaced with `for` syntax * `fn foo() -> &A + B` has been deprecated for some time (needs parens) * Obsolete `for Sized?` syntax * Obsolete `Sized? Foo` syntax * Obsolete `|T| -> U` syntax
2015-03-18Require braces when a closure has an explicit return type. This is aNiko Matsakis-17/+31
[breaking-change]: instead of a closure like `|| -> i32 22`, prefer `|| -> i32 { 22 }`. Fixes #23420.
2015-03-18Register new snapshotsAlex Crichton-8/+0
2015-03-18Rollup merge of #23428 - Manishearth:ast-doc, r=huonManish Goregaokar-15/+157
I often have to run `ast-json` or look into the pretty-printer source to figure out what the fields of an AST enum mean. I've tried to document most of what I know (and some semi-obvious stuff). r? @steveklabnik f? @eddyb
2015-03-18Address huon's commentsManish Goregaokar-17/+21
2015-03-18Clarify ExprManish Goregaokar-5/+10
2015-03-18ast: Document Item and ForeignItemManish Goregaokar-9/+27
2015-03-18ast: Document LitManish Goregaokar-1/+15
2015-03-18ast: Document Pat and BlockManish Goregaokar-1/+19
2015-03-18ast: Document paths and `where` clausesManish Goregaokar-1/+15
2015-03-18ast: Document Expr_, UnOp, and BinOpManish Goregaokar-1/+70
2015-03-17std: Tweak some unstable features of `str`Alex Crichton-11/+13
This commit clarifies some of the unstable features in the `str` module by moving them out of the blanket `core` and `collections` features. The following methods were moved to the `str_char` feature which generally encompasses decoding specific characters from a `str` and dealing with the result. It is unclear if any of these methods need to be stabilized for 1.0 and the most conservative route for now is to continue providing them but to leave them as unstable under a more specific name. * `is_char_boundary` * `char_at` * `char_range_at` * `char_at_reverse` * `char_range_at_reverse` * `slice_shift_char` The following methods were moved into the generic `unicode` feature as they are specifically enabled by the `unicode` crate itself. * `nfd_chars` * `nfkd_chars` * `nfc_chars` * `graphemes` * `grapheme_indices` * `width`