Commit Graph

36711 Commits

Author SHA1 Message Date
Aaron Turon
c9f600bcee Stabilize some stragglers in std::option
Marks as `#[stable}`:

* `ok_or`
* `ok_or_else`
* `iter_mut`
* `cloned`

Similarly to `IteratorExt::cloned`, the `cloned` method is pared down to
work only on `Option<&T>`. Thus, this is a:

[breaking-change]
2015-03-26 17:47:13 -07:00
Murarth
c0dd239753 Add std::net::lookup_addr for reverse DNS lookup
Closes #22608
2015-03-26 17:13:14 -07:00
Felix S. Klock II
b68ca84ef1 workaround pretty-print bugs to placate make check-pretty. 2015-03-27 01:07:27 +01:00
Alex Crichton
e71221f327 std: Stabilize BufRead::split
Now that `<[_]>::split` is an inherent method, it will trump `BufRead::split`
when `BufRead` is in scope, so there is no longer a conflict. As a result,
calling `slice.split()` will probably always give you precisely what you want!
2015-03-26 16:54:15 -07:00
Tshepang Lekhonkhobe
ce668a873e book: fix typo 2015-03-27 01:44:03 +02:00
Alex Crichton
4f419d9668 rustc: Remove support for -l foo:static
This syntax has been renamed to `-l static=foo` some time ago.
2015-03-26 16:42:22 -07:00
Tshepang Lekhonkhobe
4357621ca9 book: there is no guessing game anymore, so remove references to it 2015-03-27 01:35:50 +02:00
Brian Anderson
cbef22e242 Update rust-installer. Fixes --help and interop with NixOS 2015-03-26 16:09:46 -07:00
Alex Crichton
671d896294 rustc: Remove old #[phase] and #[plugin]
This commit removes the extra deprecation warnings and support for the old
`phase` and `plugin` attributes for loading plugins.
2015-03-26 15:43:42 -07:00
Niko Matsakis
710af0498d Refactor object-safety test to use def-ids only 2015-03-26 17:52:39 -04:00
Niko Matsakis
703308db4a Refactor how binders are handled in trait selection 2015-03-26 17:52:38 -04:00
Niko Matsakis
c59fe8bde2 Drive-by fix for incorrect variance rule that I noticed. 2015-03-26 17:52:38 -04:00
Niko Matsakis
9c9bb9ce1d Implement Reflect trait with a variant on the standard OIBIT
semantics that tests the *interface* of trait objects, rather
than what they close over.
2015-03-26 17:52:38 -04:00
Gary M. Josack
5123bf40a1 Update docs to fix various 404s
Found a few 404s that seemed like simple fixes:

The Result docs use old_io Writer as an example. Fix the link to old_io Writer. There's probably an effort to update the example away from a deprecated api but this was a simple fix.

rustc/plugin was pointing at the old guide and it was a broken link anyways (plugin vs plugins). Point at the book instead.

The main page of the API docs referenced c_{str,vec}. Looks like these were deleted in 25d5a3a194. Point at ffi docs instead.
2015-03-26 14:46:06 -07:00
Aaron Turon
e7525cf620 Revise use of conversion traits
This commit revises `path` and `os_str` to use blanket impls for `From`
on reference types. This both cuts down on the number of required impls,
and means that you can pass through e.g. `T: AsRef<OsStr>` to
`PathBuf::from` without an intermediate call to `as_ref`.

It also makes a FIXME note for later generalizing the blanket impls for
`AsRef` and `AsMut` to use `Deref`/`DerefMut`, once it is possible to do
so.
2015-03-26 13:54:48 -07:00
Alex Crichton
3752958e40 syntax: Remove support for #[should_fail]
This attribute has been deprecated in favor of #[should_panic]. This also
updates rustdoc to no longer accept the `should_fail` directive and instead
renames it to `should_panic`.
2015-03-26 13:53:52 -07:00
Tshepang Lekhonkhobe
07afd04d34 book: let grow() accept the growth parameter 2015-03-26 22:38:19 +02:00
Murarth
1c43e53c8f impl FromStr for IpAddr 2015-03-26 13:31:37 -07:00
Alex Crichton
9754b06cd8 rustc: Remove support for old_impl_check
This commit removes compiler support for the `old_impl_check` attribute which
should in theory be entirely removed now. The last remaining use of it in the
standard library has been updated by moving the type parameter on the
`old_io::Acceptor` trait into an associated type. As a result, this is a
breaking change for all current users of the deprecated `old_io::Acceptor`
trait. Code can be migrated by using the `Connection` associated type instead.

[breaking-change]
2015-03-26 13:25:33 -07:00
Tshepang Lekhonkhobe
3e100ff038 book: make it one sentence 2015-03-26 22:10:59 +02:00
Or Neeman
dac552f255 doc: change 0u32..10 to 0..10 2015-03-26 13:24:20 -06:00
Alex Crichton
43bfaa4a33 Mass rename uint/int to usize/isize
Now that support has been removed, all lingering use cases are renamed.
2015-03-26 12:10:22 -07:00
Adenilson Cavalcanti
7d3bf47323 Adding more information about the behavior of Arc/Rc
when you perform a clone() call.
2015-03-26 12:05:21 -07:00
bors
53a183f027 Auto merge of #23359 - erickt:quote, r=pnkfelix
This PR allows the quote macros to unquote trait items, impl items, where clauses, and paths.
2015-03-26 18:43:56 +00:00
Felix S. Klock II
e2cc8b1436 add feature flags required post rebase. 2015-03-26 19:31:53 +01:00
Alex Crichton
77de3ee6e5 syntax: Remove parsing of old slice syntax
This syntax has been deprecated for quite some time, and there were only a few
remaining uses of it in the codebase anyway.
2015-03-26 10:24:44 -07:00
Alex Crichton
36ef29abf7 Register new snapshots 2015-03-26 09:57:05 -07:00
bors
199bdcfeff 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)
2015-03-26 16:10:23 +00:00
Steve Klabnik
c153fc1da1 New section of the book: nightly rust
Now that feature flags are only on nightly, it's good to split this stuff out.
2015-03-26 11:42:45 -04:00
Erick Tryzelaar
c5b8763753 Deprecate as_mut_slice methods
This is technically a breaking change as it deprecates and unstables
some previously stable apis that were missed in the last round of
deprecations.

