]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agorollup merge of #23690: wettowelreactor/patch-1
Alex Crichton [Fri, 27 Mar 2015 17:07:42 +0000 (10:07 -0700)]
rollup merge of #23690: wettowelreactor/patch-1

9 years agorollup merge of #23676: gkoz/array_as_ref
Alex Crichton [Fri, 27 Mar 2015 17:07:42 +0000 (10:07 -0700)]
rollup merge of #23676: gkoz/array_as_ref

r? @aturon

9 years agorollup merge of #23651: alexcrichton/unwind-try
Alex Crichton [Fri, 27 Mar 2015 17:07:42 +0000 (10:07 -0700)]
rollup merge of #23651: alexcrichton/unwind-try

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.

9 years agorollup merge of #23625: fhahn/issue-23620-ice-unicode-bytestring
Alex Crichton [Fri, 27 Mar 2015 17:07:41 +0000 (10:07 -0700)]
rollup merge of #23625: fhahn/issue-23620-ice-unicode-bytestring

closes #23620

This PR patches the issue mentioned in #23620, but there is also an ICE for invalid escape sequences in byte literals. This is due to the fact that the `scan_byte` function returns ` token::intern("??") ` for invalid bytes, resulting in an ICE later on. Is there a reason for this behavior? Shouldn't `scan_byte` fail when it encounters an invalid byte?

And I noticed a small inconsistency in the documentation. According to the formal byte literal definition in http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals , a byte string literal contains `string_body *`, but according to the text (and the behavior of the lexer) it should not accept unicode escape sequences. Hence it should be replaced by `byte_body *`. If this is valid, I can add this fix to this PR.

9 years agorollup merge of #23535: pnkfelix/fsk-filling-drop
Alex Crichton [Fri, 27 Mar 2015 17:07:41 +0000 (10:07 -0700)]
rollup merge of #23535: pnkfelix/fsk-filling-drop

Replace zeroing-on-drop with filling-on-drop.

This is meant to set the stage for removing *all* zeroing and filling (on drop) in the future.

Note that the code is meant to be entirely abstract with respect to the particular values used for the drop flags: the final commit demonstrates how to go from zeroing-on-drop to filling-on-drop by changing the value of three constants (in two files).

See further discussion on the internals thread:
  http://internals.rust-lang.org/t/attention-hackers-filling-drop/1715/11

[breaking-change] especially for structs / enums using `#[unsafe_no_drop_flag]`.

9 years agorollup merge of #23419: murarth/lookup-addr
Alex Crichton [Fri, 27 Mar 2015 17:07:40 +0000 (10:07 -0700)]
rollup merge of #23419: murarth/lookup-addr

Closes #22608

9 years agoPrevent ICEs when parsing invalid escapes, closes #23620
Florian Hahn [Thu, 26 Mar 2015 08:38:25 +0000 (09:38 +0100)]
Prevent ICEs when parsing invalid escapes, closes #23620

9 years agoAuto merge of #22930 - Gankro:entry_3, r=aturon
bors [Fri, 27 Mar 2015 12:55:23 +0000 (12:55 +0000)]
Auto merge of #22930 - Gankro:entry_3, r=aturon

RFC pending, but this is the patch that does it.

Totally untested. Likely needs some removed imports. std::collections docs should also be updated to provide better examples.

Closes #23508

9 years agodefault => or_insert per RFC
Alexis Beingessner [Fri, 20 Mar 2015 17:43:01 +0000 (13:43 -0400)]
default => or_insert per RFC

9 years agoupdate everything to use Entry defaults
Alexis [Sun, 1 Mar 2015 14:42:11 +0000 (09:42 -0500)]
update everything to use Entry defaults

9 years agoentry API v3: replace Entry::get with Entry::default and Entry::default_with
Alexis [Sun, 1 Mar 2015 14:50:08 +0000 (09:50 -0500)]
entry API v3: replace Entry::get with Entry::default and Entry::default_with

9 years agoAdd `std::net::lookup_addr` for reverse DNS lookup
Murarth [Mon, 16 Mar 2015 20:04:31 +0000 (13:04 -0700)]
Add `std::net::lookup_addr` for reverse DNS lookup

Closes #22608

9 years agoworkaround pretty-print bugs to placate `make check-pretty`.
Felix S. Klock II [Fri, 27 Mar 2015 00:07:27 +0000 (01:07 +0100)]
workaround pretty-print bugs to placate `make check-pretty`.

