Commit Graph

36471 Commits

Author SHA1 Message Date
Jorge Aparicio
0cb34a3609 EncodeInlinedItem: convert to "unboxed" closures 2015-01-05 17:22:13 -05:00
Jorge Aparicio
bd9eef7ac6 DecodeInlinedItem: convert to "unboxed" closures 2015-01-05 17:22:13 -05:00
Jorge Aparicio
98fda878d8 conv_did: convert to "unboxed" closure 2015-01-05 17:22:12 -05:00
Jorge Aparicio
07a8e7cfb5 syntax: remove remaining boxed closures 2015-01-05 17:22:12 -05:00
Jorge Aparicio
37f62ae1c0 std: remove remaining boxed closures 2015-01-05 17:22:12 -05:00
Jorge Aparicio
a291a80fbe register snapshot 2015-01-05 17:22:11 -05:00
Niko Matsakis
6e68fd09ed Implement new orphan rule that requires that impls of remote traits meet the following two criteria:
- the self type includes some local type; and,
- type parameters in the self type must be constrained by a local type.

A type parameter is called *constrained* if it appears in some type-parameter of a local type.

Here are some examples that are accepted. In all of these examples, I
assume that `Foo` is a trait defined in another crate. If `Foo` were
defined in the local crate, then all the examples would be legal.

- `impl Foo for LocalType`
- `impl<T> Foo<T> for LocalType` -- T does not appear in Self, so it is OK
- `impl<T> Foo<T> for LocalType<T>` -- T here is constrained by LocalType
- `impl<T> Foo<T> for (LocalType<T>, T)` -- T here is constrained by LocalType

Here are some illegal examples (again, these examples assume that
`Foo` is not local to the current crate):

- `impl Foo for int` -- the Self type is not local
- `impl<T> Foo for T` -- T appears in Self unconstrained by a local type
- `impl<T> Foo for (LocalType, T)` -- T appears in Self unconstrained by a local type

This is a [breaking-change]. For the time being, you can opt out of
the new rules by placing `#[old_orphan_check]` on the trait (and
enabling the feature gate where the trait is defined). Longer term,
you should restructure your traits to avoid the problem. Usually this
means changing the order of parameters so that the "central" type
parameter is in the `Self` position.

As an example of that refactoring, consider the `BorrowFrom` trait:

```rust
pub trait BorrowFrom<Sized? Owned> for Sized? {
    fn borrow_from(owned: &Owned) -> &Self;
}
```

As defined, this trait is commonly implemented for custom pointer
types, such as `Arc`. Those impls follow the pattern:

```rust
impl<T> BorrowFrom<Arc<T>> for T {...}
```

Unfortunately, this impl is illegal because the self type `T` is not
local to the current crate. Therefore, we are going to change the order of the parameters,
so that `BorrowFrom` becomes `Borrow`:

```rust
pub trait Borrow<Sized? Borrowed> for Sized? {
    fn borrow_from(owned: &Self) -> &Borrowed;
}
```

Now the `Arc` impl is written:

```rust
impl<T> Borrow<T> for Arc<T> { ... }
```

This impl is legal because the self type (`Arc<T>`) is local.
2015-01-05 17:17:26 -05:00
Aaron Turon
cb765ce7e1 Stabilize collection modules
The earlier collections stabilization did not cover the modules
themselves. This commit marks as stable those modules whose types have
been stabilized.
2015-01-05 14:08:22 -08:00
Aaron Turon
121f6c6673 Final alpha stabilization of std::slice
Marks as `#[stable]`:

* Various iterator structs for stable methods, e.g. `Chunks` and
  `Windows`.
* The `SliceExt` trait itself.
2015-01-05 14:08:21 -08:00
Aaron Turon
e921afddd8 Stabilize core::ops
This commit marks as stable those parts of `core::ops` that are in their
final planned form: `Drop`, all of the mathematical operators (`Add`,
`Sub`, etc), `Deref`/`DerefMut`. It leaves the `Index*`, `Slice*` and
`Fn*` traits unstable, as they are still undergoing active changes.
2015-01-05 14:01:05 -08:00
Aaron Turon
64ec47c9d2 Final alpha stabilization of core::iter
This commit wraps up the adjustments to the iterator for recent language
changes.

* Moves `rposition` from `ExactSizeIterator` to `IteratorExt` using a
  `where` clause, thereby removing the `ExactSizeIterator:
  DoubleEndedIterator` constraint.

* Merges `MutableDoubleEndedIterator` into `IteratorExt`, renaming
  `reverse_` to `reverse_in_place`.

