Commit graph

35780 commits

Author SHA1 Message Date
bors
19f73b4ef6 auto merge of #20058 : Kimundi/rust/str_pattern_pre, r=alexcrichton
This stabilizes most methods on `&str` working with patterns in a way that is forwards-compatible with a generic string pattern matching API:
- Methods that are using the primary name for their operation are marked as `#[stable]`, as they can be upgraded to a full `Pattern` API later without existing code breaking. Example: `contains(&str)`
- Methods that are using a more specific name in order to not clash with the primary one are marked as `#[unstable]`, as they will likely be removed once their functionality is merged into the primary one. Example: `contains_char<C: CharEq>(C)`
- The method docs got changed to consistently refer to the pattern types as a pattern.
- Methods whose names do not match in the context of the more generic API got renamed. Example: `trim_chars -> trim_matches` 

Additionally, all methods returning iterators got changed to return unique new types with changed names in accordance with the new naming guidelines.

See also https://github.com/rust-lang/rfcs/pull/528

Due to some deprecations and type changes, this is a 

[breaking-change]
2014-12-29 18:02:30 +00:00
bors
3dcc409fac auto merge of #19549 : huonw/rust/middle-ty-2, r=nikomatsakis
This takes building `librustc/lib.rs` from using 696 MB to 588 (`rustc --no-trans`), and 1.99 GB to 1.87 (`rustc -O`). It also reduces `sty` down to 32 bytes on platforms with 64-bit pointers, at the expense of some more side-tables in `ctxt`. I'm sure there's more gains to be had from reducing the size of the side tables (e.g. by making the actual things they're storing smaller).

r? @nikomatsakis
2014-12-29 13:32:19 +00:00
Huon Wilson
91db254c81 More rebase fixes. 2014-12-30 00:11:30 +11:00
Huon Wilson
7c21a0ff69 Update rustc_driver tests. 2014-12-29 23:55:25 +11:00
Huon Wilson
d442f77561 Rebase fixes.
I've totally mangled the history with these rebases; sorry, future programmer!
2014-12-29 23:55:25 +11:00
Huon Wilson
4f7e5ed660 Add the -Z print-enum-sizes flag for displaying enum info.
This replaces required the RUST_LOG=... invocation to make it much more
user friendly.
2014-12-29 23:55:25 +11:00
Huon Wilson
975a57ce43 Fix rebase artifacts. 2014-12-29 23:55:25 +11:00
Huon Wilson
5e5cc6749e Slash the ast::Stmt type from 104 to 24 bytes.
(on platforms with 64-bit pointers.)

The StmtMac variant is rather large and also fairly rare, so let's
optimise the common case.
2014-12-29 23:55:25 +11:00
Huon Wilson
06f25b7e99 Print info from the barefn and region interners in the tcx. 2014-12-29 23:55:25 +11:00
Huon Wilson
85970d49df Intern Region in tcx.
This makes sty only 32 bytes on machines with 64-bit pointers.
2014-12-29 23:55:25 +11:00
Huon Wilson
add6bb2f2d Collect tcx arenas into a single struct.
This allows expanding how many arenas exist without users having to
care, since they are all created with CtxtArena::new().
2014-12-29 23:55:24 +11:00
Huon Wilson
ce3c949115 Intern BareFnTys to make sty slightly smaller.
This cuts the ty_bare_fn variant to 48 bytes rather than 56. There
doesn't seem to be a noticable memory usage decrease from this.
2014-12-29 23:55:24 +11:00
Huon Wilson
a33a7d20de Switch Region information from uint to u32.
This reduces memory use for building librustc with -O from 1.88 to 1.76
GB.
2014-12-29 23:55:24 +11:00
Huon Wilson
a548f8917b Intern substs before storing them in the tcx.
This cuts memory use dramatically from the previous commit, and reduces
use overall. E.g. the memory usage of `rustc -O librustc/lib.rs` seems
to drop 100MB from 1.98GB to 1.88GB (on one run anyway).
2014-12-29 23:55:24 +11:00
Huon Wilson
4f2b0f032a Store Substs in an arena in the tcx.
This current inflates memory use more than 3 times.
2014-12-29 23:55:24 +11:00
Huon Wilson
7cd6bf67a2 Implement debug printing for tcx interner sty's. 2014-12-29 23:55:24 +11:00
bors
25fb12b8a5 auto merge of #19765 : luqmana/rust/nonzero-lang-item, r=nikomatsakis
This extends the nullable enum opt to traverse beyond just the first level to find possible fields to use as the discriminant. So now, it'll work through structs, tuples, and fixed sized arrays. This also introduces a new lang item, NonZero, that you can use to wrap raw pointers or integral types to indicate to rustc that the underlying value is known to never be 0/NULL. We then use this in Vec, Rc and Arc to have them also benefit from the nullable enum opt.

As per https://github.com/rust-lang/rfcs/pull/499 NonZero is not exposed via the `libstd` facade.

```
x86_64 Linux:
                        T       Option<T> (Before)      Option<T> (After)
----------------------------------------------------------------------------------
Vec<int>                24          32                      24
String                  24          32                      24
Rc<int>                 8           16                      8
Arc<int>                8           16                      8
[Box<int>, ..2]         16          24                      16
(String, uint)          32          40                      32
```

Fixes #19419.
Fixes #13194.
Fixes #9378.
Fixes #7576.
2014-12-29 08:06:20 +00:00
Marvin Löbel
c1f3acaa64 Marked find and rfind as stable 2014-12-29 08:54:51 +01:00
bors
03a1188cf3 auto merge of #19227 : johshoff/rust/master, r=brson
Using the current directory may not always be appropriate, for example in
the case where it will unnecessarily trigger a backup to be made.

The only risk with this change is that systems might not have a mktemp.
I am not aware of such a system, but have not tested on Windows. It is
working on a basic Ubuntu and OS X installation.
2014-12-29 05:22:26 +00:00
Luqman Aden
766a71922f libcollections: impl Send/Sync for Vec. 2014-12-28 19:40:48 -05:00
Luqman Aden
0e039ada55 libcoretest: Add tests for NonZero. 2014-12-28 19:40:48 -05:00
Luqman Aden
94f1261573 libcore: Use Zeroable trait to try to limit what types may be used with NonZero. 2014-12-28 19:40:48 -05:00
Luqman Aden
27617a10f6 librustc_trans: Get rid of unnecessary allocation in finding discriminant field. 2014-12-28 19:40:48 -05:00
Luqman Aden
c15df8e68f libcore: Don't impl RawPtr* traits for NonZero. 2014-12-28 19:40:48 -05:00
Luqman Aden
b44d7cb89c Don't expose NonZero through libstd. 2014-12-28 19:40:48 -05:00
Luqman Aden
e83272b628 Add tests for NonZero. 2014-12-28 19:40:48 -05:00
Luqman Aden
466135bfef libcore: Make it unsafe to create NonZero and impl Deref. 2014-12-28 19:40:48 -05:00
Luqman Aden
4af50548b9 liballoc: Use NonZero in Arc. 2014-12-28 19:40:47 -05:00
Luqman Aden
0d48f76224 liballoc: Use NonZero in Rc. 2014-12-28 19:40:47 -05:00
Luqman Aden
bb44737748 libcollections: Use NonZero in Vec. 2014-12-28 19:40:47 -05:00
Luqman Aden
ef5da14edb libcore: Add NonZero lang item and implement some methods. 2014-12-28 19:40:47 -05:00
Luqman Aden
46e7376489 librustc: Add NonZero lang item and use it if possible for nullable pointer enum opt. 2014-12-28 19:40:47 -05:00
Luqman Aden
6d91419f27 Add tests. 2014-12-28 19:40:47 -05:00
Luqman Aden
5fb1e6b1e2 librustc: Try looking in fixed sized arrays for nullable enum opt. 2014-12-28 19:40:47 -05:00
Luqman Aden
e6b6234e66 librustc: Try looking in tuple fields for nullable enum opt. 2014-12-28 19:40:47 -05:00
Luqman Aden
e954fc4385 librustc: Traverse arbitrarily deep for nullable enum opt. 2014-12-28 19:40:46 -05:00
bors
6366631721 auto merge of #20185 : csouth3/rust/dlist-deprecate, r=alexcrichton
This PR deprecates the `DList::ListInsertion` trait, in accordance with rust-lang/rfcs#509.  The functions which were previously part of the ListInsertion impl for `DList::IterMut` have been moved to be inherent methods on the iterator itself, and appropriate doctests have been added.
2014-12-28 16:21:58 +00:00
Johannes Hoff
0e2b5d99af Split overly long line 2014-12-28 12:59:19 +01:00
bors
3e6b29f8ad auto merge of #20136 : eddyb/rust/format-args, r=alexcrichton
We have the technology: no longer do you need to write closures to use `format_args!`.
This is a `[breaking-change]`, as it forces you to clean up old hacks - if you had code like this:
```rust
format_args!(fmt::format, "{} {} {}", a, b, c)
format_args!(|args| { w.write_fmt(args) }, "{} {} {}", x, y, z)
```
change it to this: 
```rust
fmt::format(format_args!("{} {} {}", a, b, c))
w.write_fmt(format_args!("{} {} {}", x, y, z))
```
To allow them to be called with `format_args!(...)` directly, several functions were modified to
take `fmt::Arguments` by value instead of by reference. Also, `fmt::Arguments` derives `Copy`
now in order to preserve all usecases that were previously possible.
2014-12-28 03:11:48 +00:00
Eduard Burtescu
647e54d6d1 Fallout of changing format_args!(f, args) to f(format_args!(args)). 2014-12-27 23:57:43 +02:00
Eduard Burtescu
fc3f22bf25 syntax: change format_args! to produce fmt::Arguments instead of calling a function with them. 2014-12-27 23:55:14 +02:00
Eduard Burtescu
3961adcaf0 syntax: use std::string::String unqualified in format. 2014-12-27 23:55:14 +02:00
Eduard Burtescu
68a7f1b5e3 syntax: turn the match-call generated by format_args inside-out. 2014-12-27 23:55:14 +02:00
Eduard Burtescu
17b3c1107a syntax: format: put static arrays in their own blocks to avoid needing a wrapper block. 2014-12-27 23:55:14 +02:00
Eduard Burtescu
22376be754 syntax: format: remove unused method_statics field. 2014-12-27 23:55:14 +02:00
bors
070ab63807 auto merge of #19916 : SimonSapin/rust/ascii-reform, r=sfackler
Implements [RFC 486](https://github.com/rust-lang/rfcs/pull/486). Fixes #19908.

* Rename `to_ascii_{lower,upper}` to `to_ascii_{lower,upper}case`, per #14401
* Remove the `Ascii` type and associated traits: `AsciiCast`, `OwnedAsciiCast`, `AsciiStr`, `IntoBytes`, and `IntoString`.
* As a replacement, add `.is_ascii()` to `AsciiExt`, and implement `AsciiExt` for `u8` and `char`.

[breaking-change]
2014-12-27 21:51:43 +00:00
bors
0201334439 auto merge of #20244 : japaric/rust/bc-no-move, r=nikomatsakis
closes #19141
closes #20193
closes #20228

---

Currently whenever we encounter `let f = || {/* */}`, we *always* type check the RHS as a *boxed* closure. This is wrong when the RHS is `move || {/* */}` (because boxed closures can't capture by value) and generates all sort of badness during trans (see issues above). What we *should* do is always type check `move || {/* */}` as an *unboxed* closure, but ~~I *think* (haven't tried)~~ (2) this is not feasible right now because we have a limited form of kind (`Fn` vs `FnMut` vs `FnOnce`) inference that only works when there is an expected type (1).

In this PR, I've chosen to generate a type error whenever `let f = move || {/* */}` is encountered. The error asks the user to annotate the kind of the unboxed closure (e.g. `move |:| {/* */}`). Once annotated, the compiler will type check the RHS as an unboxed closure which is what the user wants.

r? @nikomatsakis 

(1) AIUI it only triggers in this scenario:

``` rust
fn is_uc<F>(_: F) where F: FnOnce() {}

fn main() {
    is_uc(|| {});  // type checked as unboxed closure with kind `FnOnce`
}
```

(2) I checked, and it's not possible because `check_unboxed_closure` expects a `kind` argument, but we can't supply that argument in this case (i.e. `let f = || {}`, what's the kind?). We could force the `FnOnce` kind in that case, but that's ad hoc. We should try to infer the kind depending on how the closure is used afterwards, but there is no inference mechanism to do that (at least, not right now).
2014-12-27 15:28:36 +00:00
bors
4a4c89c7a4 auto merge of #20119 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis
More work on opt-in built in traits. `Send` and `Sync` are not opt-in, `OwnedPtr` renamed to `UniquePtr` and the `Send` and `Sync` traits are now unsafe.

NOTE: This likely needs to be rebased on top of the yet-to-land snapshot.

r? @nikomatsakis 

cc #13231
2014-12-27 13:11:48 +00:00
Flavio Percoco
1a73ccc8db Make trait's impls consistent for unix/windows 2014-12-27 13:00:20 +01:00
Flavio Percoco
11f71ec701 Implement Sync/Send for windows' UnixStream 2014-12-27 12:40:25 +01:00