9 years agoAuto merge of #23359 - erickt:quote, r=pnkfelix
bors [Thu, 26 Mar 2015 18:43:56 +0000 (18:43 +0000)]
Auto merge of #23359 - erickt:quote, r=pnkfelix

This PR allows the quote macros to unquote trait items, impl items, where clauses, and paths.

9 years agoadd feature flags required post rebase.
Felix S. Klock II [Thu, 26 Mar 2015 18:31:53 +0000 (19:31 +0100)]
add feature flags required post rebase.

9 years agoAuto merge of #23680 - erickt:inline, r=cmr
bors [Thu, 26 Mar 2015 16:10:23 +0000 (16:10 +0000)]
Auto merge of #23680 - erickt:inline, r=cmr

before:

test bench_read_slice  ... bench:        68 ns/iter (+/- 56)
test bench_read_vec    ... bench:        78 ns/iter (+/- 21)
test bench_write_slice ... bench:       133 ns/iter (+/- 46)
test bench_write_vec   ... bench:       308 ns/iter (+/- 69)

after:

test bench_read_slice  ... bench:        32 ns/iter (+/- 10)
test bench_read_vec    ... bench:        32 ns/iter (+/- 8)
test bench_write_slice ... bench:        53 ns/iter (+/- 12)
test bench_write_vec   ... bench:       247 ns/iter (+/- 172)

9 years agoAuto merge of #21237 - erickt:derive-assoc-types, r=erickt
bors [Thu, 26 Mar 2015 13:38:41 +0000 (13:38 +0000)]
Auto merge of #21237 - erickt:derive-assoc-types, r=erickt

This PR adds support for associated types to the `#[derive(...)]` syntax extension. In order to do this, it switches over to using where predicates to apply the type constraints. So now this:

```rust
type Trait {
    type Type;
}

#[derive(Clone)]
struct Foo<A> where A: Trait {
    a: A,
    b: <A as Trait>::Type,
}
```

Gets expended into this impl:

```rust
impl<A: Clone> Clone for Foo<A> where
    A: Trait,
    <A as Trait>::Type: Clone,
{
    fn clone(&self) -> Foo<T> {
        Foo {
            a: self.a.clone(),
            b: self.b.clone(),
        }
    }
}
```

9 years agoAdd tests exercising the dropflag checking functionality.
Felix S. Klock II [Wed, 25 Mar 2015 15:49:21 +0000 (16:49 +0100)]
Add tests exercising the dropflag checking functionality.

9 years agoUse `-Z force-dropflag-checks=on/off` for emitting sanity-check.
Felix S. Klock II [Wed, 25 Mar 2015 10:57:55 +0000 (11:57 +0100)]
Use `-Z force-dropflag-checks=on/off` for emitting sanity-check.

(That is, added config and debugflag a la check-overflow but for drop
flag sanity-check.)

Remove now-unused import of NoDebugInfo from trans::glue.

9 years agoAdded instability markers to `POST_DROP_*` consts, and related opt-in's.
Felix S. Klock II [Wed, 25 Mar 2015 15:36:58 +0000 (16:36 +0100)]
Added instability markers to `POST_DROP_*` consts, and related opt-in's.

(Reviewed rest of code; did not see other `pub` items that needed such
treatment.)

Driveby: fix typo in comment in ptr.rs.

9 years agoA better `core::mem::dropped` implementation suggested by huonw on the PR.
Felix S. Klock II [Mon, 23 Mar 2015 22:52:21 +0000 (23:52 +0100)]
A better `core::mem::dropped` implementation suggested by huonw on the PR.

9 years agofilling-drop: switch `DTOR_NEEDED` and `DTOR_DONE` to non-trivial values.
Felix S. Klock II [Tue, 17 Mar 2015 23:20:52 +0000 (00:20 +0100)]
filling-drop: switch `DTOR_NEEDED` and `DTOR_DONE` to non-trivial values.

9 years agoRegression tests for issues uncovered only post the run-pass and compile-fail tests.
Felix S. Klock II [Wed, 11 Mar 2015 00:25:53 +0000 (01:25 +0100)]
Regression tests for issues uncovered only post the run-pass and compile-fail tests.

(I.e. the idea being, lets catch errors in these basic constructs
sometime *before* we start doing the doc tests.)