* Merges `IteratorOrdExt`, `IteratorCloneExt` and `CloneIteratorExt`
  into `IteratorExt` using `where` clauses.

Marks as `#[stable]`:

* the `iter` module itself
* `FromIterator`, `Extend`
* `Iterator`, `IteratorExt`
* `map`
* `filter`
* `filter_map`
* `skip_while`
* `take_while`
* `scan`
* `flat_map`
* `inspect`
* `collect`
* `fold`
* `all`
* `any`
* `find`
* `rposition`
* `max`, `min`
* Various adapter types related to the above methods

Because of the trait merging, this is a:

[breaking-change]
2015-01-05 14:01:05 -08:00
FakeKane
f7f5d0958b removing whitespace 2015-01-05 16:46:46 -05:00
FakeKane
8733b8b19c examples added for element access 2015-01-05 16:22:03 -05:00
Jorge Aparicio
cd4205a970 tweak the obsolete syntax message 2015-01-05 15:19:38 -05:00
bors
f11f3e7bae auto merge of #20572 : nikomatsakis/rust/assoc-supertrait-stuff, r=brson
The first few commits in the PR are just general refactoring. I was intending them for some other code I didn't get around to writing yet, but might as well land them now. 

cc @japaric

Fixes #19541
2015-01-05 20:02:14 +00:00
Keegan McAllister
677b7cad3d Reformat metadata for exported macros
Instead of copy-pasting the whole macro_rules! item from the original .rs file,
we serialize a separate name, attributes list, and body, the latter as
pretty-printed TTs.  The compilation of macro_rules! macros is decoupled
somewhat from the expansion of macros in item position.

This filters out comments, and facilitates selective imports.
2015-01-05 12:00:57 -08:00
Keegan McAllister
24aa7f0e38 creader: Use a single struct 2015-01-05 12:00:57 -08:00
Keegan McAllister
5171b325bd creader: Convert free functions to Env methods 2015-01-05 12:00:57 -08:00
Keegan McAllister
5bf385be6a Rename macro_escape to macro_use
In the future we want to support

    #[macro_use(foo, bar)]
    mod macros;

but it's not an essential part of macro reform.  Reserve the syntax for now.
2015-01-05 12:00:57 -08:00
Keegan McAllister
fc58479323 Stop using macro_escape as an inner attribute
In preparation for the rename.
2015-01-05 12:00:57 -08:00
Keegan McAllister
73806ddd0f Use $crate and macro reexport to reduce duplicated code
Many of libstd's macros are now re-exported from libcore and libcollections.
Their libstd definitions have moved to a macros_stage0 module and can disappear
after the next snapshot.

Where the two crates had already diverged, I took the libstd versions as
they're generally newer and better-tested. See e.g. d3c831b, which was a fix to
libstd's assert_eq!() that didn't make it into libcore's.

