Commit Graph

34263 Commits

Author SHA1 Message Date
Daniel Micay
fea985a0b5 bubble up out-of-memory errors from liballoc
This makes the low-level allocation API suitable for use cases where
out-of-memory conditions need to be handled.

Closes #18292

[breaking-change]
2014-11-01 19:23:20 -04:00
bors
3327ecca42 auto merge of #17595 : danburkert/rust/tuple-index-deserialization, r=alexcrichton
Currently `Decoder` implementations are not provided the tuple arity as
a parameter to `read_tuple`. This forces all encoder/decoder combos to
serialize the arity along with the elements. Tuple-arity is always known
statically at the decode site, because it is part of the type of the
tuple, so it could instead be provided as an argument to `read_tuple`,
as it is to `read_struct`.

The upside to this is that serialized tuples could become smaller in
encoder/decoder implementations which choose not to serialize type
(arity) information. For example, @TyOverby's
[binary-encode](https://github.com/TyOverby/binary-encode) format is
currently forced to serialize the tuple-arity along with every tuple,
despite the information being statically known at the decode site.

A downside to this change is that the tuple-arity of serialized tuples
can no longer be automatically checked during deserialization. However,
for formats which do serialize the tuple-arity, either explicitly (rbml)
or implicitly (json), this check can be added to the `read_tuple` method.

The signature of `Deserialize::read_tuple` and
`Deserialize::read_tuple_struct` are changed, and thus binary
backwards-compatibility is broken. This change does *not* force
serialization formats to change, and thus does not break decoding values
serialized prior to this change.

[breaking-change]
2014-11-01 22:41:48 +00:00
Brian Koropoff
09cc2f1b13 Add regression test for issue #18514 2014-11-01 15:24:42 -07:00
Brian Koropoff
7ea7606874 Monomorphize method types in Typer impl for BlockS
In some obscure circumstances, failure to do this can cause
unsubstituted type parameters to show up where they aren't
expected and cause an ICE.

Closes #18514
2014-11-01 15:24:34 -07:00
bors
39f90aead4 auto merge of #18474 : alexcrichton/rust/no-more-traits, r=aturon
As part of the collections reform RFC, this commit removes all collections
traits in favor of inherent methods on collections themselves. All methods
should continue to be available on all collections.

This is a breaking change with all of the collections traits being removed and
no longer being in the prelude. In order to update old code you should move the
trait implementations to inherent implementations directly on the type itself.

Note that some traits had default methods which will also need to be implemented
to maintain backwards compatibility.

[breaking-change]
cc #18424
2014-11-01 20:21:47 +00:00
Alex Crichton
21ac985af4 collections: Remove all collections traits
As part of the collections reform RFC, this commit removes all collections
traits in favor of inherent methods on collections themselves. All methods
should continue to be available on all collections.

This is a breaking change with all of the collections traits being removed and
no longer being in the prelude. In order to update old code you should move the
trait implementations to inherent implementations directly on the type itself.

Note that some traits had default methods which will also need to be implemented
to maintain backwards compatibility.

[breaking-change]
cc #18424
2014-11-01 11:37:04 -07:00
Dan Burkert
05f6bdaefc Tuple deserialization should not fail 2014-11-01 10:54:34 -07:00
Dan Burkert
ca6b082c05 libserialize: tuple-arity should be provided to Decoder::read_tuple
Currently `Decoder` implementations are not provided the tuple arity as
a parameter to `read_tuple`. This forces all encoder/decoder combos to
serialize the arity along with the elements. Tuple-arity is always known
statically at the decode site, because it is part of the type of the
tuple, so it could instead be provided as an argument to `read_tuple`,
as it is to `read_struct`.

The upside to this is that serialized tuples could become smaller in
encoder/decoder implementations which choose not to serialize type
(arity) information. For example, @TyOverby's
[binary-encode](https://github.com/TyOverby/binary-encode) format is
currently forced to serialize the tuple-arity along with every tuple,
despite the information being statically known at the decode site.

A downside to this change is that the tuple-arity of serialized tuples
can no longer be automatically checked during deserialization. However,
for formats which do serialize the tuple-arity, either explicitly (rbml)
or implicitly (json), this check can be added to the `read_tuple` method.

The signature of `Deserialize::read_tuple` and
`Deserialize::read_tuple_struct` are changed, and thus binary
backwards-compatibility is broken. This change does *not* force
serialization formats to change, and thus does not break decoding values
serialized prior to this change.

[breaking-change]
2014-11-01 10:54:34 -07:00
Daniel Hofstetter
83225cc38d Reference: Add missing of's 2014-11-01 15:34:01 +01:00
Daniel Hofstetter
88d7f0a8da Guide: Fix variable name 2014-11-01 14:56:48 +01:00
bors
0547a407aa auto merge of #18457 : japaric/rust/tocstr, r=alexcrichton
Methods that used to take `ToCStr` implementors by value, now take them by reference. In particular, this breaks some uses of `Command`:

``` rust
Command::new("foo");  // Still works
Command::new(path) -> Command::new(&path)
cmd.arg(string) -> cmd.arg(&string) or cmd.arg(string.as_slice())
```

[breaking-change]

---

It may be sensible to remove `impl ToCstr for String` since:
- We're getting `impl Deref<str> for String`, so `string.to_cstr()` would still work
- `Command` methods would still be able to use `cmd.arg(string[..])` instead of `cmd.arg(&string)`.

But, I'm leaving that up to the library stabilization process.

r? @aturon 
cc #16918
2014-11-01 11:21:47 +00:00
Brian Koropoff
205f84f13c Add compile-fail test of DST rvalues resulting from overloaded index 2014-11-01 01:56:09 -07:00
Falco Hirschenberger
e5058a8f0c Add lint for checking exceeding bitshifts #17713 2014-11-01 09:10:10 +01:00
Brian Koropoff
6b93b4eb7c Add regression test for #18487 2014-10-31 23:42:48 -07:00
Brian Koropoff
8a9ced1551 Fix trans of index overload expressions with DST result types
Closes #18487
2014-10-31 23:31:16 -07:00
bors
51a25c7f96 auto merge of #18422 : michaelwoerister/rust/windows-freeze-fix, r=alexcrichton
On some Windows versions of GDB this is more stable than setting breakpoints via function names. This is also something I wanted to do for some time now because it makes the tests more consistent.

@brson:
These changes are in response to issue #17540. It works on my machine with the toolchain mentioned in the issue. In order to find out if the problem is really worked around, we also need to make the build bots use the newer GDB version again.
2014-11-01 03:56:44 +00:00
Steven Fackler
d7ff7da65a First stage of enum namespacing changes 2014-10-31 20:43:35 -07:00
bors
1442235d3f auto merge of #18371 : nikomatsakis/rust/issue-18262, r=pcwalton
Teach variance checker about the lifetime bounds that appear in trait object types.

[breaking-change] This patch fixes a hole in the type system which resulted in lifetime parameters that were only used in trait objects not being checked. It's hard to characterize precisely the changes that might be needed to fix target code.

cc #18262 (this fixes the test case by @jakub- but I am not sure if this is the same issue that @alexcrichton was reporting)

r? @pnkfelix 

Fixes #18205
2014-11-01 01:41:45 +00:00
bors
88b6e93d35 auto merge of #18177 : nick29581/rust/ufcs2, r=nikomatsakis
r?

closes #18061
2014-10-31 23:36:48 +00:00
Adrien Tétar
f4fb57b110 doc: enable OpenType kerning and ligatures 2014-11-01 00:16:48 +01:00
Adrien Tétar
c809a4ff01 Update one corrupt webfont
As with last time (where I marked .woff files as binary so that git does
not perform newline normalization), it's unclear how it got corrupted in
the first place.
2014-11-01 00:15:35 +01:00
Adrien Tétar
3a72bc3f1c rustdoc: stop trying to use font-variants we don't have
Browser-generated weights or slants is the last thing we want...
2014-11-01 00:06:49 +01:00
Nick Cameron
060566f08a Fix RustDoc bug 2014-11-01 11:05:12 +13:00
Nick Cameron
2474d7d2c4 Rebasing and review changes 2014-11-01 11:05:12 +13:00
Nick Cameron
318472bea9 test 2014-11-01 11:05:12 +13:00
Nick Cameron
1397f990fe Cross crait inherant impls 2014-11-01 11:05:12 +13:00
Nick Cameron
d416d16cce Remove FnStyle from DefFn and DefStaticMethod 2014-11-01 11:05:12 +13:00
Nick Cameron
4e7d86c079 Resolve methods called as functions and...
...defined in another crate.

Fixes #18061
2014-11-01 11:03:50 +13:00
Niko Matsakis
9a5e7ba4c7 Teach variance checker about the lifetime bounds that appear in trait object types. 2014-10-31 17:39:41 -04:00
Rolf van de Krol
66b8cc8692 small fix to output of code sample in intro.md 2014-10-31 20:28:58 +01:00
Niko Matsakis
6bf0dc849f Prefer where clauses to impls in trait resolution (not vice versa).
Fixes #18453.
2014-10-31 15:03:56 -04:00
Jakub Bukaj
d23d633eb8 Constants used in range patterns should not be considered unused 2014-10-31 19:14:57 +01:00
gamazeps
4ee0c4f3fb DOC: improves the str type explanation
Closes #18449
2014-10-31 19:00:00 +01:00
Michael Woerister
e06c338273 debuginfo: Enable some GDB tests on Windows. 2014-10-31 18:49:59 +01:00
Michael Woerister
54a5a2b365 debuginfo: Make GDB tests use line breakpoints like done in LLDB tests.
On some Windows versions of GDB this is more stable than setting breakpoints via function names.
2014-10-31 18:49:59 +01:00
bors
5e834243b6 auto merge of #18440 : japaric/rust/hash, r=alexcrichton
- The signature of the `*_equiv` methods of `HashMap` and similar structures have changed, and now require one less level of indirection. Change your code from:

``` rust
hashmap.find_equiv(&"Hello");
hashmap.find_equiv(&&[0u8, 1, 2]);
```

to:

``` rust
hashmap.find_equiv("Hello");
hashmap.find_equiv(&[0u8, 1, 2]);
```

- The generic parameter `T` of the `Hasher::hash<T>` method have become `Sized?`. Downstream code must add `Sized?` to that method in their implementations. For example:

``` rust
impl Hasher<FnvState> for FnvHasher {
    fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
}
```

must be changed to:

``` rust
impl Hasher<FnvState> for FnvHasher {
    fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
    //      ^^^^^^
}
```

[breaking-change]

---

After review I'll squash the commits and update the commit message with the above paragraph.

r? @aturon 
cc #16918
2014-10-31 17:11:43 +00:00
Jorge Aparicio
dd9dda7a1c DSTify ToCStr 2014-10-31 10:09:15 -05:00
bors
7e662316d1 auto merge of #18458 : eddyb/rust/free-region-args, r=nikomatsakis
This fixes ICEs caused by late-bound lifetimes ending up in argument
datum types and being used in cleanup - user Drop impl's would then
fail to monomorphize if the type was used to look up the impl of a
method call - which happens in trans now, I presume for multidispatch.
2014-10-31 15:06:45 +00:00
Eduard Burtescu
96ba514294 trans: use types from argument patterns instead of the function signature.
This fixes ICEs caused by late-bound lifetimes ending up in argument
datum types and being used in cleanup - user Drop impl's would then
fail to monomorphize if the type was used to look up the impl of a
method call - which happens in trans now, I presume for multidispatch.
2014-10-31 16:47:25 +02:00
Jorge Aparicio
1384a43db3 DSTify Hash
- The signature of the `*_equiv` methods of `HashMap` and similar structures
have changed, and now require one less level of indirection. Change your code
from:

```
hashmap.find_equiv(&"Hello");
hashmap.find_equiv(&&[0u8, 1, 2]);
```

to:

```
hashmap.find_equiv("Hello");
hashmap.find_equiv(&[0u8, 1, 2]);
```

- The generic parameter `T` of the `Hasher::hash<T>` method have become
`Sized?`. Downstream code must add `Sized?` to that method in their
implementations. For example:

```
impl Hasher<FnvState> for FnvHasher {
    fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
}
```

must be changed to:

```
impl Hasher<FnvState> for FnvHasher {
    fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
    //      ^^^^^^
}
```

[breaking-change]
2014-10-31 07:25:34 -05:00
bors
82045ca360 auto merge of #18264 : jakub-/rust/var-ids-in-error-messages, r=nikomatsakis
This PR aims to improve the readability of diagnostic messages that involve unresolved type variables. Currently, messages like the following:

```rust
mismatched types: expected `core::result::Result<uint,()>`, found `core::option::Option<<generic #1>>`
<anon>:6     let a: Result<uint, ()> = None;
                                       ^~~~
mismatched types: expected `&mut <generic #2>`, found `uint`
<anon>:7     f(42u);
               ^~~
```

tend to appear unapproachable to new users. [0] While specific type var IDs are valuable in
diagnostics that deal with more than one such variable, in practice many messages
only mention one. In those cases, leaving out the specific number makes the messages
slightly less terrifying.

```rust
mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_>`
<anon>:6     let a: Result<uint, ()> = None;
                                       ^~~~
mismatched types: expected `&mut _`, found `uint`
<anon>:7     f(42u);
               ^~~
```

As you can see, I also tweaked the aesthetics slightly by changing type variables to use the type hole syntax _. For integer variables, the syntax used is:

```rust
mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_#1i>`
<anon>:6     let a: Result<uint, ()> = Some(1);
```

and float variables:

```rust
mismatched types: expected `core::result::Result<uint, ()>`, found `core::option::Option<_#1f>`
<anon>:6     let a: Result<uint, ()> = Some(0.5);
```

[0] https://twitter.com/coda/status/517713085465772032

Closes https://github.com/rust-lang/rust/issues/2632.
Closes https://github.com/rust-lang/rust/issues/3404.
Closes https://github.com/rust-lang/rust/issues/18426.
2014-10-31 11:16:44 +00:00
bors
065caf34f5 auto merge of #18431 : japaric/rust/show, r=alexcrichton
r? @aturon 
cc #16918
2014-10-31 06:01:41 +00:00
Jorge Aparicio
eef7e97017 DSTify Show and all the other formatting traits 2014-10-30 23:28:11 -05:00
bors
221fc1e3cd auto merge of #18459 : alexcrichton/rust/rollup, r=alexcrichton 2014-10-31 02:27:15 +00:00
Alex Crichton
8e6e846d8a rustc: Implement -l and include! tweaks
This is an implementation of the rustc bits of [RFC 403][rfc]. This adds a new
flag to the compiler, `-l`, as well as tweaking the `include!` macro (and
related source-centric macros).

The compiler's new `-l` flag is used to link libraries in from the command line.
This flag stacks with `#[link]` directives already found in the program. The
purpose of this flag, also stated in the RFC, is to ease linking against native
libraries which have wildly different requirements across platforms and even
within distributions of one platform. This flag accepts a string of the form
`NAME[:KIND]` where `KIND` is optional or one of dylib, static, or framework.
This is roughly equivalent to if the equivalent `#[link]` directive were just
written in the program.

The `include!` macro has been modified to recursively expand macros to allow
usage of `concat!` as an argument, for example. The use case spelled out in RFC
403 was for `env!` to be used as well to include compile-time generated files.
The macro also received a bit of tweaking to allow it to expand to either an
expression or a series of items, depending on what context it's used in.

[rfc]: https://github.com/rust-lang/rfcs/pull/403
2014-10-30 19:02:11 -07:00
Vadim Chugunov
e23f5c8e26 Really fix #17982 this time. 2014-10-30 18:01:02 -07:00
Alex Crichton
6fcba8826f Test fixes and rebase conflicts 2014-10-30 17:37:56 -07:00
Alex Crichton
c10c163377 rollup merge of #18445 : alexcrichton/index-mut
Conflicts:
	src/libcollections/vec.rs
2014-10-30 17:37:55 -07:00
Alex Crichton
5d6241ddaf rollup merge of #18430 : bjz/token
Conflicts:
	src/libsyntax/parse/parser.rs
2014-10-30 17:37:41 -07:00
Alex Crichton
00975e041d rollup merge of #18398 : aturon/lint-conventions-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-30 17:37:22 -07:00