9 years agoSwitch drop-flag to `u8` to allow special tags to instrument state.
Felix S. Klock II [Tue, 10 Feb 2015 09:04:39 +0000 (10:04 +0100)]
Switch drop-flag to `u8` to allow special tags to instrument state.

Refactored code so that the drop-flag values for initialized
(`DTOR_NEEDED`) versus dropped (`DTOR_DONE`) are given explicit names.

Add `mem::dropped()` (which with `DTOR_DONE == 0` is semantically the
same as `mem::zeroed`, but the point is that it abstracts away from
the particular choice of value for `DTOR_DONE`).

Filling-drop needs to use something other than `ptr::read_and_zero`,
so I added such a function: `ptr::read_and_drop`.  But, libraries
should not use it if they can otherwise avoid it.

Fixes to tests to accommodate filling-drop.

9 years agoAuto merge of #23711 - alexcrichton:ip-addr, r=aturon
bors [Thu, 26 Mar 2015 09:43:35 +0000 (09:43 +0000)]
Auto merge of #23711 - alexcrichton:ip-addr, r=aturon

This commits adds back an `IpAddr` enum matching the `SocketAddr` enum, but
without a port. The enumeration is `#[unstable]`. The `lookup_host` function and
iterator are also destabilized behind a new feature gate due to questions around
the semantics of returning `SocketAddr` values.

9 years agoAuto merge of #23691 - richo:dedup-typeorigin-mergable, r=eddyb
bors [Thu, 26 Mar 2015 05:44:26 +0000 (05:44 +0000)]
Auto merge of #23691 - richo:dedup-typeorigin-mergable, r=eddyb

I've started on refactoring the error handling code to avoid the need to reparse generated errors in `span_*`, but would rather land this incrementally as one monolithic PR (and have un-fond memories of merge conflicts from various other monoliths)

r? @eddyb

9 years agoinfer: Drop pointless format! calls
Richo Healey [Wed, 25 Mar 2015 03:59:17 +0000 (20:59 -0700)]
infer: Drop pointless format! calls

9 years agoinfer: Refactor Display impl
Richo Healey [Wed, 25 Mar 2015 03:55:02 +0000 (20:55 -0700)]
infer: Refactor Display impl

9 years agoinfer: Move TypeOrigin formatting onto it's enum
Richo Healey [Thu, 19 Mar 2015 21:49:28 +0000 (14:49 -0700)]
infer: Move TypeOrigin formatting onto it's enum

This doesn't actually solve the issue that prompted this, at:

https://github.com/rust-lang/rust/blob/master/src/librustc/session/mod.rs#L262-271

But skimming the cfg it appears that all type information has been
discarded long before that point.

9 years agoAuto merge of #23718 - alexcrichton:flaky-test, r=huonw
bors [Thu, 26 Mar 2015 02:33:36 +0000 (02:33 +0000)]
Auto merge of #23718 - alexcrichton:flaky-test, r=huonw

It's considered an error to access stdout while a process is being shut down, so
tweak this test a bit to actually wait for the child thread to exit.

