Commit Graph

40816 Commits

Author SHA1 Message Date
Björn Steinbrink
cc259fb6c3 Always properly copy values into bindings when mutating the match discriminant
The reassignment checker effectively only checks whether the last
assignment in a body affects the discriminant, but it should of course
check all the assignments.

Fixes #23698
2015-03-25 14:50:04 +01:00
Manish Goregaokar
5535767228 Rollup merge of #23664 - bluss:std-docs, r=steveklabnik
Main motivation was to update docs for the removal or "demotion" of certain extension traits. The update to the slice docs was larger, since the text was largely outdated.
2015-03-25 17:12:13 +05:30
Manish Goregaokar
b6783e6b46 Rollup merge of #23617 - steveklabnik:gh23564, r=Manishearth
Fixes #23564
2015-03-25 17:12:13 +05:30
Sae-bom Kim
c66a2b7393 Ignore some tests on aarch64 2015-03-25 18:17:33 +09:00
Sae-bom Kim
a99936b397 make it use gdb instead of lldb when mac-android cross compile 2015-03-25 18:12:35 +09:00
bors
928e2e2394 Auto merge of #23670 - cmr:vec-push-slowpath, r=pcwalton
Makes Vec::push considerably smaller: 25 instructions, rather than 42, on
x86_64.
2015-03-25 07:47:30 +00:00
Sébastien Marie
eefb8e2065 unbreak bitrig/openbsd build after 8389253d
`PathBuf::new` have been changed. Use `PathBuf::from` instead.

Apply the same change for freebsd too, while here.
2015-03-25 08:44:35 +01:00
Jihyun Yu
1663665be0 Fix ICE on SIMD overflow checking
Disable overflow checking on SIMD operations, fix #23037
2015-03-25 15:17:10 +09:00
Camille Roussel
053d58e180 Update pointers.md 2015-03-24 21:46:09 -07:00
Tamir Duberstein
eb5ed10330 [iOS] Fallout from 8389253 2015-03-24 18:50:38 -07:00
bors
593db005d4 Auto merge of #23681 - alexcrichton:rollup, r=alexcrichton 2015-03-25 01:42:42 +00:00
Alex Crichton
3021d4c564 Test fixes and rebase conflicts, round 2 2015-03-24 18:37:16 -07:00
Alex Crichton
db2c3ba0cf rollup merge of #23674: nagisa/fallout-1 2015-03-24 16:53:38 -07:00
Alex Crichton
efaef24304 Test fixes and rebase conflicts, round 1 2015-03-24 16:48:50 -07:00
Gleb Kozyrev
3577555742 Implement AsRef and AsMut for fixed-sized arrays 2015-03-25 01:37:08 +02:00
bors
123a754cb8 Auto merge of #23546 - alexcrichton:hyphens, r=brson
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-24 22:44:33 +00:00
Simonas Kazlauskas
492f07bbda Fix some fallout in librustdoc 2015-03-25 00:39:29 +02:00
Alex Crichton
19cd00094c rollup merge of #23671: steveklabnik/doc_std_clone 2015-03-24 15:27:16 -07:00
Alex Crichton
3b13b9c2b4 rollup merge of #23638: pnkfelix/fsk-reject-specialized-drops
Reject specialized Drop impls.

See Issue #8142 for discussion.

This makes it illegal for a Drop impl to be more specialized than the original item.

So for example, all of the following are now rejected (when they would have been blindly accepted before):

```rust
struct S<A> { ... };
impl Drop for S<i8> { ... } // error: specialized to concrete type

struct T<'a> { ... };
impl Drop for T<'static> { ... } // error: specialized to concrete region

struct U<A> { ... };
impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement

struct V<'a,'b>;
impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement
```

Due to examples like the above, this is a [breaking-change].

(The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.)

----

This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute.

Fix #8142
Fix #23584
2015-03-24 15:27:14 -07:00
Alex Crichton
91b633aa03 rollup merge of #23546: alexcrichton/hyphens
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-24 14:56:00 -07:00
Alex Crichton
eb2f1d925f rustc: Add support for extern crate foo as bar
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-24 14:55:15 -07:00
Alex Crichton
4c2ddb33ad std: Reexport std::rt::unwind::try in std::thread
This commit provides a safe, but unstable interface for the `try` functionality
of running a closure and determining whether it panicked or not.

There are two primary reasons that this function was previously marked `unsafe`:

1. A vanilla version of this function exposes the problem of exception safety by
   allowing a bare try/catch in the language. It is not clear whether this
   concern should be directly tied to `unsafe` in Rust at the API level. At this
   time, however, the bounds on `ffi::try` require the closure to be both
   `'static` and `Send` (mirroring those of `thread::spawn`). It may be possible
   to relax the bounds in the future, but for now it's the level of safety that
   we're willing to commit to.