[breaking change]
2015-03-26 07:29:06 -07:00
bors
557d4346a2 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(),
        }
    }
}
```
2015-03-26 13:38:41 +00:00
Felix S. Klock II
aab4bef939 Add tests exercising the dropflag checking functionality. 2015-03-26 14:08:55 +01:00
Felix S. Klock II
4053b00112 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.
2015-03-26 14:08:55 +01:00
Felix S. Klock II
601eca3b53 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.
2015-03-26 14:08:55 +01:00
Felix S. Klock II
5733726508 A better core::mem::dropped implementation suggested by huonw on the PR. 2015-03-26 14:08:55 +01:00
Felix S. Klock II
5bc35b1852 filling-drop: switch DTOR_NEEDED and DTOR_DONE to non-trivial values. 2015-03-26 14:08:55 +01:00
Felix S. Klock II
7c671e5177 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.)
2015-03-26 14:08:54 +01:00
Felix S. Klock II
3902190ac4 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.
2015-03-26 14:08:54 +01:00
bors
1501f33e76 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.
2015-03-26 09:43:35 +00:00
bors
b0fd67b3e7 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
2015-03-26 05:44:26 +00:00
Richo Healey
c193fe4f3c infer: Drop pointless format! calls 2015-03-25 21:44:22 -07:00
Richo Healey
e15bebfefa infer: Refactor Display impl 2015-03-25 21:44:21 -07:00
Richo Healey
385b5a3a7d 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.
2015-03-25 21:44:21 -07:00
bors
d4ba1caa99 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)
2015-03-26 02:33:36 +00:00
Tamir Duberstein
d9d2236b09 Add iOS triple mapping so tests can run 2015-03-25 18:18:34 -07:00
Tamir Duberstein
71386e5774 Alphabetize 2015-03-25 18:18:30 -07:00
Alex Crichton
54f16b818b rustc: Remove support for int/uint
This commit removes all parsing, resolve, and compiler support for the old and
long-deprecated int/uint types.
2015-03-25 16:39:00 -07:00
Alex Crichton
8165bc14fb 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.
2015-03-25 16:18:31 -07:00
Alex Crichton
02c6f6b049 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.
2015-03-25 15:26:39 -07:00
bors
27901849e0 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
2015-03-25 21:29:50 +00:00
bors
a3b13610c5 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.
2015-03-25 18:59:00 +00:00
Erick Tryzelaar
92e72ee15e 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)
2015-03-25 09:07:46 -07:00
Manish Goregaokar
e962a1d51e 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
2015-03-25 19:44:32 +05:30
Manish Goregaokar
2354fc9fac 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.
2015-03-25 19:44:08 +05:30
Manish Goregaokar
4283b2ab50 Rollup merge of #23692 - yjh0502:fix/simd-overflow, r=pnkfelix
Disable overflow checking on SIMD operations, fix #23037
2015-03-25 19:44:08 +05:30
Manish Goregaokar
5a5845dc01 Rollup merge of #23684 - tamird:ios-fallout, r=alexcrichton
r? @aturon cc @alexcrichton
2015-03-25 19:44:08 +05:30
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
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
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
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
Erick Tryzelaar
4ec07ed29a syntax: Allow where strings to be parsed independent from generics
This allows quasiquoting to insert where clauses.
2015-03-24 14:18:39 -07:00
Erick Tryzelaar
c3f4fba9cc syntax: add {trait_item,impl_item,where_clause}_to_string 2015-03-24 14:18:39 -07:00
Corey Richardson
0e838f749f libcollections: move Vec::push slow path out
Makes Vec::push considerably smaller: 25 instructions, rather than 42, on
x86_64.
2015-03-24 17:12:58 -04:00
Nick Cameron
e7122a5a09 Change lint names to plurals 2015-03-25 10:06:13 +13:00
Nick Cameron
dc206a91c8 Add tests 2015-03-25 10:06:13 +13:00
Nick Cameron
088cd566ea Remove the UnusedCasts lint 2015-03-25 10:06:13 +13:00
Nick Cameron
9374c216f6 Minor refactoring in coercion.rs 2015-03-25 10:06:13 +13:00
Nick Cameron
95602a759d 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;
```
2015-03-25 10:03:57 +13:00
Steve Klabnik
406524682b An example for clone 2015-03-24 16:58:08 -04:00
Alex Crichton
4ccf374b4a 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
2015-03-24 13:42:19 -07:00
Steve Klabnik
528a5e2bae Add examples for std::ascii
Also tweaked a few things.
2015-03-24 15:47:47 -04:00
Alex Crichton
d252d0ad54 Test fixes and rebase conflicts, round 4 2015-03-24 10:23:47 -07:00
Steve Klabnik
f2e0810cb8 correct reference wrt shifts
Fixes #23421
2015-03-24 12:58:50 -04:00
Steve Klabnik
0031d57a21 Clean up Any's title line
http://www.reddit.com/r/rust/comments/304q00/type_information_in_rust/cpp43lu
2015-03-24 12:15:49 -04:00
Steve Klabnik
f2996c0c0e Add basic information about associated types 2015-03-24 12:10:01 -04:00
Steve Klabnik
a34e87f3ab Add Examples for File
This is pretty basic, but it's nice to have something.
2015-03-24 10:52:46 -04:00
Nicholas Mazzuca
a9b31969dc Add the other S_I(RWX)(GRP/OTH) for posix creat 2015-03-24 03:25:48 -07:00
Alex Crichton
c5c3de0cf4 Test fixes and rebase conflicts, round 3 2015-03-23 22:52:21 -07:00
Liam Monahan
37dc801fe6 Improve the wording of the example section description on the ownership page
to make it more clear.
2015-03-23 21:19:54 -04:00
Alex Crichton
253992eb38 rollup merge of #23653: dhuseby/bitrig-stage0-c64d671
@alexcrichton this adds the latest Bitrig snapshot.  Please upload the corresponding snapshot: https://github.com/dhuseby/rust-cross-bitrig/blob/master/snapshots/rust-stage0-2015-03-17-c64d671-bitrig-x86_64-41de2c7a69a1ac648d3fa3b65e96a29bdc122163.tar.bz2
2015-03-23 17:13:39 -07:00
Alex Crichton
1588caca61 rollup merge of #23652: alexcrichton/stabilize-hasher-finish
This commit enables writing a stable implementation of the `Hasher` trait as
well as actually calculating the hash of a vlaue in a stable fashion. The
signature is stabilized as-is.
2015-03-23 17:13:38 -07:00
Alex Crichton
7380b6ffc8 rollup merge of #23645: steveklabnik/gh23642
Fixes #23642
2015-03-23 17:13:38 -07:00
Alex Crichton
6a44f24b9e rollup merge of #23644: mbrubeck/doc-edit
PR #23104 moved `is_null` and `offset` to an inherent impl on the raw pointer type.