This was discovered with a recent [snap-mac3 failure](http://buildbot.rust-lang.org/builders/snap3-mac/builds/164/steps/test/logs/stdio)

9 years agostd: Add net::IpAddr, destabilize lookup_host
Alex Crichton [Wed, 25 Mar 2015 19:30:49 +0000 (12:30 -0700)]
std: Add net::IpAddr, destabilize lookup_host

This commits adds back an `IpAddr` enum matching the `SocketAddr` enum, but
without a port. The enumeration is `#[unstable]`. The `lookup_host` function and
iterator are also destabilized behind a new feature gate due to questions around
the semantics of returning `SocketAddr` values.

9 years agotest: Make a test less flaky
Alex Crichton [Wed, 25 Mar 2015 22:26:39 +0000 (15:26 -0700)]
test: Make a test less flaky

It's considered an error to access stdout while a process is being shut down, so
tweak this test a bit to actually wait for the child thread to exit.

9 years agoAuto merge of #23695 - sae-bom:mac-android-debuginfo, r=alexcrichton
bors [Wed, 25 Mar 2015 21:29:50 +0000 (21:29 +0000)]
Auto merge of #23695 - sae-bom:mac-android-debuginfo, r=alexcrichton

1. when mac-android cross compile and make-check , make it use gdb instead of lldb so as to it passes debuginfo tests.
2. ignore some tests on aarch64

9 years agoAuto merge of #23434 - alexcrichton:misc-stab, r=aturon
bors [Wed, 25 Mar 2015 18:59:00 +0000 (18:59 +0000)]
Auto merge of #23434 - alexcrichton:misc-stab, r=aturon

Now that we check the stability of fields, the fields of this struct should also
be stable.

9 years agoSpeed up reading/writing slices with #[inline]
Erick Tryzelaar [Wed, 25 Mar 2015 16:07:46 +0000 (09:07 -0700)]
Speed up reading/writing slices with #[inline]

When built with `rustc -O`:

before:

test bench_read_slice  ... bench:        68 ns/iter (+/- 56)
test bench_read_vec    ... bench:        78 ns/iter (+/- 21)
test bench_write_slice ... bench:       133 ns/iter (+/- 46)
test bench_write_vec   ... bench:       308 ns/iter (+/- 69)

after:

test bench_read_slice  ... bench:        32 ns/iter (+/- 10)
test bench_read_vec    ... bench:        32 ns/iter (+/- 8)
test bench_write_slice ... bench:        53 ns/iter (+/- 12)
test bench_write_vec   ... bench:       247 ns/iter (+/- 172)

9 years agoAuto merge of #23697 - Manishearth:rollup, r=Manishearth
bors [Wed, 25 Mar 2015 14:14:04 +0000 (14:14 +0000)]
Auto merge of #23697 - Manishearth:rollup, r=Manishearth

- Successful merges: #23617, #23664, #23680, #23684, #23692, #23693
- Failed merges:

9 years agoRollup merge of #23702 - dotdash:match_reass, r=eddyb
Manish Goregaokar [Wed, 25 Mar 2015 14:14:32 +0000 (19:44 +0530)]
Rollup merge of #23702 - dotdash:match_reass, r=eddyb

 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

9 years agoRollup merge of #23693 - semarie:openbsd-pathbuf-new, r=nikomatsakis
Manish Goregaokar [Wed, 25 Mar 2015 11:42:14 +0000 (17:12 +0530)]
Rollup merge of #23693 - semarie:openbsd-pathbuf-new, r=nikomatsakis

`PathBuf::new` have been changed. Use `PathBuf::from` instead.

Apply the same change for freebsd too, while here.

9 years agoRollup merge of #23692 - yjh0502:fix/simd-overflow, r=pnkfelix
Manish Goregaokar [Wed, 25 Mar 2015 11:42:14 +0000 (17:12 +0530)]
Rollup merge of #23692 - yjh0502:fix/simd-overflow, r=pnkfelix

Disable overflow checking on SIMD operations, fix #23037

9 years agoRollup merge of #23684 - tamird:ios-fallout, r=alexcrichton
Manish Goregaokar [Wed, 25 Mar 2015 11:42:13 +0000 (17:12 +0530)]
Rollup merge of #23684 - tamird:ios-fallout, r=alexcrichton

r? @aturon cc @alexcrichton

9 years agoAlways properly copy values into bindings when mutating the match discriminant
Björn Steinbrink [Wed, 25 Mar 2015 13:50:04 +0000 (14:50 +0100)]
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

9 years agoRollup merge of #23664 - bluss:std-docs, r=steveklabnik
Manish Goregaokar [Wed, 25 Mar 2015 11:42:13 +0000 (17:12 +0530)]
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.

9 years agoRollup merge of #23617 - steveklabnik:gh23564, r=Manishearth
Manish Goregaokar [Wed, 25 Mar 2015 11:42:13 +0000 (17:12 +0530)]
Rollup merge of #23617 - steveklabnik:gh23564, r=Manishearth

Fixes #23564

9 years agoIgnore some tests on aarch64
Sae-bom Kim [Wed, 25 Mar 2015 09:17:33 +0000 (18:17 +0900)]
Ignore some tests on aarch64

9 years agomake it use gdb instead of lldb when mac-android cross compile
Sae-bom Kim [Wed, 25 Mar 2015 09:12:35 +0000 (18:12 +0900)]
make it use gdb instead of lldb when mac-android cross compile

9 years agoAuto merge of #23670 - cmr:vec-push-slowpath, r=pcwalton
bors [Wed, 25 Mar 2015 07:47:30 +0000 (07:47 +0000)]
Auto merge of #23670 - cmr:vec-push-slowpath, r=pcwalton

Makes Vec::push considerably smaller: 25 instructions, rather than 42, on
x86_64.

9 years agounbreak bitrig/openbsd build after 8389253d
Sébastien Marie [Wed, 25 Mar 2015 07:42:15 +0000 (08:42 +0100)]
unbreak bitrig/openbsd build after 8389253d

`PathBuf::new` have been changed. Use `PathBuf::from` instead.

Apply the same change for freebsd too, while here.

9 years agoFix ICE on SIMD overflow checking
Jihyun Yu [Wed, 25 Mar 2015 06:17:10 +0000 (15:17 +0900)]
Fix ICE on SIMD overflow checking

Disable overflow checking on SIMD operations, fix #23037

9 years agoUpdate pointers.md
Camille Roussel [Wed, 25 Mar 2015 04:46:09 +0000 (21:46 -0700)]
Update pointers.md

9 years ago[iOS] Fallout from 8389253
Tamir Duberstein [Wed, 25 Mar 2015 01:48:14 +0000 (18:48 -0700)]
[iOS] Fallout from 8389253

9 years agoAuto merge of #23681 - alexcrichton:rollup, r=alexcrichton
bors [Wed, 25 Mar 2015 01:42:42 +0000 (01:42 +0000)]
Auto merge of #23681 - alexcrichton:rollup, r=alexcrichton

9 years agoTest fixes and rebase conflicts, round 2
Alex Crichton [Tue, 24 Mar 2015 23:55:35 +0000 (16:55 -0700)]
Test fixes and rebase conflicts, round 2

9 years agorollup merge of #23674: nagisa/fallout-1
Alex Crichton [Tue, 24 Mar 2015 23:53:38 +0000 (16:53 -0700)]
rollup merge of #23674: nagisa/fallout-1

9 years agoTest fixes and rebase conflicts, round 1
Alex Crichton [Tue, 24 Mar 2015 23:48:50 +0000 (16:48 -0700)]
Test fixes and rebase conflicts, round 1

9 years agoImplement AsRef and AsMut for fixed-sized arrays
Gleb Kozyrev [Tue, 24 Mar 2015 23:37:08 +0000 (01:37 +0200)]
Implement AsRef and AsMut for fixed-sized arrays

9 years agoAuto merge of #23546 - alexcrichton:hyphens, r=brson
bors [Tue, 24 Mar 2015 22:44:33 +0000 (22:44 +0000)]
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

9 years agoFix some fallout in librustdoc
Simonas Kazlauskas [Tue, 24 Mar 2015 22:39:29 +0000 (00:39 +0200)]
Fix some fallout in librustdoc

9 years agorollup merge of #23671: steveklabnik/doc_std_clone
Alex Crichton [Tue, 24 Mar 2015 22:27:16 +0000 (15:27 -0700)]
rollup merge of #23671: steveklabnik/doc_std_clone

9 years agorollup merge of #23638: pnkfelix/fsk-reject-specialized-drops
Alex Crichton [Tue, 24 Mar 2015 22:27:14 +0000 (15:27 -0700)]
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

9 years agorollup merge of #23546: alexcrichton/hyphens
Alex Crichton [Tue, 24 Mar 2015 21:56:00 +0000 (14:56 -0700)]
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

9 years agorustc: Add support for `extern crate foo as bar`
Alex Crichton [Thu, 19 Mar 2015 22:39:03 +0000 (15:39 -0700)]
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

9 years agostd: Reexport std::rt::unwind::try in std::thread
Alex Crichton [Mon, 23 Mar 2015 21:25:56 +0000 (14:25 -0700)]
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.

9 years agorollup merge of #23668: alexcrichton/io-zero
Alex Crichton [Tue, 24 Mar 2015 21:50:48 +0000 (14:50 -0700)]
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

9 years agorollup merge of #23662: steveklabnik/gh23421
Alex Crichton [Tue, 24 Mar 2015 21:50:48 +0000 (14:50 -0700)]
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

9 years agorollup merge of #23661: steveklabnik/any_docs
Alex Crichton [Tue, 24 Mar 2015 21:50:48 +0000 (14:50 -0700)]
rollup merge of #23661: steveklabnik/any_docs

http://www.reddit.com/r/rust/comments/304q00/type_information_in_rust/cpp43lu

9 years agorollup merge of #23659: GBGamer/master
Alex Crichton [Tue, 24 Mar 2015 21:50:47 +0000 (14:50 -0700)]
rollup merge of #23659: GBGamer/master

For other permissions beside USR permissions, we need these constants.

fixes #23658

9 years agorollup merge of #23646: steveklabnik/doc_file
Alex Crichton [Tue, 24 Mar 2015 21:50:47 +0000 (14:50 -0700)]
rollup merge of #23646: steveklabnik/doc_file

This is pretty basic, but it's nice to have something.

r? @alexcrichton

9 years agorollup merge of #23630: nrc/coerce-tidy
Alex Crichton [Tue, 24 Mar 2015 21:50:46 +0000 (14:50 -0700)]
rollup merge of #23630: nrc/coerce-tidy

See notes on the first commit

Closes #18601

r? @nikomatsakis

cc @eddyb

9 years agorollup merge of #23629: liammonahan/master
Alex Crichton [Tue, 24 Mar 2015 21:50:45 +0000 (14:50 -0700)]
rollup merge of #23629: liammonahan/master

Found a small typo on the Rust book "ownership" page.

Best,
Liam

r? @steveklabnik

9 years agorollup merge of #23592: alexcrichton/tweak-at-exit
Alex Crichton [Tue, 24 Mar 2015 21:50:45 +0000 (14:50 -0700)]
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.

9 years agorollup merge of #23573: steveklabnik/doc_associated_types
Alex Crichton [Tue, 24 Mar 2015 21:50:44 +0000 (14:50 -0700)]
rollup merge of #23573: steveklabnik/doc_associated_types

9 years agorollup merge of #23282: nikomatsakis/fn-trait-inheritance
Alex Crichton [Tue, 24 Mar 2015 21:50:44 +0000 (14:50 -0700)]
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

9 years agosyntax: Update #[derive(...)] to work with phantom and associated types
Erick Tryzelaar [Tue, 24 Mar 2015 21:43:26 +0000 (14:43 -0700)]
syntax: Update #[derive(...)] to work with phantom and associated types

Closes #7671, #19839

9 years agoBug fixes
Nick Cameron [Tue, 24 Mar 2015 00:50:14 +0000 (13:50 +1300)]
Bug fixes

9 years agoUnit tests for Issue 8142, collected into one file.
Felix S. Klock II [Tue, 24 Mar 2015 09:46:40 +0000 (10:46 +0100)]
Unit tests for Issue 8142, collected into one file.

9 years agoReject specialized Drop impls.
Felix S. Klock II [Sat, 21 Mar 2015 12:12:08 +0000 (13:12 +0100)]
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.

9 years agoAdded `T:Send` bound to `JoinGuard<T>` to avoid specialized `Drop` impl.
Felix S. Klock II [Sat, 21 Mar 2015 12:34:33 +0000 (13:34 +0100)]
Added `T:Send` bound to `JoinGuard<T>` to avoid specialized `Drop` impl.

9 years agoAdded `T:Send` bound to `Queue<T>` to avoid specialized `Drop` impl.
Felix S. Klock II [Sat, 21 Mar 2015 12:33:12 +0000 (13:33 +0100)]
Added `T:Send` bound to `Queue<T>` to avoid specialized `Drop` impl.

9 years agoAdded `T:Send` bound to `Packet<T>` to avoid specialized `Drop` impl.
Felix S. Klock II [Sat, 21 Mar 2015 12:31:58 +0000 (13:31 +0100)]
Added `T:Send` bound to `Packet<T>` to avoid specialized `Drop` impl.

9 years agoadded `T:Send` bound to `Mutex<T>` to avoid specialized Drop impl.
Felix S. Klock II [Sat, 21 Mar 2015 12:30:26 +0000 (13:30 +0100)]
added `T:Send` bound to `Mutex<T>` to avoid specialized Drop impl.

9 years agoAdded `W: Writer` bound to `BufferedWriter<W>` to avoid specialized `Drop` impl.
Felix S. Klock II [Sat, 21 Mar 2015 12:28:20 +0000 (13:28 +0100)]
Added `W: Writer` bound to `BufferedWriter<W>` to avoid specialized `Drop` impl.

9 years agoAdded `T:Send` bound to `Queue<T>` to avoid specialized Drop impl.
Felix S. Klock II [Sat, 21 Mar 2015 12:22:21 +0000 (13:22 +0100)]
Added `T:Send` bound to `Queue<T>` to avoid specialized Drop impl.

9 years agoAdded `Write` bounds to avoid a specialized Drop impl for `BufWriter`.
Felix S. Klock II [Sat, 21 Mar 2015 12:20:12 +0000 (13:20 +0100)]
Added `Write` bounds to avoid a specialized Drop impl for `BufWriter`.

9 years agoAdded `T:Send` bound to `sync::mpsc::Receiver` and `sync::mpsc::Sender`.
Felix S. Klock II [Sat, 21 Mar 2015 12:14:28 +0000 (13:14 +0100)]
Added `T:Send` bound to `sync::mpsc::Receiver` and `sync::mpsc::Sender`.

This was necessary to avoid specialized `Drop` impls for the two structs.

9 years agoRemove unnecessary bounds from Drop impl for `Arc` and `arc::Weak` and
Felix S. Klock II [Sat, 21 Mar 2015 12:13:07 +0000 (13:13 +0100)]
Remove unnecessary bounds from Drop impl for `Arc` and `arc::Weak` and
one of the helper method impls.

9 years agotest: silence a warning
Erick Tryzelaar [Wed, 14 Jan 2015 16:16:35 +0000 (08:16 -0800)]
test: silence a warning

9 years agocollections: Update docs for slice since SliceExt was removed
Ulrik Sverdrup [Tue, 24 Mar 2015 18:47:00 +0000 (19:47 +0100)]
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.

9 years agocore: Update docs for StrExt demotion in libstd
Ulrik Sverdrup [Tue, 24 Mar 2015 18:57:49 +0000 (19:57 +0100)]
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).

