Commit Graph

36075 Commits

Author SHA1 Message Date
Alex Crichton
9ac9d7af3b rollup merge of #20210: tshepang/patch-5 2014-12-29 16:36:04 -08:00
Alex Crichton
88ea54a39d rollup merge of #20207: jroesch/issue-18906-testcase
Closes issue #18906. This is what we talked about last night/early this morning. r? @nikomatsakis.
2014-12-29 16:36:03 -08:00
Alex Crichton
12ac91e1a6 rollup merge of #20205: tshepang/patch-4
The paragraph following this removed one has the same info, only better.
2014-12-29 16:36:01 -08:00
Alex Crichton
06256582e9 rollup merge of #20195: nagisa/unused-typo 2014-12-29 16:36:00 -08:00
Alex Crichton
2a8547783f rollup merge of #20194: nick29581/dst-syntax
Part of #19607.

r? @nikomatsakis
2014-12-29 16:35:59 -08:00
Alex Crichton
28f424fd1b rollup merge of #20191: lifthrasiir/double-debug_assert
Yes, really. That definition wouldn't work anyway.

This also fixes repeated entries for `debug_assert!` from libcore docs. Maybe we should warn such macro definitions in the first place?
2014-12-29 16:35:57 -08:00
Alex Crichton
7b3be9b854 rollup merge of #20182: brianloveswords/patch-2
Treemap should be BTreeMap
2014-12-29 16:35:56 -08:00
Alex Crichton
62c9a48953 rollup merge of #20165: tamird/needstest-tests
@alexcrichton @jakub-
2014-12-29 16:35:54 -08:00
Alex Crichton
dbc8440821 rollup merge of #20160: nick29581/ranges2
The first six commits are from an earlier PR (#19858) and have already been reviewed. This PR makes an awful hack in the compiler to accommodate slices both natively and in the index a range form. After a snapshot we can hopefully add the new Index impls and then we can remove these awful hacks.

r? @nikomatsakis (or anyone who knows the compiler, really)
2014-12-29 16:35:53 -08:00
Alex Crichton
52315a97c6 rollup merge of #20042: alexcrichton/second-pass-ptr
This commit performs a second pass for stabilization over the `std::ptr` module.
The specific actions taken were:

* The `RawPtr` trait was renamed to `PtrExt`
* The `RawMutPtr` trait was renamed to `PtrMutExt`
* The module name `ptr` is now stable.
* These functions were all marked `#[stable]` with no modification:
  * `null`
  * `null_mut`
  * `swap`
  * `replace`
  * `read`
  * `write`
  * `PtrExt::is_null`
  * `PtrExt::is_not_null`
  * `PtrExt::offset`
* These functions remain unstable:
  * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive
                         as null isn't the only bad value, and it's unclear
                         whether we want to commit to these functions at this
                         time. The reference/lifetime semantics as written are
                         also problematic in how they encourage arbitrary
                         lifetimes.
  * `zero_memory` - This function is currently not used at all in the
                    distribution, and in general it plays a broader role in the
                    "working with unsafe pointers" story. This story is not yet
                    fully developed, so at this time the function remains
                    unstable for now.
  * `read_and_zero` - This function remains unstable for largely the same
                      reasons as `zero_memory`.
* These functions are now all deprecated:
  * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead.
  * `PtrExt::to_uint` - use an `as` expression instead.
2014-12-29 16:35:51 -08:00
Alex Crichton
cc20d6009e rollup merge of #19661: alexcrichton/mutex-result
All of the current std::sync primitives have poisoning enable which means that
when a task fails inside of a write-access lock then all future attempts to
acquire the lock will fail. This strategy ensures that stale data whose
invariants are possibly not upheld are never viewed by other tasks to help
propagate unexpected panics (bugs in a program) among tasks.

Currently there is no way to test whether a mutex or rwlock is poisoned. One
method would be to duplicate all the methods with a sister foo_catch function,
for example. This pattern is, however, against our [error guidelines][errors].
As a result, this commit exposes the fact that a task has failed internally
through the return value of a `Result`.

[errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

All methods now return a `LockResult<T>` or a `TryLockResult<T>` which
communicates whether the lock was poisoned or not. In a `LockResult`, both the
`Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in
order to allow access to the data if poisoning is not desired. This also means
that the lock is *always* held upon returning from `.lock()`.

A new type, `PoisonError`, was added with one method `into_guard` which can
consume the assertion that a lock is poisoned to gain access to the underlying
data.

This is a breaking change because the signatures of these methods have changed,
often incompatible ways. One major difference is that the `wait` methods on a
condition variable now consume the guard and return it in as a `LockResult` to
indicate whether the lock was poisoned while waiting. Most code can be updated
by calling `.unwrap()` on the return value of `.lock()`.

[breaking-change]
2014-12-29 16:35:50 -08:00
Alex Crichton
94d82c1f55 rollup merge of #19457: reem/remove-is-lang-item
Removes a FIXME on closed issue #15064. This flag is no
longer needed or used since reflection is gone.
2014-12-29 16:35:49 -08:00
Nick Cameron
113f8aa86b Rebasing and reviewer changes 2014-12-30 13:06:25 +13:00
Nick Cameron
3bf405682d Fallout from mut slices 2014-12-30 13:06:25 +13:00
Nick Cameron
4e2afb0052 Remove ExprSlice by hacking the compiler
[breaking-change]

The `mut` in slices is now redundant. Mutability is 'inferred' from position. This means that if mutability is only obvious from the type, you will need to use explicit calls to the slicing methods.
2014-12-30 13:06:25 +13:00
Nick Cameron
ed8f503911 Add hypothetical support for ranges with only an upper bound
Note that this doesn't add the surface syntax.
2014-12-30 13:06:24 +13:00
Alex Crichton
54452cdd68 std: Second pass stabilization for ptr
This commit performs a second pass for stabilization over the `std::ptr` module.
The specific actions taken were:

* The `RawPtr` trait was renamed to `PtrExt`
* The `RawMutPtr` trait was renamed to `MutPtrExt`
* The module name `ptr` is now stable.
* These functions were all marked `#[stable]` with no modification:
  * `null`
  * `null_mut`
  * `swap`
  * `replace`
  * `read`
  * `write`
  * `PtrExt::is_null`
  * `PtrExt::offset`
* These functions remain unstable:
  * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive
                         as null isn't the only bad value, and it's unclear
                         whether we want to commit to these functions at this
                         time. The reference/lifetime semantics as written are
                         also problematic in how they encourage arbitrary
                         lifetimes.
  * `zero_memory` - This function is currently not used at all in the
                    distribution, and in general it plays a broader role in the
                    "working with unsafe pointers" story. This story is not yet
                    fully developed, so at this time the function remains
                    unstable for now.
  * `read_and_zero` - This function remains unstable for largely the same
                      reasons as `zero_memory`.
* These functions are now all deprecated:
  * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead.
  * `PtrExt::to_uint` - use an `as` expression instead.
  * `PtrExt::is_not_null` - use `!p.is_null()` instead.
2014-12-29 15:57:28 -08:00
Alex Crichton
35e63e3827 std: Stabilization pass for mutex/rwlock/condvar
This commit performs a stabilization pass over the sync::{mutex, rwlock,
condvar} modules, marking the following items as stable:

* Mutex
* Mutex::new
* Mutex::lock
* Mutex::try_lock
* MutexGuard
* RWLock
* RWLock::new
* RWLock::read
* RWLock::try_read
* RWLock::write
* RWLock::try_write
* RWLockReadGuard
* RWLockWriteGuard
* Condvar
* Condvar::new
* Condvar::wait
* Condvar::notify_one
* Condvar::notify_all
* PoisonError
* TryLockError
* TryLockError::Poisoned
* TryLockError::WouldBlock
* LockResult
* TryLockResult

The following items remain unstable to explore future possibilities of unifying
the static/non-static variants of the types:

* StaticMutex
* StaticMutex::new
* StaticMutex::lock
* StaticMutex::try_lock
* StaticMutex::desroy
* StaticRWLock
* StaticRWLock::new
* StaticRWLock::read
* StaticRWLock::try_read
* StaticRWLock::write
* StaticRWLock::try_write
* StaticRWLock::destroy

The following items were removed in favor of `Guard<'static, ()>` instead.

* StaticMutexGuard
* StaticRWLockReadGuard
* StaticRWLockWriteGuard
2014-12-29 14:41:30 -08:00
Alex Crichton
b26daf3a67 std: Second pass stabilization for string
This commit performs a second pass over the `std::string` module, performing the
following actions:

* The name `std::string` is now stable.
* The `String::from_utf8` function is now stable after having been altered to
  return a new `FromUtf8Error` structure. The `FromUtf8Error` structure is now
  stable as well as its `into_bytes` and `utf8_error` methods.
* The `String::from_utf8_lossy` function is now stable.
* The `String::from_chars` method is now deprecated in favor of `.collect()`
* The `String::from_raw_parts` method is now stable
* The `String::from_str` function remains experimental
* The `String::from_raw_buf` function remains experimental
* The `String::from_raw_buf_len` function remains experimental
* The `String::from_utf8_unchecked` function is now stable
* The `String::from_char` function is now deprecated in favor of
  `repeat(c).take(n).collect()`
* The `String::grow` function is now deprecated in favor of
  `.extend(repeat(c).take(n)`
* The `String::capacity` method is now stable
* The `String::reserve` method is now stable
* The `String::reserve_exact` method is now stable
* The `String::shrink_to_fit` method is now stable
* The `String::pop` method is now stable
* The `String::as_mut_vec` method is now stable
* The `String::is_empty` method is now stable
* The `IntoString` trait is now deprecated (there are no implementors)
* The `String::truncate` method is now stable
* The `String::insert` method is now stable
* The `String::remove` method is now stable
* The `String::push` method is now stable
* The `String::push_str` method is now stable
* The `String::from_utf16` function is now stable after its error type has now
  become an opaque structure to carry more semantic information in the future.

A number of these changes are breaking changes, but the migrations should be
fairly straightforward on a case-by-case basis (outlined above where possible).

[breaking-change]
2014-12-29 14:11:16 -08:00
Florian Hahn
808945c21c Handle range in model lexer correctly #15877 2014-12-29 21:29:31 +01:00
Steven Fackler
88d4e02d5b Implement Send for Cell and RefCell
Also get rid of NoSync markers since UnsafeCell is now not Sync
2014-12-29 12:20:34 -08:00
bors
71123902e1 auto merge of #20101 : alexcrichton/rust/issue-20096, r=aturon
These crates are all deprecated for their rust-lang/$crate equivalents and by
generating docs we're generating broken links. The documentation for these
crates are generated out-of-tree and are managed separately, so we're not losing
the documentation altogether, just the links from the main distribution's docs.

Closes #20096
2014-12-29 20:19:53 +00:00
Alex Crichton
bc83a009f6 std: Second pass stabilization for comm
This commit is a second pass stabilization for the `std::comm` module,
performing the following actions:

* The entire `std::comm` module was moved under `std::sync::mpsc`. This movement
  reflects that channels are just yet another synchronization primitive, and
  they don't necessarily deserve a special place outside of the other
  concurrency primitives that the standard library offers.
* The `send` and `recv` methods have all been removed.
* The `send_opt` and `recv_opt` methods have been renamed to `send` and `recv`.
  This means that all send/receive operations return a `Result` now indicating
  whether the operation was successful or not.
* The error type of `send` is now a `SendError` to implement a custom error
  message and allow for `unwrap()`. The error type contains an `into_inner`
  method to extract the value.
* The error type of `recv` is now `RecvError` for the same reasons as `send`.
* The `TryRecvError` and `TrySendError` types have had public reexports removed
  of their variants and the variant names have been tweaked with enum
  namespacing rules.
* The `Messages` iterator is renamed to `Iter`

This functionality is now all `#[stable]`:

* `Sender`
* `SyncSender`
* `Receiver`
* `std::sync::mpsc`
* `channel`
* `sync_channel`
* `Iter`
* `Sender::send`
* `Sender::clone`
* `SyncSender::send`
* `SyncSender::try_send`
* `SyncSender::clone`
* `Receiver::recv`
* `Receiver::try_recv`
* `Receiver::iter`
* `SendError`
* `RecvError`
* `TrySendError::{mod, Full, Disconnected}`
* `TryRecvError::{mod, Empty, Disconnected}`
* `SendError::into_inner`
* `TrySendError::into_inner`

This is a breaking change due to the modification of where this module is
located, as well as the changing of the semantics of `send` and `recv`. Most
programs just need to rename imports of `std::comm` to `std::sync::mpsc` and
add calls to `unwrap` after a send or a receive operation.

[breaking-change]
2014-12-29 12:16:49 -08:00
Florian Hahn
adda8997b1 Update grammer/verify.rs to work with recent master 2014-12-29 19:40:40 +01:00
Florian Hahn
288195370c Fix output directory for generated antlr code 2014-12-29 19:40:40 +01:00
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
Alex Crichton
76e5ed655c std: Return Result from RWLock/Mutex methods
All of the current std::sync primitives have poisoning enable which means that
when a task fails inside of a write-access lock then all future attempts to
acquire the lock will fail. This strategy ensures that stale data whose
invariants are possibly not upheld are never viewed by other tasks to help
propagate unexpected panics (bugs in a program) among tasks.

Currently there is no way to test whether a mutex or rwlock is poisoned. One
method would be to duplicate all the methods with a sister foo_catch function,
for example. This pattern is, however, against our [error guidelines][errors].
As a result, this commit exposes the fact that a task has failed internally
through the return value of a `Result`.

[errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

All methods now return a `LockResult<T>` or a `TryLockResult<T>` which
communicates whether the lock was poisoned or not. In a `LockResult`, both the
`Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in
order to allow access to the data if poisoning is not desired. This also means
that the lock is *always* held upon returning from `.lock()`.

A new type, `PoisonError`, was added with one method `into_guard` which can
consume the assertion that a lock is poisoned to gain access to the underlying
data.

This is a breaking change because the signatures of these methods have changed,
often incompatible ways. One major difference is that the `wait` methods on a
condition variable now consume the guard and return it in as a `LockResult` to
indicate whether the lock was poisoned while waiting. Most code can be updated
by calling `.unwrap()` on the return value of `.lock()`.

[breaking-change]
2014-12-29 09:18:09 -08:00
Steve Klabnik
86d6359065 Don't promise that we talk about Rustdoc more
Fixes #20088
2014-12-29 12:06:11 -05:00
Alex Crichton
bb8f4fc3b7 fixes 2014-12-29 08:58:21 -08:00
Steve Klabnik
e76bd7e75d Properly deal with Ordering in the guide
Now that it's been removed from the prelude, we need to treat things differently.

Fixes #17967
2014-12-29 08:58:21 -08:00
Alex Crichton
c32d03f417 std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization
story for the prelude. Most of the RFC was directly applied, removing reexports.
Some reexports are kept around, however:

* `range` remains until range syntax has landed to reduce churn.
* `Path` and `GenericPath` remain until path reform lands. This is done to
  prevent many imports of `GenericPath` which will soon be removed.
* All `io` traits remain until I/O reform lands so imports can be rewritten all
  at once to `std::io::prelude::*`.

This is a breaking change because many prelude reexports have been removed, and
the RFC can be consulted for the exact list of removed reexports, as well as to
find the locations of where to import them.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md
[breaking-change]

Closes #20068
2014-12-29 08:58:21 -08: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
Nick Cameron
9dce83ccd9 Tests 2014-12-29 19:10:08 +13:00
Nick Cameron
ac095351fb Fallout from globs/re-export/shadowing change 2014-12-29 19:10:08 +13:00