I'm not sure whether or how it's possible to link to docs for that impl.

r? @steveklabnik
2015-03-23 17:13:37 -07:00
Alex Crichton
29b54387b8 Test fixes and rebase conflicts, round 2 2015-03-23 17:10:19 -07:00
Niko Matsakis
9330bae4bd Fallout from changing fn traits to use inheritance rather than bridge
impls. This is a [breaking-change] (for gated code) in that when you
implement `Fn` (`FnMut`) you must also implement `FnOnce`. This commit
demonstrates how to fix it.
2015-03-23 19:57:30 -04:00
Dave Huseby
3a0c15f3cf adding lastest Bitrig snapshot by hand 2015-03-23 15:58:44 -07:00
Matt Brubeck
3f52d719dc Update docs for ptr module.
PR #23104 moved `is_null` and `offset` to an inherent impl on the raw pointer
type.
2015-03-23 15:57:20 -07:00
bors
28a0b25f42 Auto merge of #23536 - pnkfelix:arith-oflo-shifts, r=nikomatsakis
overflow-checking for rhs of shift operators

Subtask of #22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
2015-03-23 22:43:39 +00:00
Alex Crichton
3112716f12 rollup merge of #23506: alexcrichton/remove-some-deprecated-things
Conflicts:
	src/test/run-pass/deprecated-no-split-stack.rs
2015-03-23 15:27:06 -07:00
Alex Crichton
aea822626f rollup merge of #23503: alexcrichton/fix-ptr-docs
The method with which backwards compatibility was retained ended up leading to
documentation that rustdoc didn't handle well and largely ended up confusing.
2015-03-23 15:26:24 -07:00
Alex Crichton
6e0f1d3984 rollup merge of #23484: alexcrichton/marker-trait-stable
This trait has proven quite useful when defining marker traits to avoid the
semi-confusing `PhantomFn` trait and it looks like it will continue to be a
useful tool for defining these traits.
2015-03-23 15:26:24 -07:00
Alex Crichton
04e667a6b1 Test fixes and rebase conflicts, round 1 2015-03-23 15:18:40 -07:00
Alex Crichton
7d07f70ccb rollup merge of #23383: alexcrichton/fs-create-dir-all
Conflicts:
	src/libstd/fs/mod.rs
2015-03-23 15:18:24 -07:00
Alex Crichton
c608084ff5 rollup merge of #23598: brson/gate
Conflicts:
	src/compiletest/compiletest.rs
	src/libcollections/lib.rs
	src/librustc_back/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
	src/libtest/lib.rs
	src/test/run-make/rustdoc-default-impl/foo.rs
	src/test/run-pass/env-home-dir.rs
2015-03-23 15:13:15 -07:00
Alex Crichton
7101ff4513 rollup merge of #23648: steveklabnik/rollup
- Successful merges: #22954, #23119, #23509, #23561, #23590, #23607, #23608, #23618, #23622, #23639, #23641
- Failed merges: #23401
2015-03-23 15:11:15 -07:00
Alex Crichton
fcf2ba794e rollup merge of #23641: steveklabnik/gh23632
Fixes #23632
2015-03-23 15:11:13 -07:00
Alex Crichton
8a15868206 rollup merge of #23640: nagisa/thread-less-weak
This is more portable as far as linux is concerned.
2015-03-23 15:11:12 -07:00
Alex Crichton
5e06ebbfc0 rollup merge of #23639: steveklabnik/gh21305
Fixes #21305