2. Panicking while panicking will leak resources by not running destructors.
   Because panicking is still controlled by the standard library, safeguards
   remain in place to prevent this from happening.

The new API is now called `catch_panic` and is marked as `#[unstable]` for now.
2015-03-24 14:53:10 -07:00
Alex Crichton
5ed8733ea3 rollup merge of #23668: alexcrichton/io-zero
This commit alters the behavior of the `Read::read_to_end()` method to zero all
memory instead of passing an uninitialized buffer to `read`. This change is
motivated by the [discussion on the internals forum][discuss] where the
conclusion has been that the standard library will not expose uninitialized
memory.

[discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652

Closes #20314
2015-03-24 14:50:48 -07:00
Alex Crichton
020efc78f1 rollup merge of #23662: steveklabnik/gh23421
I assume since both shifts say the same thing, I should fix both of them, but then I realized I don't strictly know about left shift.

Fixes #23421

r? @pnkfelix
2015-03-24 14:50:48 -07:00
Alex Crichton
8a0bb42813 rollup merge of #23661: steveklabnik/any_docs
http://www.reddit.com/r/rust/comments/304q00/type_information_in_rust/cpp43lu
2015-03-24 14:50:48 -07:00
Alex Crichton
5c74ed912b rollup merge of #23659: GBGamer/master
For other permissions beside USR permissions, we need these constants.

fixes #23658
2015-03-24 14:50:47 -07:00
Alex Crichton
37d57e76fc rollup merge of #23646: steveklabnik/doc_file
This is pretty basic, but it's nice to have something.

r? @alexcrichton
2015-03-24 14:50:47 -07:00
Alex Crichton
a1d2e62c1f rollup merge of #23630: nrc/coerce-tidy
See notes on the first commit

Closes #18601

r? @nikomatsakis

cc @eddyb
2015-03-24 14:50:46 -07:00
Alex Crichton
6da0b9dedb rollup merge of #23629: liammonahan/master
Found a small typo on the Rust book "ownership" page.

Best,
Liam

r? @steveklabnik
2015-03-24 14:50:45 -07:00
Alex Crichton
61063459bb rollup merge of #23592: alexcrichton/tweak-at-exit
There have been some recent panics on the bots and this commit is an attempt to
appease them. Previously it was considered invalid to run `rt::at_exit` after
the handlers had already started running. Due to the multithreaded nature of
applications, however, it is not always possible to guarantee this. For example
[this program][ex] will show off the abort.

[ex]: https://gist.github.com/alexcrichton/56300b87af6fa554e52d

The semantics of the `rt::at_exit` function have been modified as such:

* It is now legal to call `rt::at_exit` at any time. The return value now
  indicates whether the closure was successfully registered or not. Callers must
  now decide what to do with this information.
* The `rt::at_exit` handlers will now be run for a fixed number of iterations.
  Common cases (such as the example shown) may end up registering a new handler
  while others are running perhaps once or twice, so this common condition is
  covered by re-running the handlers a fixed number of times, after which new
  registrations are forbidden.

Some usage of `rt::at_exit` was updated to handle these new semantics, but
deprecated or unstable libraries calling `rt::at_exit` were not updated.
2015-03-24 14:50:45 -07:00
Alex Crichton
f5b65c5c22 rollup merge of #23573: steveklabnik/doc_associated_types 2015-03-24 14:50:44 -07:00
Alex Crichton
8f6c879d2a rollup merge of #23282: nikomatsakis/fn-trait-inheritance
The primary motivation here is to sidestep #19032 -- for a time, I thought that we should improve coherence or otherwise extend the language, but I now think that any such changes will require more time to bake. In the meantime, inheritance amongst the fn traits is both logically correct *and* a simple solution to that obstacle. This change introduces inheritance and modifies the compiler so that it can properly generate impls for closures and fns.

Things enabled by this PR (but not included in this PR):

1. An impl of `FnMut` for `&mut F` where `F : FnMut` (https://github.com/rust-lang/rust/issues/23015).
2. A better version of `Thunk` I've been calling `FnBox`.

I did not include either of these in the PR because:

1. Adding the impls in 1 currently induces a coherence conflict with the pattern trait. This is interesting and merits some discussion.
2. `FnBox` deserves to be a PR of its own.

The main downside to this design is (a) the need to write impls by hand; (b) the possibility of implementing `FnMut` with different semantics from `Fn`, etc. Point (a) is minor -- in particular, it does not affect normal closure usage -- and could be addressed in the future in many ways (better defaults; convenient macros; specialization; etc). Point (b) is unfortunate but "just a bug" from my POV, and certainly not unique to these traits (c.f. Copy/Clone, PartialEq/Eq, etc). (Until we lift the feature-gate on implementing the Fn traits, in any case, there is room to correct both of these if we find a nice way.)

Note that I believe this change is reversible in the future if we decide on another course of action, due to the feature gate on implementing the `Fn` traits, though I do not (currently) think we should reverse it.

Fixes #18835.

r? @nrc
2015-03-24 14:50:44 -07:00
Erick Tryzelaar
9cabe273d3 syntax: Update #[derive(...)] to work with phantom and associated types
Closes #7671, #19839
2015-03-24 14:43:26 -07:00
Nick Cameron
7e3ee02006 Bug fixes 2015-03-25 10:37:03 +13:00
Felix S. Klock II
1955e05267 Unit tests for Issue 8142, collected into one file. 2015-03-24 22:27:24 +01:00
Felix S. Klock II
5b2e8693e4 Reject specialized Drop impls.
See Issue 8142 for discussion.

This makes it illegal for a Drop impl to be more specialized than the
original item.

So for example, all of the following are now rejected (when they would
have been blindly accepted before):

```rust
struct S<A> { ... };
impl Drop for S<i8> { ... } // error: specialized to concrete type

struct T<'a> { ... };
impl Drop for T<'static> { ... } // error: specialized to concrete region

struct U<A> { ... };
impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement

struct V<'a,'b>;
impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement
```

Due to examples like the above, this is a [breaking-change].

(The fix is to either remove the specialization from the `Drop` impl,
or to transcribe the requirements into the struct/enum definition;
examples of both are shown in the PR's fixed to `libstd`.)

----

This is likely to be the last thing blocking the removal of the
`#[unsafe_destructor]` attribute.

Includes two new error codes for the new dropck check.

Update run-pass tests to accommodate new dropck pass.

Update tests and docs to reflect new destructor restriction.

----

Implementation notes:

We identify Drop impl specialization by not being as parametric as the
struct/enum definition via unification.

More specifically:

 1. Attempt unification of a skolemized instance of the struct/enum
    with an instance of the Drop impl's type expression where all of
    the impl's generics (i.e. the free variables of the type
    expression) have been replaced with unification variables.

 2. If unification fails, then reject Drop impl as specialized.

 3. If unification succeeds, check if any of the skolemized
    variables "leaked" into the constraint set for the inference
    context; if so, then reject Drop impl as specialized.

 4. Otherwise, unification succeeded without leaking skolemized
    variables: accept the Drop impl.

We identify whether a Drop impl is injecting new predicates by simply
looking whether the predicate, after an appropriate substitution,
appears on the struct/enum definition.
2015-03-24 22:27:23 +01:00
Felix S. Klock II
290c8de0a6 Added T:Send bound to JoinGuard<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
5f57fd591d Added T:Send bound to Queue<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
123b5c124e Added T:Send bound to Packet<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
018eeb76f0 added T:Send bound to Mutex<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
1e71d2e71c Added W: Writer bound to BufferedWriter<W> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
1249e60891 Added T:Send bound to Queue<T> to avoid specialized Drop impl. 2015-03-24 22:27:23 +01:00
Felix S. Klock II
26a79e3c20 Added Write bounds to avoid a specialized Drop impl for BufWriter. 2015-03-24 22:27:22 +01:00
Felix S. Klock II
0adab507bb Added T:Send bound to sync::mpsc::Receiver and sync::mpsc::Sender.
This was necessary to avoid specialized `Drop` impls for the two structs.
2015-03-24 22:27:22 +01:00
Felix S. Klock II
5fa4b4c4af Remove unnecessary bounds from Drop impl for Arc and arc::Weak and
one of the helper method impls.
2015-03-24 22:27:22 +01:00
Erick Tryzelaar
d4701bd4fb test: silence a warning 2015-03-24 14:26:58 -07:00
Ulrik Sverdrup
547a48e193 collections: Update docs for slice since SliceExt was removed
A lot has changed since this doc text was last touched up, and this is
just a minor edit. I remove the trait section entirely since we don't
use extension traits that much anymore, so there are no significant
trait hilights for this module.
2015-03-24 22:23:13 +01:00
Ulrik Sverdrup
00e14f1622 core: Update docs for StrExt demotion in libstd
Main access point of .split() and other similar methods are not using
the StrExt trait anymore, so update the libcore docs to reflect this
(because these docs are visible in libstd API documentation).
2015-03-24 22:21:38 +01:00
Ulrik Sverdrup
227d30414c std: Update docs for removal of ReadExt, WriteExt 2015-03-24 22:20:35 +01:00
Erick Tryzelaar
a17f5563b8 syntax: Allow quotes to insert path 2015-03-24 14:18:39 -07:00