9 years agostd: Update docs for removal of ReadExt, WriteExt
Ulrik Sverdrup [Tue, 24 Mar 2015 18:37:52 +0000 (19:37 +0100)]
std: Update docs for removal of ReadExt, WriteExt

9 years agosyntax: Allow quotes to insert path
Erick Tryzelaar [Sat, 14 Mar 2015 07:20:30 +0000 (00:20 -0700)]
syntax: Allow quotes to insert path

9 years agosyntax: Allow where strings to be parsed independent from generics
Erick Tryzelaar [Sat, 14 Mar 2015 05:22:04 +0000 (22:22 -0700)]
syntax: Allow where strings to be parsed independent from generics

This allows quasiquoting to insert where clauses.

9 years agosyntax: add {trait_item,impl_item,where_clause}_to_string
Erick Tryzelaar [Sat, 14 Mar 2015 04:54:29 +0000 (21:54 -0700)]
syntax: add {trait_item,impl_item,where_clause}_to_string

9 years agolibcollections: move Vec::push slow path out
Corey Richardson [Tue, 24 Mar 2015 20:17:15 +0000 (16:17 -0400)]
libcollections: move Vec::push slow path out

Makes Vec::push considerably smaller: 25 instructions, rather than 42, on
x86_64.

9 years agoChange lint names to plurals
Nick Cameron [Mon, 23 Mar 2015 22:23:34 +0000 (11:23 +1300)]
Change lint names to plurals