Not sure if we should include more than this here, but it should be good to have at least this.
2015-03-23 15:11:10 -07:00
Alex Crichton
ca7f7cf3d3 rollup merge of #23637: apasel422/iter 2015-03-23 15:11:09 -07:00
Alex Crichton
c7509bb8d8 rollup merge of #23634: WiSaGaN/bugfix/fix_dead_link 2015-03-23 15:11:07 -07:00
Alex Crichton
19510ac70b rollup merge of #23633: tomjakubowski/rustdoc-array-prim
Previously, impls for `[T; n]` were collected in the same place as impls for `[T]` and `&[T]`. This splits them out into their own primitive page in both core and std.
2015-03-23 15:11:06 -07:00
Alex Crichton
28fcdc0df7 rollup merge of #23631: andersk/minstack-dlsym
Linking `__pthread_get_minstack`, even weakly, was causing Debian’s `dpkg-shlibdeps` to detect an unnecessarily strict versioned dependency on libc6.

Closes #23628.
2015-03-23 15:11:05 -07:00
Alex Crichton
ef07e0797f rollup merge of #23622: steveklabnik/gh23196
Fixes #23196
2015-03-23 15:11:03 -07:00
Alex Crichton
b03939bfab rollup merge of #23619: steveklabnik/gh23220
Fixes #23571

I _think_ this is better, but other suggestions welcome too.
2015-03-23 15:11:02 -07:00
Alex Crichton
a78eb53074 rollup merge of #23618: steveklabnik/gh23571
Fixes #23571
2015-03-23 15:11:00 -07:00
Alex Crichton
5a6a90508d rollup merge of #23615: steveklabnik/gh23540
Closes #23540
2015-03-23 15:10:58 -07:00
Alex Crichton
010895e4f2 rollup merge of #23612: dotdash/closure_bloat
For the rust-call ABI, the last function argument is a tuple that gets
untupled for the actual call. For bare functions using this ABI, the
code has access to the tuple, so we need to tuple the arguments again.
But closures can't actually access the tuple. Their arguments map to the
elements in the tuple. So what we currently do is to tuple the arguments
and then immediately untuple them again, which is pretty useless and we
can just omit it.
2015-03-23 15:10:57 -07:00
Alex Crichton
c99970783a rollup merge of #23608: nagisa/refine-cursor-docstring
r? @steveklabnik
2015-03-23 15:10:55 -07:00
Alex Crichton
71c705db02 rollup merge of #23607: mahkoh/cursor
Closes #23599