Fixes #16806.
2015-01-05 12:00:56 -08:00
Jorge Aparicio
4ed2800701 syntax: obsolete the for Sized? syntax 2015-01-05 14:56:49 -05:00
Jorge Aparicio
bbf7e4e58a update comment to reflect new Sized semantics 2015-01-05 14:56:49 -05:00
Jorge Aparicio
eb50d3ee01 undo one for Sized? removal that was in a comment 2015-01-05 14:56:49 -05:00
Jorge Aparicio
c26f5801f5 remove unused Sized imports 2015-01-05 14:56:49 -05:00
Jorge Aparicio
774588fd9d sed -i -s 's/ for Sized?//g' **/*.rs 2015-01-05 14:56:49 -05:00
Alex Crichton
4236c52e34 std: Move Atomic{Int,Uint} back to unstable
The int/uint story is under heavy development, and these types are likely to be
renamed.
2015-01-05 11:39:52 -08:00
Keegan McAllister
1c2fddc6bf Remove unused if_ok! macro 2015-01-05 11:38:12 -08:00
Keegan McAllister
538288176a Implement macro re-export
Fixes #17103.
2015-01-05 11:38:12 -08:00
Keegan McAllister
e2a9c04e19 Allow leading :: in use items 2015-01-05 11:38:12 -08:00
Keegan McAllister
ad7c647773 Add a special macro nonterminal $crate 2015-01-05 11:38:12 -08:00
Keegan McAllister
5e5924b799 Replace LetSyntaxTT with MacroRulesTT
The implementation of LetSyntaxTT was specialized to macro_rules! in various
ways. This gets rid of the false generality and simplifies the code.
2015-01-05 11:38:12 -08:00
Keegan McAllister
d1cf1b1e6b Don't test codegen-units errors on stage1 (c.f. #20184) 2015-01-05 11:38:11 -08:00
Brian Anderson
c548b879ef Typo 2015-01-05 10:29:09 -08:00
Brian Anderson
edbb7c3ed1 0.13.0 -> 1.0.0 2015-01-05 10:26:10 -08:00
Brian Anderson
40bd1c245f Put version number in beta channel artifacts 2015-01-05 10:25:49 -08:00
Chase Southwood
faf07b1365 Update reexports in vim syntax file 2015-01-05 12:21:47 -06:00
Michael Neumann
66da36f6ee Ensure that LLVM is rebuilt with recent changes 2015-01-05 18:40:41 +01:00
Michael Neumann
5488ddb307 Segmented stack support for DragonFly 2015-01-05 18:39:40 +01:00
Steve Klabnik
a56e7aee81 Add lifetime elision information to the ownership guide.
Fixes #19662.
2015-01-05 11:51:52 -05:00
Andrew Paseltiner
61bb6ac9de remove unnecessary Default bound from Hash{Map,Set}'s Extend impl 2015-01-05 11:40:39 -05:00
Niko Matsakis
5caf847b3f Add a test for issue #18865. Fixes #18865. 2015-01-05 11:31:37 -05:00
Niko Matsakis
540a7777b8 Don't ICE just because an impl is missing an associated type. Trust in the other compiler passes.
Fixes #17359.
2015-01-05 11:31:37 -05:00
Alex Crichton
ec7a50d20d std: Redesign c_str and c_vec
This commit is an implementation of [RFC 494][rfc] which removes the entire
`std::c_vec` module and redesigns the `std::c_str` module as `std::ffi`.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0494-c_str-and-c_vec-stability.md

The interface of the new `CString` is outlined in the linked RFC, the primary
changes being:

* The `ToCStr` trait is gone, meaning the `with_c_str` and `to_c_str` methods
  are now gone. These two methods are replaced with a `CString::from_slice`
  method.
* The `CString` type is now just a wrapper around `Vec<u8>` with a static
  guarantee that there is a trailing nul byte with no internal nul bytes. This
  means that `CString` now implements `Deref<Target = [c_char]>`, which is where
  it gains most of its methods from. A few helper methods are added to acquire a
  slice of `u8` instead of `c_char`, as well as including a slice with the
  trailing nul byte if necessary.
* All usage of non-owned `CString` values is now done via two functions inside
  of `std::ffi`, called `c_str_to_bytes` and `c_str_to_bytes_with_nul`. These
  functions are now the one method used to convert a `*const c_char` to a Rust
  slice of `u8`.

Many more details, including newly deprecated methods, can be found linked in
the RFC. This is a:

[breaking-change]
Closes #20444
2015-01-05 08:00:13 -08:00
FakeKane
05c5b5f033 reverting other changes 2015-01-05 10:25:22 -05:00
Niko Matsakis
c8868942e8 Treat associated types the same as type parameters when it comes to region bounding. Fixes #20303.
Strictly speaking, this is a [breaking-change] (if you are using
associated types). You are no longer free to wantonly violate the type
system rules by closing associated types into objects without any form
of region bound. Instead you should add region bounds like `T::X :
'a`, just as you would with a normal type parameter.
2015-01-05 10:14:35 -05:00
bors
03268bbf35 auto merge of #20514 : alexcrichton/rust/serialize-associated-type, r=aturon
This commit moves the libserialize crate (and will force the hand of the
rustc-serialize crate) to not require the `old_orphan_check` feature gate as
well as using associated types wherever possible. Concretely, the following
changes were made:

* The error type of `Encoder` and `Decoder` is now an associated type, meaning
  that these traits have no type parameters.

* The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable`
  traits have moved to the corresponding method of the trait. This movement
  alleviates the dependency on `old_orphan_check` but implies that
  implementations can no longer be specialized for the type of encoder/decoder
  being implemented.

Due to the trait definitions changing, this is a:

[breaking-change]
2015-01-05 14:51:03 +00:00
Piotr Czarnecki
156a1c3134 Implement a few methods for RingBuf
* shrink_to_fit
* swap_back_remove
* swap_front_remove
* truncate
* resize
2015-01-05 15:48:58 +01:00
Niko Matsakis
928bb2be8f Improve test to include a projection, per @huonw's suggestion. 2015-01-05 09:14:03 -05:00
Niko Matsakis
57aaa9bf87 Make supertrait references work in object types too. 2015-01-05 07:11:48 -05:00