9 years agoAdd tests
Nick Cameron [Mon, 23 Mar 2015 04:28:57 +0000 (17:28 +1300)]
Add tests

9 years agoRemove the UnusedCasts lint
Nick Cameron [Mon, 23 Mar 2015 02:50:32 +0000 (15:50 +1300)]
Remove the UnusedCasts lint

9 years agoMinor refactoring in coercion.rs
Nick Cameron [Mon, 23 Mar 2015 02:26:51 +0000 (15:26 +1300)]
Minor refactoring in coercion.rs

9 years agoAdd trivial cast lints.
Nick Cameron [Fri, 20 Mar 2015 04:15:27 +0000 (17:15 +1300)]
Add trivial cast lints.

This permits all coercions to be performed in casts, but adds lints to warn in those cases.

Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference.

[breaking change]

* Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed.
* The unused casts lint has gone.
* Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are:
- You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_`
- Casts do not influence inference of integer types. E.g., the following used to type check:

```
let x = 42;
let y = &x as *const u32;
```

Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information:

```
let x: u32 = 42;
let y = &x as *const u32;
```

9 years agoAn example for clone
Steve Klabnik [Tue, 24 Mar 2015 20:58:08 +0000 (16:58 -0400)]
An example for clone

9 years agostd: Zero memory when calling `read_to_end()`
Alex Crichton [Tue, 24 Mar 2015 18:14:35 +0000 (11:14 -0700)]
std: Zero memory when calling `read_to_end()`

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