r? @alexcrichton
2015-03-23 15:10:53 -07:00
Alex Crichton
68fb3acd85 rollup merge of #23604: apasel422/btree
`btree_map::IntoIter` (and `btree_set::IntoIter`) remains, but it is a bit trickier.
2015-03-23 15:10:51 -07:00
Alex Crichton
753efb5042 rollup merge of #23601: nikomatsakis/by-value-index
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`.

r? @japaric
cc @aturon @Gankro
2015-03-23 15:10:50 -07:00
Alex Crichton
bed77408df rollup merge of #23580: nikomatsakis/pattern-and-overflow 2015-03-23 15:10:30 -07:00
Alex Crichton
9e347b39f1 rollup merge of #23579: Ms2ger/thread_local-unsafe
Conflicts:
	src/libstd/thread/local.rs
2015-03-23 15:10:13 -07:00
Alex Crichton
88ae218578 rollup merge of #23561: steveklabnik/gh23422
Fixes #23422
2015-03-23 15:09:10 -07:00
Alex Crichton
2153c581ef rollup merge of #23557: aturon/rfc-909
This commit implements [RFC 909](https://github.com/rust-lang/rfcs/pull/909):

The `std::thread_local` module is now deprecated, and its contents are
available directly in `std::thread` as `LocalKey`, `LocalKeyState`, and
`ScopedKey`.

The macros remain exactly as they were, which means little if any code
should break. Nevertheless, this is technically a:

[breaking-change]

Closes #23547
2015-03-23 15:09:09 -07:00
Alex Crichton
b97e1cc28e rollup merge of #23541: aturon/stab-error
This small commit stabilizes the `Error` trait as-is, except that `Send`
and `Debug` are added as constraints. The `Send` constraint is because
most uses of `Error` will be for trait objects, and by default we would
like these objects to be transferrable between threads. The `Debug`
constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because
types that implement `Display` should certainly implement `Debug` in any case.

In the near future we expect to add `Any`-like downcasting features to
`Error`, but this is waiting on some additional
mechanisms (`Reflect`). It will be added before 1.0 via default methods.

[breaking-change]

r? @alexcrichton

Closes #21790
2015-03-23 15:09:08 -07:00
Alex Crichton
fd13400627 rollup merge of #23538: aturon/conversion
Conflicts:
	src/librustc_back/rpath.rs
2015-03-23 15:09:05 -07:00
Alex Crichton
c77af69a37 rollup merge of #23536: pnkfelix/arith-oflo-shifts
overflow-checking for rhs of shift operators

Subtask of #22020 ([RFC 560](https://github.com/rust-lang/rfcs/blob/master/text/0560-integer-overflow.md))
2015-03-23 15:08:17 -07:00
Alex Crichton
68cf9e09c2 rollup merge of #23517: vhbit/ext-socket-options
Continuation of #23380 - added corresponding constants for Windows, Linux, *BSDs

r? @alexcrichton

Alex, can you also cc to a person who can check correctness for Windows as I'm not that confident in header file I've downloaded.
2015-03-23 15:08:15 -07:00
Alex Crichton
0678f0b10c rollup merge of #23515: nikomatsakis/issue-14985-trait-subtyping
Remove incorrect subtyping for `&mut Trait` and introduce coercion for `&mut (Trait+'a)` to `&mut (Trait+'b)` if `'a:'b`.

Fixes #14985.

r? @nrc
2015-03-23 15:08:13 -07:00
Alex Crichton
4f7437647f rollup merge of #23466: woehr/master
This fixes a bug in LLVM IR generation for in-line assembly where Rust would always use the host clobbers instead of target clobbers.

I also took this opportunity to clean/simplify the ```trans_inline_asm``` function.

This is my first Rust pull request; please let me know if I'm missing anything.
2015-03-23 15:08:10 -07:00
Alex Crichton
d3fbc149b3 rollup merge of #23401: tshepang/crates-and-modules-doc-nits
Conflicts:
	src/doc/trpl/crates-and-modules.md
2015-03-23 15:08:01 -07:00
Alex Crichton
e98d4d9589 rollup merge of #23283: brson/rpathfix
Fix regression in -C rpath that causes failures with symlinks

The new `relative_from` method no longer supports the case on unix
where both paths are absolute, which `-C rpath` depended on. This
version fixes the problem by copying the old path_relative_from
function into the rpath module.

Fixes #23140

After experimenting with the new `relative_from` function on `Path` I'm not sure what it's use case is. It no longer even figures out that the relative path from `/foo/bar` to `/foo/baz/qux` is `../baz/qux`.
2015-03-23 15:07:33 -07:00
Alex Crichton
67e516c5c2 rollup merge of #23269: shepmaster/split-not-double-ended
Closes #23262
2015-03-23 15:07:23 -07:00
Alex Crichton
ec1a85a85c rollup merge of #23211: FlaPer87/oibit-send-and-friends
Fixes #23225

r? @nikomatsakis
2015-03-23 15:07:21 -07:00
Alex Crichton
ad41e7cd7a rollup merge of #23119: nikomatsakis/issue-23116-ref-mut
Don't allow upcasting to a supertype in the type of the match discriminant. Fixes #23116.

This is a [breaking-change] in that it closes a type hole that previously existed.

r? @pnkfelix
2015-03-23 15:07:19 -07:00
Alex Crichton
d6054e4771 rollup merge of #22954: ches/docs
Greetings Rustaceans!

I've just been getting acquainted with Rust through the guide. First let me say that it's already in great shape, chapters are kept a good length to be digestible and paced to move the reader along fluidly, so my compliments to contributors!

Along the way I noticed a few minor copy errors, and also a few areas that I thought more subjectively could stand to be improved. My commits here are divided so that minor edits unlikely to be very contentious could be cherry-picked, and then topically on parts that might generate more discussion.

I also have some comments and questions that aren't directly associated with any changes on this branch yet. I'm not sure how you like to triage this sort of thing but I'll present them below and if it's appropriate they could be moved to separate issues or I might be able to help work some of them out within the scope of this PR. Sorry that these are a lot to take in, pretty much everything below here can be digested independently of the current changes in this PR so you could read the rest later 😄

### Questions and Comments

I'll give stable links to doc revisions as of this writing.

1. The [example using `PartialEq` in the Traits chapter][1] is poor—we have no idea how `PartialEq` works at this point in the text (or at any point, AFAICT), so it isn't clear why it won't work as a trait bound in this situation and `Float` almost magically does, with the aid of existing tailor-made identity functions that seem unlikely to be so conveniently available when we encounter a scenario like this in our real-world code.

   This section just seems glossed over, or perhaps content has moved around over time or there's an assumption that implementing equality with `PartialEq` should be covered in the guide eventually so this example will be less foreign. As it stands the text is hard to follow and not very meaningful.
2. I found treatment of the relationship of trait objects to pointers in the *Static and Dynamic Dispatch* chapter unclear. [The "Why Pointers?" section][2] opens with this line:

   > The use of language like "fat pointer" implies that a trait object is always a pointer of some form, but why?

   But the phrase "fat pointer" hasn't been used anywhere before. This is some of the more complex material in the guide, but this section nevertheless feels displaced, not clearly connecting preceding subject matter. Earlier we've covered the internal representation of trait objects and significance of pointers they contain, but it hasn't been spelled out (other than what `&Foo` syntax suggests) that trait objects are references (and why). That's what the "Why Pointers?" section is aiming to do I gather, but it seems out of place, I think it'd make more sense to cover this before the gory details of their internals.
3. Suggestion: move the *Error Handling* chapter much earlier in the Intermediate section of the guide, or even into the Basics section. I know the Intermediate section isn't intended to be read in order per se, but plenty of people like me are just going to read it straight through anyway 😁 These are pretty fundamental concepts to understand and `Option`, `Result`, and idioms like `unwrap()` and `.ok().expect()` are referenced numerous times throughout the rest of the guide. They feature pretty prominently as early as *Standard Input* and *Guessing Game* chapters in Basics, in fact. I happen to have a good understanding of these already through encountering their analogs in typed functional languages, but if I didn't I believe I really would have appreciated reading *Error Handling* much earlier.
4. In the `rustdoc` chapter, a [comment at the beginning of the first source example][3] refers to a "link" crate attribute being needed. There seems to be no such attribute present in the source. I believe this refers to `crate_type` [according to the reference][4], but it'd be nice if this example were updated/clarified (I think `crate_id` is deprecated/obsolete too).

   This brings me to a related comment also: after encountering crate attributes in the reference and also docs on Cargo configuration like `crate-type = ["dylib"]`, I'm uncertain about the relationship/redundancy between these. I'm sure this is the kind of thing where docs are simply struggling to keep pace with rapid changes in Rust and Cargo, just wanted to flag that this distinction ought to be clearly covered in the docs for one or the other at some point, it's presently hard to track down.
5. Minor: link to sample editor configurations in [the introductory chapter][5] is broken, probably the generator automatically translates `.md` links to `.html`. Perhaps it shouldn't do that for absolute URLs.
6. Following from my changes to the enums coverage in [*Compound Data Types*][6] in this PR: sum types are an important topic and I tried to make some improvements, but I think the motivating example of `Character` with `Digit(i32)` and `Other` variants is a pretty weak one, and a better example could greatly improve cohesion with the `Ordering` coverage later in the section and how that ties into pattern matching in the subsequent chapter. I just haven't thought of a better example to suggest yet.

   In particular, the text states:

   > This may seem rather limiting, but it's a limitation which we can overcome.

   This is referring to `Character`, and actually to more than one limitation: the preceding admonition that its variants aren't comparable/don't have ordering, and don't support binary operators like `*` and `+`. Overcoming these limitations actually never gets explained—we next cover how `Ordering` works as an enum itself for plain `i32`s, but never get around to showing how this might be applied to our `Digit` variant type.

   Since the coverage of enums already segues into pattern matching and this could be even tighter with a stronger example, it might be nice if our example enum were somehow connected to the final example program for the Basics section too, where `Ordering` reappears. I don't see how it would fit with the current guessing game example, but food for thought.
7. `#[derive]` seems conspicuously missing from the guide. It would probably make sense to introduce after showing simple examples of implementing equality and/or ordering traits by hand, which have been mentioned as possibilities above. Perhaps it's too much to breach this as early as the Basic section though without traits being introduced. `#[derive]` itself and the derivable traits can certainly be saved for Intermediate and referenced as covered later, in any case.

r? @steveklabnik for docs.

[1]: 1576142495/src/doc/trpl/traits.md (our-inverse-example)
[2]: 1576142495/src/doc/trpl/static-and-dynamic-dispatch.md (why-pointers)
[3]: 1576142495/src/doc/trpl/documentation.md (creating-documentation)
[4]: http://doc.rust-lang.org/reference.html#linkage
[5]: 1576142495/src/doc/trpl/hello-world.md
[6]: 1576142495/src/doc/trpl/compound-data-types.md (enums)
2015-03-23 15:07:18 -07:00
Niko Matsakis
76ead08108 Remove auto-deref'ing Pattern impl because it conflicts with other
possible blanket impls and also triggers internal overflow. Add some
special cases for common uses (&&str, &String) for now; bounds-targeting
deref coercions are probably the right longer term answer.
2015-03-23 18:05:20 -04:00
Niko Matsakis
8bd8466e81 Refactor how we handle overflow so that it is a fatal error that aborts
compilation: this removes all the ungainly code that special cases
overflow so that we can ensure it propagates.
2015-03-23 18:05:20 -04:00
Alex Crichton
d97d53891d std: Stabilize the Hasher::finish method
This commit enables writing a stable implementation of the `Hasher` trait as
well as actually calculating the hash of a vlaue in a stable fashion. The
signature is stabilized as-is.
2015-03-23 15:03:07 -07:00
Aaron Turon
8389253df0 Add generic conversion traits
This commit:

* Introduces `std::convert`, providing an implementation of
RFC 529.

* Deprecates the `AsPath`, `AsOsStr`, and `IntoBytes` traits, all
in favor of the corresponding generic conversion traits.

  Consequently, various IO APIs now take `AsRef<Path>` rather than
`AsPath`, and so on. Since the types provided by `std` implement both
traits, this should cause relatively little breakage.

* Deprecates many `from_foo` constructors in favor of `from`.

* Changes `PathBuf::new` to take no argument (creating an empty buffer,
  as per convention). The previous behavior is now available as
  `PathBuf::from`.

* De-stabilizes `IntoCow`. It's not clear whether we need this separate trait.

Closes #22751
Closes #14433

[breaking-change]
2015-03-23 15:01:45 -07:00
Brian Anderson
8c93a79e38 rustdoc: Replace no-pretty-expanded with pretty-expanded
Now that features must be declared expanded source often does not compile.
This adds 'pretty-expanded' to a bunch of test cases that still work.
2015-03-23 14:40:26 -07:00
Brian Anderson
e9019101a8 Add #![feature] attributes to doctests 2015-03-23 14:40:26 -07:00
Brian Anderson
df290f127e Require feature attributes, and add them where necessary 2015-03-23 14:40:26 -07:00
Brian Anderson
7770ea706b rustdoc: Add #[doc(test(no_inject_crate))] attribute
So that collections doctests don't automatically fail themselves
by injecting `extern crate collections` when they are mostly
using the std facade.
2015-03-23 14:40:25 -07:00
Brian Anderson
3d365f6a01 rustdoc: interpret all leading feature attributes in examples as crate attributes
This makes it possible to write `#![feature(foo)]` in doc tests.
2015-03-23 14:40:25 -07:00
Steve Klabnik
6a5b1e9f8e Rollup merge of #23641 - steveklabnik:gh23632, r=alexcrichton
Fixes #23632
2015-03-23 17:05:46 -04:00
Steve Klabnik
68af512123 Rollup merge of #23639 - steveklabnik:gh21305, r=alexcrichton
Fixes #21305

Not sure if we should include more than this here, but it should be good to have at least this.
2015-03-23 17:05:45 -04:00
Steve Klabnik
1c25aecf67 Rollup merge of #23622 - steveklabnik:gh23196, r=alexcrichton
Fixes #23196
2015-03-23 17:05:45 -04:00
Steve Klabnik
71b9ba1e5b Rollup merge of #23618 - steveklabnik:gh23571, r=alexcrichton
Fixes #23571
2015-03-23 17:05:45 -04:00
Steve Klabnik
8b6c0fd410 Rollup merge of #23608 - nagisa:refine-cursor-docstring, r=steveklabnik
r? @steveklabnik
2015-03-23 17:05:45 -04:00
Steve Klabnik
9299446030 Rollup merge of #23607 - mahkoh:cursor, r=alexcrichton
Closes #23599

r? @alexcrichton
2015-03-23 17:05:44 -04:00
Steve Klabnik
61e690405a Rollup merge of #23561 - steveklabnik:gh23422, r=alexcrichton
Fixes #23422
2015-03-23 17:05:44 -04:00
Steve Klabnik
84f760b50a Rollup merge of #23509 - aturon:stab-entry, r=Gankro
This commit marks as `#[stable]` the `Entry` types for the maps provided
by `std`. The main reason these had been left unstable previously was
uncertainty about an eventual trait design, but several plausible
designs have been proposed that all work fine with the current type definitions.

r? @Gankro
2015-03-23 17:05:44 -04:00
Steve Klabnik
f788159797 Rollup merge of #23119 - nikomatsakis:issue-23116-ref-mut, r=pnkfelix
Don't allow upcasting to a supertype in the type of the match discriminant. Fixes #23116.

This is a [breaking-change] in that it closes a type hole that previously existed.

r? @pnkfelix
2015-03-23 17:05:43 -04:00
Steve Klabnik
4a81e66b44 Rollup merge of #22954 - ches:docs, r=steveklabnik
Greetings Rustaceans!

I've just been getting acquainted with Rust through the guide. First let me say that it's already in great shape, chapters are kept a good length to be digestible and paced to move the reader along fluidly, so my compliments to contributors!

Along the way I noticed a few minor copy errors, and also a few areas that I thought more subjectively could stand to be improved. My commits here are divided so that minor edits unlikely to be very contentious could be cherry-picked, and then topically on parts that might generate more discussion.

I also have some comments and questions that aren't directly associated with any changes on this branch yet. I'm not sure how you like to triage this sort of thing but I'll present them below and if it's appropriate they could be moved to separate issues or I might be able to help work some of them out within the scope of this PR. Sorry that these are a lot to take in, pretty much everything below here can be digested independently of the current changes in this PR so you could read the rest later 😄

### Questions and Comments

I'll give stable links to doc revisions as of this writing.

1. The [example using `PartialEq` in the Traits chapter][1] is poor—we have no idea how `PartialEq` works at this point in the text (or at any point, AFAICT), so it isn't clear why it won't work as a trait bound in this situation and `Float` almost magically does, with the aid of existing tailor-made identity functions that seem unlikely to be so conveniently available when we encounter a scenario like this in our real-world code.

   This section just seems glossed over, or perhaps content has moved around over time or there's an assumption that implementing equality with `PartialEq` should be covered in the guide eventually so this example will be less foreign. As it stands the text is hard to follow and not very meaningful.
2. I found treatment of the relationship of trait objects to pointers in the *Static and Dynamic Dispatch* chapter unclear. [The "Why Pointers?" section][2] opens with this line:

   > The use of language like "fat pointer" implies that a trait object is always a pointer of some form, but why?

   But the phrase "fat pointer" hasn't been used anywhere before. This is some of the more complex material in the guide, but this section nevertheless feels displaced, not clearly connecting preceding subject matter. Earlier we've covered the internal representation of trait objects and significance of pointers they contain, but it hasn't been spelled out (other than what `&Foo` syntax suggests) that trait objects are references (and why). That's what the "Why Pointers?" section is aiming to do I gather, but it seems out of place, I think it'd make more sense to cover this before the gory details of their internals.
3. Suggestion: move the *Error Handling* chapter much earlier in the Intermediate section of the guide, or even into the Basics section. I know the Intermediate section isn't intended to be read in order per se, but plenty of people like me are just going to read it straight through anyway 😁 These are pretty fundamental concepts to understand and `Option`, `Result`, and idioms like `unwrap()` and `.ok().expect()` are referenced numerous times throughout the rest of the guide. They feature pretty prominently as early as *Standard Input* and *Guessing Game* chapters in Basics, in fact. I happen to have a good understanding of these already through encountering their analogs in typed functional languages, but if I didn't I believe I really would have appreciated reading *Error Handling* much earlier.
4. In the `rustdoc` chapter, a [comment at the beginning of the first source example][3] refers to a "link" crate attribute being needed. There seems to be no such attribute present in the source. I believe this refers to `crate_type` [according to the reference][4], but it'd be nice if this example were updated/clarified (I think `crate_id` is deprecated/obsolete too).

   This brings me to a related comment also: after encountering crate attributes in the reference and also docs on Cargo configuration like `crate-type = ["dylib"]`, I'm uncertain about the relationship/redundancy between these. I'm sure this is the kind of thing where docs are simply struggling to keep pace with rapid changes in Rust and Cargo, just wanted to flag that this distinction ought to be clearly covered in the docs for one or the other at some point, it's presently hard to track down.
5. Minor: link to sample editor configurations in [the introductory chapter][5] is broken, probably the generator automatically translates `.md` links to `.html`. Perhaps it shouldn't do that for absolute URLs.
6. Following from my changes to the enums coverage in [*Compound Data Types*][6] in this PR: sum types are an important topic and I tried to make some improvements, but I think the motivating example of `Character` with `Digit(i32)` and `Other` variants is a pretty weak one, and a better example could greatly improve cohesion with the `Ordering` coverage later in the section and how that ties into pattern matching in the subsequent chapter. I just haven't thought of a better example to suggest yet.

   In particular, the text states:

   > This may seem rather limiting, but it's a limitation which we can overcome.

   This is referring to `Character`, and actually to more than one limitation: the preceding admonition that its variants aren't comparable/don't have ordering, and don't support binary operators like `*` and `+`. Overcoming these limitations actually never gets explained—we next cover how `Ordering` works as an enum itself for plain `i32`s, but never get around to showing how this might be applied to our `Digit` variant type.

   Since the coverage of enums already segues into pattern matching and this could be even tighter with a stronger example, it might be nice if our example enum were somehow connected to the final example program for the Basics section too, where `Ordering` reappears. I don't see how it would fit with the current guessing game example, but food for thought.
7. `#[derive]` seems conspicuously missing from the guide. It would probably make sense to introduce after showing simple examples of implementing equality and/or ordering traits by hand, which have been mentioned as possibilities above. Perhaps it's too much to breach this as early as the Basic section though without traits being introduced. `#[derive]` itself and the derivable traits can certainly be saved for Intermediate and referenced as covered later, in any case.

r? @steveklabnik for docs.

[1]: 1576142495/src/doc/trpl/traits.md (our-inverse-example)
[2]: 1576142495/src/doc/trpl/static-and-dynamic-dispatch.md (why-pointers)
[3]: 1576142495/src/doc/trpl/documentation.md (creating-documentation)
[4]: http://doc.rust-lang.org/reference.html#linkage
[5]: 1576142495/src/doc/trpl/hello-world.md
[6]: 1576142495/src/doc/trpl/compound-data-types.md (enums)
2015-03-23 17:05:43 -04:00
Tom Jakubowski
2df8830642 rustdoc: Support for "array" primitive
Impls on `clean::Type::FixedVector` are now collected in the array
primitive page instead of the slice primitive page.

Also add a primitive docs for arrays to `std`.
2015-03-23 14:02:34 -07:00
Niko Matsakis
57cf2decf7 Update borrowck tests to test that index is by-move now 2015-03-23 16:55:45 -04:00
Niko Matsakis
8e58af4004 Fallout in stdlib, rustdoc, rustc, etc. For most maps, converted uses of
`[]` on maps to `get` in rustc, since stage0 and stage1+ disagree about
how to use `[]`.
2015-03-23 16:55:45 -04:00
Niko Matsakis
b4d4daf007 Adjust Index/IndexMut impls. For generic collections, we take
references. For collections whose keys are integers, we take both
references and by-value.
2015-03-23 16:55:43 -04:00
Niko Matsakis
bc1dde468c Compiler and trait changes to make indexing by value. 2015-03-23 16:54:28 -04:00
Niko Matsakis
37601131a0 Make the Fn traits inherit from one another and remove the bridging
impls.

This requires:

1. modifying trait selection a bit so that when we synthesize impls for
   fn pointers and closures;
2. adding code to trans so that we can synthesize a `FnMut`/`FnOnce`
   impl for a `Fn` closure and so forth.
2015-03-23 16:46:02 -04:00
Steve Klabnik
1be8fcb4a9 Make note of str in 'more strings' chapter
Fixes #21035
2015-03-23 14:57:52 -04:00
Steve Klabnik
05c9728c69 Don't conflate regions and affine types
Fixes #23642
2015-03-23 14:47:14 -04:00
Aaron Turon
6bd3ab0d81 Implement RFC 909: move thread_local into thread
This commit implements [RFC
909](https://github.com/rust-lang/rfcs/pull/909):

The `std::thread_local` module is now deprecated, and its contents are
available directly in `std::thread` as `LocalKey`, `LocalKeyState`, and
`ScopedKey`.

The macros remain exactly as they were, which means little if any code
should break. Nevertheless, this is technically a:

[breaking-change]

Closes #23547
2015-03-23 11:28:54 -07:00
Aaron Turon
9231ceb6dd Stabilize the Error trait
This small commit stabilizes the `Error` trait as-is, except that `Send`
and `Debug` are added as constraints. The `Send` constraint is because
most uses of `Error` will be for trait objects, and by default we would
like these objects to be transferrable between threads. The `Debug`
constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because
types that implement `Display` should certainly implement `Debug` in any case.

In the near future we expect to add `Any`-like downcasting features to
`Error`, but this is waiting on some additional
mechanisms (`Reflect`). It will be added before 1.0 via default methods.

[breaking-change]
2015-03-23 11:27:19 -07:00
Simonas Kazlauskas
d29d5545b6 prctl instead of pthread on linux for name setup
This is more portable as far as linux is concerned.
2015-03-23 20:08:12 +02:00