Commit Graph

3672 Commits

Author SHA1 Message Date
Aaron Turon
e0ad0fcb95 Update code with new lint names 2014-10-28 08:54:21 -07:00
Daniel Hofstetter
348a46f9c1 Remove double negation from sqrt's doc comment 2014-10-28 15:07:22 +01:00
Jorge Aparicio
94ddb51c9c DSTify [T]/str extension traits
This PR changes the signature of several methods from `foo(self, ...)` to
`foo(&self, ...)`/`foo(&mut self, ...)`, but there is no breakage of the usage
of these methods due to the autoref nature of `method.call()`s. This PR also
removes the lifetime parameter from some traits (`Trait<'a>` -> `Trait`). These
changes break any use of the extension traits for generic programming, but
those traits are not meant to be used for generic programming in the first
place. In the whole rust distribution there was only one misuse of a extension
trait as a bound, which got corrected (the bound was unnecessary and got
removed) as part of this PR.

[breaking-change]
2014-10-27 20:20:08 -05:00
Alex Crichton
9dc9eccf3d rollup merge of #18316 : thestinger/raw 2014-10-27 15:12:29 -07:00
Patrick Walton
aa242e721a libcore: Inline atomic constructors.
Servo really wants this.
2014-10-27 09:14:57 -07:00
bors
cb943b7d2b auto merge of #18212 : kmcallister/rust/unsafecell, r=thestinger
Fixes #18131.
2014-10-26 06:37:23 +00:00
Daniel Micay
3942ab92f0 make the core::raw struct representation defined
Closes #18313
2014-10-25 13:28:17 -04:00
bors
172b59abe5 auto merge of #18080 : veddan/rust/assume, r=thestinger
Adds an `assume` intrinsic that gets translated to llvm.assume. It is
used on a boolean expression and allows the optimizer to assume that
the expression is true.

This implements #18051.
2014-10-25 00:32:07 +00:00
Keegan McAllister
7317ef5c36 Add as_unsafe_cell() for Cell and RefCell
Fixes #18131.
2014-10-24 14:15:50 -07:00
bors
c53f8a920e auto merge of #17960 : mahkoh/rust/clone_from_slice, r=pcwalton
Old vs. New vs. Vec::push_all

```
test slice     ... bench:   3091942 ns/iter (+/- 54460)
test slice_new ... bench:   1800065 ns/iter (+/- 69513)
test vec       ... bench:   1804805 ns/iter (+/- 75609)
```
2014-10-24 01:02:21 +00:00
bors
3d2cf60631 auto merge of #18121 : nikomatsakis/rust/method-call-use-trait-matching-infrastructure-2, r=pcwalton
Convert trait method dispatch to use new trait matching machinery.

This fixes about 90% of #17918. What remains to be done is to make inherent dispatch work with conditional dispatch as well. I plan to do this in a future patch by generalizing the "method match" code slightly to work for inherent impls as well (the basic algorithm is precisely the same).

Fixes #17178.

This is a [breaking-change] for two reasons:

1. The old code was a bit broken. I found various minor cases, particularly around operators, where the old code incorrectly matched, but an extra `*` or other change is now required. (See commit e8cef25 ("Correct case where the old version of method lookup...") for examples.)
2. The old code didn't type check calls against the method signature from the *trait* but rather the *impl*. The two can be different in subtle ways. This makes the new method dispatch both more liberal and more conservative than the original. (See commit 8308332 ("The new method lookup mechanism typechecks...") for examples.)

r? @pcwalton since he's been reviewing most of this series of changes
f? @nick29581 for commit 39df55f ("Permit DST types to unify like other types")
cc @aturon as this relates to library stabilization
2014-10-22 00:22:04 +00:00
Niko Matsakis
b066d09be8 Patch up broken error messages 2014-10-21 17:36:15 -04:00
Niko Matsakis
98e237a681 Correct case where the old version of method lookup was incorrectly matching,
as far as I can tell.
2014-10-21 12:32:36 -04:00
bors
4764c16011 auto merge of #18201 : Gankro/rust/option-what, r=alexcrichton
🐳
2014-10-21 14:52:11 +00:00
Alexis Beingessner
01e8ad6c38 Fix crazy-pants match in Option docs 2014-10-20 21:18:59 -04:00
bors
7d0cc44f87 auto merge of #18070 : alexcrichton/rust/spring-cleaning, r=aturon
This is a large spring-cleaning commit now that the 0.12.0 release has passed removing an amount of deprecated functionality. This removes a number of deprecated crates (all still available as cargo packages in the rust-lang organization) as well as a slew of deprecated functions. All `#[crate_id]` support has also been removed.

I tried to avoid anything that was recently deprecated, but I may have missed something! The major pain points of this commit is the fact that rustc/syntax have `#[allow(deprecated)]`, but I've removed that annotation so moving forward they should be cleaned up as we go.
2014-10-20 16:07:43 +00:00
bors
ddfe24d641 auto merge of #18174 : huonw/rust/fix-sqrt, r=alexcrichton
Closes #9987.
2014-10-20 10:17:09 +00:00
Huon Wilson
a1d5cd204d Handle negative numbers in sqrt properly.
Closes #9987.
2014-10-20 21:10:13 +11:00
Alex Crichton
9d5d97b55d Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount
of deprecated functionality from the standard libraries. I tried to ensure that
only old deprecated functionality was removed.

This is removing lots and lots of deprecated features, so this is a breaking
change. Please consult the deprecation messages of the deleted code to see how
to migrate code forward if it still needs migration.

[breaking-change]
2014-10-19 12:59:40 -07:00
Ray Clanan
1b7163358f Mark lt as inline in PartialOrd 2014-10-18 11:49:33 -04:00
bors
4480caf2a4 auto merge of #18024 : phungleson/rust/fix-var-name-in-doc, r=brson
Make the doc more consistent & runnable.

* Use `_index` instead of `_rhs` when appropriate.
* Use `_from` and `_to` to avoid warning.
* Remove unnecessary `::core::ops`
2014-10-18 06:22:15 +00:00
Luqman Aden
3410c52eec librustc: Remove trans::reflect and the opaque and ty_visitor lang items. 2014-10-16 11:15:36 -04:00
Luqman Aden
7210a5af87 librustc: Stop generating visit glue and remove from TyDesc. 2014-10-16 11:15:36 -04:00
Luqman Aden
7a4122ac67 librustc: Remove visit_tydesc intrinsic. 2014-10-16 11:15:35 -04:00
Viktor Dahl
0c18da503c Improve documentation of assume intrinsic. 2014-10-16 14:20:54 +02:00
Viktor Dahl
0525bb7669 Add assume intrinsic
Adds an `assume` intrinsic that gets translated to llvm.assume. It is
used on a boolean expression and allows the optimizer to assume that
the expression is true.

This implements #18051.
2014-10-16 01:44:44 +02:00
bors
5e1e2456ed auto merge of #18029 : Ms2ger/rust/patch-1, r=huonw 2014-10-14 19:22:22 +00:00
Ms2ger
0e1e9cbb13 Fix the formatting of the documentation for OrdIterator.min_max. 2014-10-14 12:11:07 +02:00
Son
d9da3471e8 Change from and to to _from and _to
This to avoid warning: unused variable: `from`,
#[warn(unused_variable)] on by default.
2014-10-14 09:21:39 +08:00
Son
62b48bd815 Remove unnecessary ::core::ops::
It shows error: failed to resolve. Maybe a missing `extern crate core`
anyway.
2014-10-14 09:20:11 +08:00
Son
8f717ffe60 Change _rhs to _index.
Because var is provided as an index not a right hand side.
2014-10-14 09:11:37 +08:00
Stefan Bucur
39749a3adc Fix typo in char's from_digit error message 2014-10-13 22:17:48 +02:00
Julian Orth
cea171b0ae improve clone_from_slice performance 2014-10-12 01:24:47 +02:00
Alex Crichton
dae48a07f3 Register new snapshots
Also convert a number of `static mut` to just a plain old `static` and remove
some unsafe blocks.
2014-10-10 22:09:49 -07:00
bors
f9fc49c06e auto merge of #17853 : alexcrichton/rust/issue-17718, r=pcwalton
This change is an implementation of [RFC 69][rfc] which adds a third kind of
global to the language, `const`. This global is most similar to what the old
`static` was, and if you're unsure about what to use then you should use a
`const`.

The semantics of these three kinds of globals are:

* A `const` does not represent a memory location, but only a value. Constants
  are translated as rvalues, which means that their values are directly inlined
  at usage location (similar to a #define in C/C++). Constant values are, well,
  constant, and can not be modified. Any "modification" is actually a
  modification to a local value on the stack rather than the actual constant
  itself.

  Almost all values are allowed inside constants, whether they have interior
  mutability or not. There are a few minor restrictions listed in the RFC, but
  they should in general not come up too often.

* A `static` now always represents a memory location (unconditionally). Any
  references to the same `static` are actually a reference to the same memory
  location. Only values whose types ascribe to `Sync` are allowed in a `static`.
  This restriction is in place because many threads may access a `static`
  concurrently. Lifting this restriction (and allowing unsafe access) is a
  future extension not implemented at this time.

* A `static mut` continues to always represent a memory location. All references
  to a `static mut` continue to be `unsafe`.

This is a large breaking change, and many programs will need to be updated
accordingly. A summary of the breaking changes is:

* Statics may no longer be used in patterns. Statics now always represent a
  memory location, which can sometimes be modified. To fix code, repurpose the
  matched-on-`static` to a `const`.

      static FOO: uint = 4;
      match n {
          FOO => { /* ... */ }
          _ => { /* ... */ }
      }

  change this code to:

      const FOO: uint = 4;
      match n {
          FOO => { /* ... */ }
          _ => { /* ... */ }
      }

* Statics may no longer refer to other statics by value. Due to statics being
  able to change at runtime, allowing them to reference one another could
  possibly lead to confusing semantics. If you are in this situation, use a
  constant initializer instead. Note, however, that statics may reference other
  statics by address, however.

* Statics may no longer be used in constant expressions, such as array lengths.
  This is due to the same restrictions as listed above. Use a `const` instead.

[breaking-change]
Closes #17718 

[rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-10 00:07:08 +00:00
Brian Anderson
5c92a8e054 Use the same html_root_url for all docs 2014-10-09 10:50:13 -07:00
Brian Anderson
6beddcfd83 Revert "Update html_root_url for 0.12.0 release"
This reverts commit 2288f33230.
2014-10-09 10:34:34 -07:00
Alex Crichton
4d87af9dce core: Convert statics to constants 2014-10-09 09:44:50 -07:00
Brian Anderson
158eaa643b 0.12.0 release
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJUNrj+AAoJEIWrlub6G+X+4TMQAIlyIoTpbZfA7MgaqHmrqp/O
 DkWH4sjoiTL3pdqHitbaJWFzStLjmM+hzOKYVYxXJGqpHuZv7pbnN2sQCKvJ6m9E
 htojoy9ZVeOUjkqz3+PYc6mh+SuQq4bpAhnnt60tLSxZCda7uTpdTcsOgDlwhu8P
 /YIbnBHo6brcQi6kEK27uN7U2MsluRR/ZhAmZH1mvrTtjKrGsKTEdta2NW1tUzNT
 sDluM9D0/WFjwSA9OohjtpUI7KYudqChOCRaqREgNq6xc/9at/TQHULsjzxLFIiC
 tAttF7ZZ2s1TmS4qzmx3AAWl8n8xYrDo+CpfPqKvSGwDegfHN9Epa+24Cdf2Q5GO
 9RSup89NlNNo3tjmK+G1cUqi/K9RseiZNPSJSoLlR2L9QFg/VFEVbcaZX+oX+CQF
 pfWkKqsfLqj50EimO+vuXRZhShHlu/McOdN0cd+S0KEGdd7ngqU3d7YJf9Ppm1mV
 d1VUqnPxvDrGQTGqk4cpGMIv+LmT6vY2iix3ha583zMYcU9VWrC9VEmR3I4XZefE
 UgsbAx2jIgagWa6ylDpes7X8dn/7qj3BA6l3Bt9aGrs9KnyQ+a3xOyz8dFvRJwks
 T8izOhfJXpxW4CLFZjDIQ9RD/joJuvuqTSIqf7zGIxIbMUQFB9EC/Rn7a3ftidds
 aZVZSl2li1vOa3DucW64
 =4lHl
 -----END PGP SIGNATURE-----

Merge tag '0.12.0'

0.12.0 release
2014-10-09 09:36:30 -07:00
bors
218cb4bc99 auto merge of #17748 : mahkoh/rust/int_slice, r=aturon 2014-10-08 21:22:32 +00:00
Julian Orth
bd527909e7 add {Imm,M}utableIntSlice 2014-10-08 20:51:31 +02:00
Brian Anderson
2288f33230 Update html_root_url for 0.12.0 release 2014-10-07 11:18:50 -07:00
bors
e62ef37cfa auto merge of #17807 : nick29581/rust/slice6, r=aturon
r? @aturon
2014-10-07 06:17:11 +00:00
Nick Cameron
eb2fdc8b06 Reinstate AsSlice impls for Option and Result 2014-10-07 15:55:52 +13:00
Nick Cameron
3b0550c3a9 Rename slicing methods 2014-10-07 15:49:53 +13:00
Nick Cameron
cd21e4a72c Rename slice::Slice 2014-10-07 15:49:53 +13:00
Nick Cameron
2d3823441f Put slicing syntax behind a feature gate.
[breaking-change]

If you are using slicing syntax you will need to add #![feature(slicing_syntax)] to your crate.
2014-10-07 15:49:53 +13:00
Nick Cameron
59976942ea Use slice syntax instead of slice_to, etc. 2014-10-07 15:49:53 +13:00
Aaron Turon
07cfc252a1 Remove core::any::AnyPrivate
[Previously](e5da6a71a6),
the `Any` trait was split into a private portion and an (empty) public
portion, in order to hide the implementation strategy used for
downcasting. However, the [new
rules](e9ad12c0ca)
for privacy forbid `AnyPrivate` from actually being private.

This patch thus reverts the introduction of `AnyPrivate`.

Although this is unlikely to break any real code, it removes a public
trait and is therefore a:

[breaking-change]
2014-10-06 16:32:30 -07:00
bors
b5ba2f5517 auto merge of #17820 : pnkfelix/rust/fsk-improve-binary_search-doc2, r=alexcrichton
Add example to doc for `slice::ImmutableSlice::binary_search`.

Fix #17817.
2014-10-06 20:27:14 +00:00
Felix S. Klock II
d1e0f7259e Add example to doc for slice::ImmutableSlice::binary_search.
Fix #17817.
2014-10-06 15:59:22 +02:00
bors
5660db2508 auto merge of #16970 : kmcallister/rust/llvm-unreachable, r=thestinger
I'm not sure how to add an automated test for this.
2014-10-05 07:17:09 +00:00
Keegan McAllister
401aeaf6d3 Add intrinsics::unreachable 2014-10-04 20:09:09 -07:00
Peter Minten
2bb7956a83 Make examples for AtomicInt refer to AtomicInt
The examples for fetch_or, fetch_and and fetch_xor for
std::sync::atomic::AtomicInt used AtomicUint instead of AtomicInt.
2014-10-04 13:29:09 +02:00
Alex Crichton
7ae802f57b rollup merge of #17666 : eddyb/take-garbage-out
Conflicts:
	src/libcollections/lib.rs
	src/libcore/lib.rs
	src/librustdoc/lib.rs
	src/librustrt/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
	src/test/run-pass/issue-8898.rs
2014-10-02 14:53:18 -07:00
Alex Crichton
8bb5a674a4 rollup merge of #16993 : dschatzberg/items-bounds 2014-10-02 14:49:42 -07:00
Aaron Turon
d2ea0315e0 Revert "Use slice syntax instead of slice_to, etc."
This reverts commit 40b9f5ded5.
2014-10-02 11:48:07 -07:00
Aaron Turon
c0c6c89589 Revert "Remove the _ suffix from slice methods."
This reverts commit df2f1fa768.
2014-10-02 11:47:58 -07:00
Aaron Turon
7bf56df4c8 Revert "Put slicing syntax behind a feature gate."
This reverts commit 95cfc35607.
2014-10-02 11:47:51 -07:00
Aaron Turon
2f365ffdad Revert "Review and rebasing changes"
This reverts commit 6e0611a487.
2014-10-02 11:47:38 -07:00
Dan Schatzberg
4184396f28 Add lifetime bounds on Items and MutItems.
This also requires a fix for Vec's MoveItems. This resolves issue #16941
2014-10-02 11:22:05 -04:00
Eduard Burtescu
db55e70c97 syntax: mark the managed_boxes feature as Removed. 2014-10-02 17:02:03 +03:00
Eduard Burtescu
382f1bceb4 core: remove raw::GcBox. 2014-10-02 16:36:00 +03:00
Nick Cameron
6e0611a487 Review and rebasing changes 2014-10-02 14:50:22 +13:00
Nick Cameron
95cfc35607 Put slicing syntax behind a feature gate.
[breaking-change]

If you are using slicing syntax you will need to add #![feature(slicing_syntax)] to your crate.
2014-10-02 13:23:36 +13:00
Nick Cameron
df2f1fa768 Remove the _ suffix from slice methods.
Deprecates slicing methods from ImmutableSlice/MutableSlice in favour of slicing syntax or the methods in Slice/SliceMut.

Closes #17273.
2014-10-02 13:19:45 +13:00
Nick Cameron
40b9f5ded5 Use slice syntax instead of slice_to, etc. 2014-10-02 13:19:45 +13:00
bors
fe93a549a4 auto merge of #17132 : reem/rust/any-static-bound, r=alexcrichton
This bound is already implicit through the AnyPrivate trait,
but since it is not explicit, you still have to write Box<Any + 'static>,
even though Any can only be 'static.

Introducing the 'static bound here makes this bound explicit, making
Box<Any> legal.
2014-10-01 05:32:16 +00:00
Jonathan Reem
0cf60b6bb8 Bound Any with 'static
This bound is already implicit through the AnyPrivate trait,
but since it is not explicit, you still have to write Box<Any + 'static>,
even though Any can only be 'static.

Introducing the 'static bound here makes this bound explicit, making
Box<Any> legal.
2014-09-30 18:40:07 -07:00
Patrick Walton
416144b827 librustc: Forbid .. in range patterns.
This breaks code that looks like:

    match foo {
        1..3 => { ... }
    }

Instead, write:

    match foo {
        1...3 => { ... }
    }

Closes #17295.

[breaking-change]
2014-09-30 09:11:26 -07:00
Alex Crichton
1ae44c2059 rollup merge of #17621 : sfackler/new-snap 2014-09-29 08:17:18 -07:00
Alex Crichton
ea3a3e9a7f rollup merge of #17602 : Tobba/defailbloat-static 2014-09-29 08:14:32 -07:00
Alex Crichton
735d16b1b0 rollup merge of #17585 : sfackler/string-slice 2014-09-29 08:14:16 -07:00
Alex Crichton
e44393a953 rollup merge of #17582 : kmcallister/gc-box 2014-09-29 08:14:12 -07:00
Alex Crichton
bb84afeba1 rollup merge of #17564 : japaric/fix-slicemut-docs 2014-09-29 08:12:42 -07:00
Alex Crichton
e786891d41 rollup merge of #17557 : sfackler/fuse-example 2014-09-29 08:12:37 -07:00
Steven Fackler
fa419d3d21 Register new snapshots 2014-09-28 19:28:48 -07:00
Tobba
3b9732eae7 Defailbloat fail!(&'static str) 2014-09-28 02:02:31 +02:00
Steven Fackler
aa2814fd4e Implement Slice for String and str
Closes #17502
2014-09-26 21:48:49 -07:00
bors
606bf110bc auto merge of #17469 : sfackler/rust/into-result, r=aturon
This is the inverse of `Result::ok` and helps to bridge `Option` and
`Result` based APIs.
2014-09-27 04:02:58 +00:00
Keegan McAllister
f8a180b36e Rename raw::Box to raw::GcBox
Fixes #17470.
2014-09-26 19:54:27 -07:00
Jorge Aparicio
f57e9d0cc8 Fix SliceMut documentation
The syntax sugar is `[mut from..to]` not `[from..to]`
2014-09-26 11:53:47 -05:00
Steven Fackler
0c8878d042 Add Option::{ok_or, ok_or_else}
These are the inverses of `Result::ok` and help to bridge `Option` and
`Result` based APIs.
2014-09-26 09:11:53 -07:00
Steven Fackler
a4844a65e2 Fix Iterator::fuse example
The for loop would *always* exaust the iterator previously, which seems
like behavior that was not intended. It's still kind of a weird
function.
2014-09-25 23:06:34 -07:00
Aaron Turon
af3cfcc9ea Fallout from deprecation 2014-09-25 17:46:03 -07:00
Aaron Turon
4f509a1e47 Stabilize mutable slice API
This commit is another in the series of vector slice API
stabilization. The focus here is the *mutable* slice API.

Largely, this API inherits the stability attributes [previously
assigned](https://github.com/rust-lang/rust/pull/16332) to the analogous
methods on immutable slides. It also adds comments to a few `unstable`
attributes that were previously missing them.

In addition, the commit adds several `_mut` variants of APIs that were
missing:

- `init_mut`
- `head_mut`
- `tail_mut`
- `splitn_mut`
- `rsplitn_mut`

Some of the unsafe APIs -- `unsafe_set`, `init_elem`, and `copy_memory`
-- were deprecated in favor of working through `as_mut_ptr`, to simplify
the API surface.

Due to deprecations, this is a:

[breaking-change]
2014-09-25 17:46:03 -07:00
bors
2550243b41 auto merge of #17466 : nikomatsakis/rust/oibt, r=pcwalton
Moves the vast majority of builtin bound checking out of type contents and into the trait system.

This is a preliminary step for a lot of follow-on work:

- opt-in builtin types, obviously
- generalized where clauses, because TypeContents has this notion that a type parameter has a single set of builtin kinds, but with where clauses it depends on context
- generalized coherence, because this adds support for recursive trait selection

Unfortunately I wasn't able to completely remove Type Contents from the front-end checking in this PR. It's still used by EUV to decide what gets moved and what doesn't.

r? @pcwalton
2014-09-25 19:02:44 +00:00
bors
3be6a2fba8 auto merge of #17482 : hoeppnertill/rust/master, r=alexcrichton
Intended to prevent each user to write his own partial_min/max, possibly differing in slight details. @sfackler encouraged to PR this on IRC.

(Let's hope this works... First PR.)
2014-09-25 17:17:43 +00:00
bors
3f8da69618 auto merge of #17455 : steveklabnik/rust/document_default, r=alexcrichton
Given that the `Default` module is now stable, it might as well get good docs.
2014-09-25 15:32:49 +00:00
bors
58413c09cd auto merge of #17498 : coyotebush/rust/iter-doc, r=huonw
OrdIterator: the doc says that values must implement `PartialOrd`, while the implementation is only for `Ord` values. It looks like this initially got out of sync in 4e1c215. Removed the doc sentence entirely since it seems redundant.

MultiplicativeIterator: Fixed weird sentence.
2014-09-25 13:47:46 +00:00
Till Hoeppner
29c2d3df52 Add partial_min/max to libcore/cmp
Add partial_min/max to libcore/cmp

Match against None and mark as experimental

Shortened documentation.

Removed whitespace
2014-09-25 14:12:03 +02:00
Niko Matsakis
effb3636cc Integrate builtin bounds fully into the trait checker 2014-09-25 07:06:27 -04:00
bors
9ff308137a auto merge of #17428 : fhahn/rust/issue-16114-rename-begin-unwind-2, r=alexcrichton
This is a PR for #16114 and includes to following things:

* Rename `begin_unwind` lang item to `fail_fmt`
*  Rename `core::failure::begin_unwind` to `fail_impl`
* Rename `fail_` lang item to `fail`
2014-09-25 05:17:31 +00:00
Steve Klabnik
03b96d1ab6 Beef up Default documentation 2014-09-24 20:35:33 -04:00
Florian Hahn
c8b767dd3d Rename begin_unwind_string to fail_str, refs #16114 2014-09-25 01:09:14 +02:00
Florian Hahn
1c7d253ca3 Rename fail_ lang item to fail, closes #16114 2014-09-25 01:09:09 +02:00
Florian Hahn
45f4081e61 Rename core::failure::begin_unwind to fail_impl, refs #16114 2014-09-24 23:44:00 +02:00
Florian Hahn
9a01da9460 Rename begin_unwind lang item to fail_fmt, refs #16114 2014-09-24 23:44:00 +02:00
Jakub Wieczorek
5bcc154dff Remove unused enum variants 2014-09-24 21:03:55 +02:00
Corey Ford
e87209ecd6 Fix iterator doc
OrdIterator: the doc says that values must implement `PartialOrd`, while the implementation is only for `Ord` values. It looks like this initially got out of sync in 4e1c215. Removed the doc sentence entirely since it seems redundant.

MultiplicativeIterator: Fixed weird sentence.
2014-09-23 21:06:00 -07:00
bors
0a4c136d6a auto merge of #17446 : steveklabnik/rust/gh17445, r=alexcrichton
Fixes #17445.
2014-09-23 09:00:40 +00:00
Patrick Walton
e9ad12c0ca librustc: Forbid private types in public APIs.
This breaks code like:

    struct Foo {
        ...
    }

    pub fn make_foo() -> Foo {
        ...
    }

Change this code to:

    pub struct Foo {    // note `pub`
        ...
    }

    pub fn make_foo() -> Foo {
        ...
    }

The `visible_private_types` lint has been removed, since it is now an
error to attempt to expose a private type in a public API. In its place
a `#[feature(visible_private_types)]` gate has been added.

Closes #16463.

RFC #48.

[breaking-change]
2014-09-22 20:05:45 -07:00
Steve Klabnik
bd322f4c1f remove references to owned and managed pointers in clone docs
Fixes #17445.
2014-09-22 13:51:21 -04:00
Victor Berger
d845857fd9 Fix deprecation warnings in check-docs.
Fallout of closing #17185.
2014-09-22 19:31:31 +02:00
bors
8a458181dd auto merge of #17339 : treeman/rust/doc-things, r=alexcrichton
Also some cleanup to conform to documentation style.
2014-09-22 09:05:29 +00:00
Nick Cameron
31a7e38759 Implement slicing syntax.
`expr[]`, `expr[expr..]`, `expr[..expr]`,`expr[expr..expr]`

Uses the Slice and SliceMut traits.

Allows ... as well as .. in range patterns.
2014-09-19 11:15:49 +12:00
Alex Crichton
60d2689ab2 rollup merge of #17329 : alexcrichton/snapshots 2014-09-17 08:50:05 -07:00
Alex Crichton
8875584363 rollup merge of #16936 : nham/two_way_makeover 2014-09-17 08:48:33 -07:00
Jonas Hietala
f38f0b2e1a doc: Backticks and spelling mistakes. 2014-09-17 15:02:26 +02:00
Jonas Hietala
0d94d787a7 doc: Methods for option::Option 2014-09-17 12:34:20 +02:00
Jonas Hietala
e53db0b5c9 doc: Methods for result::Result. 2014-09-17 12:34:19 +02:00
Jonas Hietala
9b49ad238d doc: Cleanup.
Remove ~~~ for code block specification. Use /// Over /** */ for doc
blocks.
2014-09-17 11:28:22 +02:00
Alex Crichton
c4a1c3800b Register new snapshots
This is the first linux snapshot created on our new CentOS 5.10 builders.

Closes #9545
2014-09-16 18:16:38 -07:00
Aaron Turon
fc525eeb4e Fallout from renaming 2014-09-16 14:37:48 -07:00
Aaron Turon
d8dfe1957b Align with _mut conventions
As per [RFC
52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md),
use `_mut` suffixes to mark mutable variants, and `into_iter` for moving
iterators.

[breaking-change]
2014-09-16 11:46:52 -07:00
bors
8e2860407b auto merge of #16887 : steveklabnik/rust/guide_iterators, r=alexcrichton
This isn't ready to merge yet.

The 'containers and iterators' guide is basically just a collection of stuff that should be in the module definitions. So I'm moving the guide to just an 'iterators' guide, and moved the info that was there into the right places.

So, is this a good path forward, and is all of the information still correct?
2014-09-15 15:11:12 +00:00
bors
21d1f4d7c0 auto merge of #17195 : tbu-/rust/pr_strfindoverflow2, r=alexcrichton 2014-09-14 10:36:08 +00:00
Steve Klabnik
1b818020a0 Remove container guide.
This isn't really what guides are for, this information belongs in the
module-level docs.

Fixes #9314.
2014-09-13 15:06:00 -04:00
Tobias Bucher
259930e2a3 Document why core::str::Searcher::new doesn't overflow 2014-09-12 15:03:50 +02:00
bors
e9278c9219 auto merge of #17159 : brson/rust/snaps, r=alexcrichton
This switches win64 hosts to bootstrap from win64 snaps.
2014-09-12 11:20:42 +00:00
Ahmed Charles
5b3c3511c9 Fix bug in padding unicode, #17105. 2014-09-11 17:40:46 -07:00
Brian Anderson
38e7e4bd9c Register snapshots 2014-09-10 18:33:54 -07:00
bors
a1f4973090 auto merge of #16662 : pczarn/rust/format-fmtstr-opt, r=brson
Based on an observation that strings and arguments are always interleaved, thanks to #15832. Additionally optimize invocations where formatting parameters are unspecified for all arguments, e.g. `"{} {:?} {:x}"`, by emptying the `__STATIC_FMTARGS` array. Next, `Arguments::new` replaces an empty slice with `None` so that passing empty `__STATIC_FMTARGS` generates slightly less machine code when `Arguments::new` is inlined. Furthermore, formatting itself treats these cases separately without making redundant copies of formatting parameters.

All in all, this adds a single mov instruction per `write!` in most cases. That's why code size has increased.
2014-09-09 23:55:43 +00:00
Piotr Czarnecki
5aaa606932 Optimize for the most common cases of format!
Format specs are ignored and not stored in case they're all default.
Restore default formatting parameters during iteration.
Pass `None` instead of empty slices of format specs to take advantage
of non-nullable pointer optimization.

Generate a call to one of two functions of `fmt::Argument`.
2014-09-09 20:34:41 +01:00
Piotr Czarnecki
696367fb8d Decouple string and argument pieces 2014-09-09 20:34:41 +01:00
Alex Crichton
b8dd7d5056 rollup merge of #17080 : treeman/issue-17066 2014-09-09 12:07:12 -07:00
Nick Cameron
c2fcd4ca72 Check traits for built-in bounds in impls 2014-09-09 10:41:27 +12:00
Jonas Hietala
248319a52e Flip arguments to std::iter::iterate.
Breaks `iterate(f, seed)`, use `iterate(seed, f)` instead.
The convention is to have the closure last.

Closes #17066.

[breaking-change]
2014-09-07 19:44:30 +02:00
bors
1242772cce auto merge of #17005 : bjz/rust/bit-count, r=thestinger
Fixes rust-lang/rfcs#224
2014-09-07 12:41:25 +00:00
bors
09cebc25a3 auto merge of #16999 : brson/rust/fannkuch, r=alexcrichton
From the discussion on reddit:
http://www.reddit.com/r/rust/comments/2fenlg/benchmark_improvement_fannkuchredux/

This adds two variants: the primary, that uses an unsafe block, and a secondary
that is completely safe.

The one with the unsafe block matches clang's performance and beats gcc's.
2014-09-07 00:31:28 +00:00
Brian Anderson
7e12e67936 Optimize Slice::reverse
This makes the completely safe implementation of fannkuchredux perform
the same as C++. Yay, Rust.
2014-09-05 14:12:20 -07:00
Brendan Zabarauskas
88bd646be0 Make integer bit count methods return uints
Fixes rust-lang/rfcs#224
2014-09-05 14:01:41 +10:00
Felix Raimundo
d0f1c7dfb0 Update language item from 'share' to 'sync' #16988 2014-09-05 02:03:26 +02:00
bors
d3e7922ddd auto merge of #16982 : jbcrail/rust/comment-and-string-corrections, r=alexcrichton
I corrected spelling and capitalization errors in comments and strings.
2014-09-04 18:30:59 +00:00
wickerwaka
2bc4a5e92a Center alignment for fmt
Use '^' to specify center alignment in format strings.

fmt!( "[{:^5s}]", "Hi" ) -> "[ Hi  ]"
fmt!( "[{:^5s}]", "H" )  -> "[  H  ]"
fmt!( "[{:^5d}]", 1i )   -> "[  1  ]"
fmt!( "[{:^5d}]", -1i )  -> "[ -1  ]"
fmt!( "[{:^6d}]", 1i )   -> "[  1   ]"
fmt!( "[{:^6d}]", -1i )  -> "[  -1  ]"

If the padding is odd then the padding on the right will be one
character longer than the padding on the left.

Tuples squashed
2014-09-04 07:38:53 -07:00
Joseph Crail
b7bfe04b2d Fix spelling errors and capitalization. 2014-09-03 23:10:38 -04:00
bors
6ac4a30810 auto merge of #16634 : apoelstra/rust/to-option-fix, r=aturon
As outlined in

  https://aturon.github.io/style/naming/conversions.html

`to_` functions names should only be used for expensive operations.
Thus `to_option` is better named `as_option`. Also, putting type
names into method names is considered bad style; what the user is
really trying to get is a reference. This `as_ref` is even better.

Also, we are missing a mutable version of this method.

Finally, there is a bug in the signature of `to_option` which has
been around since lifetime elision: originally the returned reference
had 'static lifetime, but since the elision changes this become
the lifetime of the raw pointer (which does not make sense, since
the pointer lifetime and referent lifetime are unrelated). We fix
the bug to return a reference with a fresh lifetime which will be
inferred from the calling context.

[breaking-change]
2014-09-03 16:01:12 +00:00
nham
d1bcd771a0 Add many comments to TwoWaySearcher. 2014-09-02 01:57:23 -04:00
nham
e9db8adebb core: Make TwoWaySearcher reset its prefix memory when shifting by byteset
Closes #16878.
2014-09-02 01:53:12 -04:00
bors
0bdac78da8 auto merge of #16897 : japaric/rust/mut-slice-collection, r=alexcrichton 2014-09-01 21:31:00 +00:00
bors
eb7589a188 auto merge of #16886 : Tobba/rust/defailbloat-string, r=alexcrichton
by not performing formatting at the failure site

This cuts about 673382 bytes from libcore.rlib
2014-09-01 14:56:08 +00:00
Andrew Poelstra
00ff5aac4e Rename RawPtr::to_option() to RawPtr::as_ref()
As outlined in

  https://aturon.github.io/style/naming/conversions.html

`to_` functions names should only be used for expensive operations.
Thus `to_option` is better named `as_option`. Also, putting type
names into method names is considered bad style; what the user is
really trying to get is a reference. This `as_ref` is even better.

Also, we are missing a mutable version of this method. So add a
new trait `RawMutPtr` with a corresponding `as_mut` methode.

Finally, there is a bug in the signature of `to_option` which has
been around since lifetime elision: originally the returned reference
had 'static lifetime, but since the elision changes this become
the lifetime of the raw pointer (which does not make sense, since
the pointer lifetime and referent lifetime are unrelated). Fix
the bug to return a reference with a fresh lifetime (which will
be inferred from the calling context).

[breaking-change]
2014-08-31 13:33:55 -05:00
Jorge Aparicio
417e4b41bb &mut [T] now implements Collection. Fixes #16896 2014-08-31 02:28:37 -05:00
Alex Crichton
f584392ec9 rollup merge of #16842 : zsiciarz/master 2014-08-30 23:47:38 -07:00
Alex Crichton
0bce667249 rollup merge of #16835 : michaelsproul/doc-slice-failure 2014-08-30 23:47:17 -07:00
Alex Crichton
6b3aa5832f rollup merge of #16769 : rgawdzik/abs_doc_addition 2014-08-30 23:45:52 -07:00
bors
f297366593 auto merge of #16859 : alexcrichton/rust/snapshots, r=huonw 2014-08-30 19:51:25 +00:00
Tobba
e676b73d64 Defailbloat fail!(string) 2014-08-30 20:38:47 +02:00
Alex Crichton
d15d559739 Register new snapshots 2014-08-29 14:33:08 -07:00
P1start
ed2aad8b43 Add lint groups; define built-in lint groups bad_style and unused
This adds support for lint groups to the compiler. Lint groups are a way of
grouping a number of lints together under one name. For example, this also
defines a default lint for naming conventions, named `bad_style`. Writing
`#[allow(bad_style)]` is equivalent to writing
`#[allow(non_camel_case_types, non_snake_case, non_uppercase_statics)]`. These
lint groups can also be defined as a compiler plugin using the new
`Registry::register_lint_group` method.

This also adds two built-in lint groups, `bad_style` and `unused`. The contents
of these groups can be seen by running `rustc -W help`.
2014-08-30 09:12:04 +12:00
P1start
de7abd8824 Unify non-snake-case lints and non-uppercase statics lints
This unifies the `non_snake_case_functions` and `uppercase_variables` lints
into one lint, `non_snake_case`. It also now checks for non-snake-case modules.
This also extends the non-camel-case types lint to check type parameters, and
merges the `non_uppercase_pattern_statics` lint into the
`non_uppercase_statics` lint.

Because the `uppercase_variables` lint is now part of the `non_snake_case`
lint, all non-snake-case variables that start with lowercase characters (such
as `fooBar`) will now trigger the `non_snake_case` lint.

New code should be updated to use the new `non_snake_case` lint instead of the
previous `non_snake_case_functions` and `uppercase_variables` lints. All use of
the `non_uppercase_pattern_statics` should be replaced with the
`non_uppercase_statics` lint. Any code that previously contained non-snake-case
module or variable names should be updated to use snake case names or disable
the `non_snake_case` lint. Any code with non-camel-case type parameters should
be changed to use camel case or disable the `non_camel_case_types` lint.

[breaking-change]
2014-08-30 09:10:05 +12:00
Zbigniew Siciarz
13bb83ce40 Updated mut_chunks doc comment to match argument name. 2014-08-29 10:53:18 +02:00
Michael Sproul
db7c7c23a4 doc: Clarify slice failure conditions. 2014-08-29 11:09:12 +10:00
bors
2e92c67dc0 auto merge of #16664 : aturon/rust/stabilize-option-result, r=alexcrichton
Per API meeting

  https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md

# Changes to `core::option`

Most of the module is marked as stable or unstable; most of the unstable items are awaiting resolution of conventions issues.

However, a few methods have been deprecated, either due to lack of use or redundancy:

* `take_unwrap`, `get_ref` and `get_mut_ref` (redundant, and we prefer for this functionality to go through an explicit .unwrap)
* `filtered` and `while`
* `mutate` and `mutate_or_set`
* `collect`: this functionality is being moved to a new `FromIterator` impl.

# Changes to `core::result`

Most of the module is marked as stable or unstable; most of the unstable items are awaiting resolution of conventions issues.

* `collect`: this functionality is being moved to a new `FromIterator` impl.
* `fold_` is deprecated due to lack of use
* Several methods found in `core::option` are added here, including `iter`, `as_slice`, and variants.

Due to deprecations, this is a:

[breaking-change]
2014-08-28 23:56:20 +00:00
Aaron Turon
9a8233d377 stabilize core::result
Per API meeting

  https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md

Most of the module is marked as stable or unstable; most of the unstable
items are awaiting resolution of conventions issues.

* `collect`: this functionality is being moved to a new `FromIterator`
  impl.
* `fold_` is deprecated due to lack of use
* Several methods found in `core::option` are added here, including
  `iter`, `as_slice`, and variants.

Due to deprecations, this is a:

[breaking-change]
2014-08-28 09:12:54 -07:00
Aaron Turon
276b8b125d Fallout from stabilizing core::option 2014-08-28 09:12:54 -07:00
Aaron Turon
3a52ef4613 stabilize core::option
Per API meeting

  https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md

Most of the module is marked as stable or unstable; most of the unstable
items are awaiting resolution of conventions issues.

However, a few methods have been deprecated, either due to lack of use
or redundancy:

* `take_unwrap`, `get_ref` and `get_mut_ref` (redundant, and we prefer
  for this functionality to go through an explicit .unwrap)
* `filtered` and `while`
* `mutate` and `mutate_or_set`
* `collect`: this functionality is being moved to a new `FromIterator`
  impl.

Due to deprecations, this is a:

[breaking-change]
2014-08-28 09:12:54 -07:00
Niko Matsakis
1b487a8906 Implement generalized object and type parameter bounds (Fixes #16462) 2014-08-27 21:46:52 -04:00
Robert Gawdzik ☢
c09c038e11 Added a note for usage of abs with ::MIN. 2014-08-26 20:45:02 -04:00
Nick Cameron
52ef46251e Rebasing changes 2014-08-26 16:07:32 +12:00
Nick Cameron
3e626375d8 DST coercions and DST structs
[breaking-change]

1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code.

2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible.

3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-26 12:38:51 +12:00
Nick Cameron
37a94b80f2 Use temp vars for implicit coercion to ^[T] 2014-08-26 12:37:45 +12:00
Nick Cameron
34d607f9c9 Use the slice repr for ~[T] 2014-08-26 12:37:45 +12:00
bors
17f79af31c auto merge of #16728 : bluss/rust/zip-next-back, r=alexcrichton
Use ExactSize::len() and defer to its decisions about overly defensive
assertions. Remove the length double-check and simply put a failure
case if the Zip finds an uneven end in .next_back().

Fixing this up since I think I wrote this, and it's been known to
confuse rusties (PR #15886).
2014-08-24 18:46:01 +00:00
Tshepang Lekhonkhobe
0a3073657f doc: fix some typos in the Guide 2014-08-24 17:22:10 +02:00
root
d363770851 libcore: Simplify Enumerate, Zip::next_back
Use ExactSize::len() and defer to its decisions about overly defensive
assertions. Remove the length double-check and simply put a failure
case if the Zip finds an uneven end in .next_back().

Fixing this up since I think I wrote this, and it's been known to
confuse rusties (PR#15886).
2014-08-24 15:11:23 +02:00
bors
d0c314205c auto merge of #16698 : bluss/rust/slice-bloat, r=huonw
These are somewhat stop-gap solutions to address #16625 

core: Separate failure formatting in str methods slice, slice_to, slice_from

Use a separate inline-never function to format failure message for
str::slice() errors.

Using strcat's idea, this makes sure no formatting code from failure is
inlined when str::slice() is inlined. The number of `unreachable` being
inlined when usingi `.slice()` drops from 5 to just 1.



The testcase:

```
#![crate_type = "lib"]
pub fn slice(x: &str, a: uint, b: uint) -> &str {
    x.slice(a, b)
}
```

shrinks from 16.9 kB to 3.3 kB llvm IR, and the number of `unreachable` drops from 5 to 1.
2014-08-24 03:10:59 +00:00
bors
03fd90be45 auto merge of #16612 : nham/rust/twoway_searcher_fix, r=alexcrichton
There is a check in TwoWaySearcher::new to determine whether the needle is periodic. This is needed because during searching when a match fails, we cannot advance the position by the entire length of the needle when it is periodic, but can only advance by the length of the period.

The reason "bananas".contains("nana") (and similar searches) were returning false was because the periodicity check was wrong.

Closes #16589

Also, thanks to @Gankro, who came up with many buggy examples.
2014-08-23 18:00:59 +00:00
root
b3b7c2e97b core: Separate failure formatting in str methods slice, slice_to, slice_from
Use a separate inline-never function to format failure message for
str::slice() errors.

Using strcat's idea, this makes sure no formatting code from failure is
inlined when str::slice() is inlined. The number of `unreachable` being
inlined when usingi `.slice()` drops from 5 to just 1.
2014-08-23 13:49:19 +02:00
nham
9a43492f59 Improve TwoWaySearcher comments. 2014-08-22 22:34:14 -04:00
bors
07d86b46a9 auto merge of #16509 : luqmana/rust/uw, r=alexcrichton
Fixes #15401.
2014-08-22 02:40:56 +00:00
Corey Richardson
cf5d28083d libgreen: use FFI-safe types 2014-08-20 21:02:24 -04:00
nham
9419e92659 Fix TwoWaySearcher to work when used with periodic needles.
There is a check in TwoWaySearcher::new to determine whether the needle
is periodic. This is needed because during searching when a match fails,
we cannot advance the position by the entire length of the needle when
it is periodic, but can only advance by the length of the period.

The reason "bananas".contains("nana") (and similar searches) were
returning false was because the periodicity check was wrong.

Closes #16589
2014-08-20 02:51:22 -04:00
nham
0821119edd Add examples for some StrSlice methods. 2014-08-19 18:51:58 -04:00
bors
3f5d0b5b6c auto merge of #16590 : nham/rust/str_searcher_underflow, r=alexcrichton
This incidentally fixes #16589, because it will cause `MatchIndices` to use `NaiveSearcher` instead of `TwoWaySearcher`, but I'm not sure #16589 should be closed until the underlying problem in `TwoWaySearcher` is found.
2014-08-19 16:35:51 +00:00
bors
d16a5cd7c4 auto merge of #16364 : tbu-/rust/pr_checkeddiv0, r=alexcrichton 2014-08-19 06:50:55 +00:00
bors
fb4201ff34 auto merge of #16579 : steveklabnik/rust/gh9099, r=pcwalton
Fixes #9099
2014-08-18 22:46:19 +00:00
nham
a4bbb5bab4 Fix underflow bug in core::str::Searcher::new for haystacks of length < 20 2014-08-18 17:51:51 -04:00
Steve Klabnik
46f27c9d96 Improve text of Option.unwrap()
Fixes #9099
2014-08-18 13:47:13 -04:00
Patrick Walton
67deb2e65e libsyntax: Remove the use foo = bar syntax from the language in favor
of `use bar as foo`.

Change all uses of `use foo = bar` to `use bar as foo`.

Implements RFC #47.

Closes #16461.

[breaking-change]
2014-08-18 09:19:10 -07:00
bors
cb9c1e0e70 auto merge of #16498 : Kimundi/rust/inline-utf-encoding, r=alexcrichton
The first commit improves code generation through a few changes:
- The `#[inline]` attributes allow llvm to constant fold the encoding step away in certain situations. For example, code like this changes from a call to `encode_utf8` in a inner loop to the pushing of a byte constant:

 ```rust
let mut s = String::new();
for _ in range(0u, 21) {
        s.push_char('a');
}
```
- Both methods changed their semantic from causing run time failure if the target buffer is not large enough to returning `None` instead. This makes llvm no longer emit code for causing failure for these methods.
- A few debug `assert!()` calls got removed because they affected code generation due to unwinding, and where basically unnecessary with today's sound handling of `char` as a Unicode scalar value.

~~The second commit is optional. It changes the methods from regular indexing with the `dst[i]` syntax to unsafe indexing with `dst.unsafe_mut_ref(i)`. This does not change code generation directly - in both cases llvm is smart enough to see that there can never be an out-of-bounds access. But it makes it emit a `nounwind` attribute for the function. 
However, I'm not sure whether that is a real improvement, so if there is any objection to this I'll remove the commit.~~

This changes how the methods behave on a too small buffer, so this is a 

[breaking-change]
2014-08-17 04:42:32 +00:00
Patrick Walton
7f928d150e librustc: Forbid external crates, imports, and/or items from being
declared with the same name in the same scope.

This breaks several common patterns. First are unused imports:

    use foo::bar;
    use baz::bar;

Change this code to the following:

    use baz::bar;

Second, this patch breaks globs that import names that are shadowed by
subsequent imports. For example:

    use foo::*; // including `bar`
    use baz::bar;

Change this code to remove the glob:

    use foo::{boo, quux};
    use baz::bar;

Or qualify all uses of `bar`:

    use foo::{boo, quux};
    use baz;

    ... baz::bar ...

Finally, this patch breaks code that, at top level, explicitly imports
`std` and doesn't disable the prelude.

    extern crate std;

Because the prelude imports `std` implicitly, there is no need to
explicitly import it; just remove such directives.

The old behavior can be opted into via the `import_shadowing` feature
gate. Use of this feature gate is discouraged.

This implements RFC #116.

Closes #16464.

[breaking-change]
2014-08-16 19:32:25 -07:00
Marvin Löbel
13079c1a85 Optimized IR generation for UTF-8 and UTF-16 encoding
- Both can now be inlined and constant folded away
- Both can no longer cause failure
- Both now return an `Option` instead

Removed debug `assert!()`s over the valid ranges of a `char`
- It affected optimizations due to unwinding
- Char handling is now sound enought that they became uneccessary
2014-08-16 21:13:39 +02:00
Alex Crichton
8f16aa748c Register new snapshots
Hopefully this will fix #16489!
2014-08-15 22:16:10 -07:00
Luqman Aden
715abbdc9c libcore: Get rid of useless mem::forget wrapper. 2014-08-14 19:07:56 -04:00
bors
e99eeb574e auto merge of #16470 : liigo/rust/rename-private-cmp-macros, r=brson
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-14 13:01:18 +00:00
Brian Anderson
c3b9d5df62 Address some review feedback 2014-08-13 15:27:40 -07:00
Brian Anderson
bc450b17e3 core: Change the argument order on splitn and rsplitn for strs.
This makes it consistent with the same functions for slices,
and allows the search closure to be specified last.

[breaking-change]
2014-08-13 15:27:37 -07:00
Brian Anderson
4e1024f8d3 core: Put stability attributes all over the slice module
Much of this is as discussed[1]. Many things are marked

[1]: https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md
2014-08-13 15:27:34 -07:00
Brian Anderson
a4b354ca02 core: Add binary_search and binary_search_elem methods to slices.
These are like the existing bsearch methods but if the search fails,
it returns the next insertion point.

The new `binary_search` returns a `BinarySearchResult` that is either
`Found` or `NotFound`. For convenience, the `found` and `not_found`
methods convert to `Option`, ala `Result`.

Deprecate bsearch and bsearch_elem.
2014-08-13 11:30:15 -07:00
Brian Anderson
76d46af6d4 core: Rename ImmutableEqSlice to ImmutablePartialEqSlice
This is in the prelude and won't break much code.

[breaking-change]
2014-08-13 11:30:15 -07:00
Brian Anderson
c9abc01a98 core: Rename MutableCloneableSlice::copy_from to clone_from_slice
Deprecate the previous.
2014-08-13 11:30:15 -07:00
Brian Anderson
d4c736b1f0 core: Deprecate ImmutableSlice::tailn and initn
These are equivalent to slice_from and slice_to.
2014-08-13 11:30:15 -07:00
Brian Anderson
033f28d436 core: Rename ImmutableSlice::unsafe_ref to unsafe_get
Deprecate the previous.
2014-08-13 11:30:14 -07:00
Brian Anderson
fbc93082ec std: Rename slice::Vector to Slice
This required some contortions because importing both raw::Slice
and slice::Slice makes rustc crash.

Since `Slice` is in the prelude, this renaming is unlikely to
casue breakage.

[breaking-change]
2014-08-13 11:30:14 -07:00
Brian Anderson
4f5b6927e8 std: Rename various slice traits for consistency
ImmutableVector -> ImmutableSlice
ImmutableEqVector -> ImmutableEqSlice
ImmutableOrdVector -> ImmutableOrdSlice
MutableVector -> MutableSlice
MutableVectorAllocating -> MutableSliceAllocating
MutableCloneableVector -> MutableCloneableSlice
MutableOrdVector -> MutableOrdSlice

These are all in the prelude so most code will not break.

[breaking-change]
2014-08-13 11:30:14 -07:00
Liigo Zhuang
0186246afe libcore: rename private cmp macros
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-13 11:41:29 +08:00
bors
e2273d9456 auto merge of #16081 : luqmana/rust/nr, r=pcwalton
Fixes #15763
2014-08-12 18:16:33 +00:00
nham
04233a1675 Change std::fmt::{Float,LowerExp,UpperExp} to not print '-NaN' for f32::NAN and f64::NAN 2014-08-11 22:24:01 -04:00
Luqman Aden
5aedcb1e91 librustc: Don't allow return_address intrinsic in functions that don't use an out pointer. 2014-08-11 19:20:10 -07:00
Huon Wilson
07aadc2e8b core/std: squash dead_code warnings from fail! invocations.
The fail macro defines some function/static items internally, which got
a dead_code warning when `fail!()` is used inside a dead function. This
is ugly and unnecessarily reveals implementation details, so the
warnings can be squashed.

Fixes #16192.
2014-08-11 18:26:31 +10:00
Tobias Bucher
cd6eb12270 Add division by zero case to the CheckedDiv comment 2014-08-08 22:45:50 +02:00
Ruud van Asseldonk
c56fa5f266 libcore: Fix documentation comment for f32. 2014-08-08 18:30:23 +02:00
Niko Matsakis
4fd797e757 Register new snapshot 12e0f72 2014-08-08 07:55:00 -04:00
bors
aae7901a78 auto merge of #16285 : alexcrichton/rust/rename-share, r=huonw
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use`
statement, but the `NoShare` struct is no longer part of `std::kinds::marker`
due to #12660 (the build cannot bootstrap otherwise).

All code referencing the `Share` trait should now reference the `Sync` trait,
and all code referencing the `NoShare` type should now reference the `NoSync`
type. The functionality and meaning of this trait have not changed, only the
naming.

Closes #16281
[breaking-change]
2014-08-08 03:51:15 +00:00
Alex Crichton
1f760d5d1a Rename Share to Sync
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use`
statement, but the `NoShare` struct is no longer part of `std::kinds::marker`
due to #12660 (the build cannot bootstrap otherwise).

All code referencing the `Share` trait should now reference the `Sync` trait,
and all code referencing the `NoShare` type should now reference the `NoSync`
type. The functionality and meaning of this trait have not changed, only the
naming.

Closes #16281
[breaking-change]
2014-08-07 08:54:38 -07:00
bors
e9c5c4c9bd auto merge of #16316 : forticulous/rust/char-Fix, r=alexcrichton
Signature for `from_digit` in `Char` wasn't using `Self` so there was no way to use this method
2014-08-07 04:21:04 +00:00
fort
ef03363059 Char::from_digit signature fix 2014-08-06 18:46:54 -07:00
bors
8fe73f1166 auto merge of #16291 : nham/rust/byte_literals, r=alexcrichton
This replaces many instances chars being casted to u8 with byte literals.
2014-08-06 23:41:05 +00:00
bors
b9308d1ff0 auto merge of #16225 : pczarn/rust/iter-refactoring, r=kballard
Simplifying the code of methods: `nth`, `fold`, `rposition`, and iterators: `Filter`, `FilterMap`, `SkipWhile`.

```
before
test iter::bench_multiple_take      ... bench:        15 ns/iter (+/- 0)
test iter::bench_rposition          ... bench:       349 ns/iter (+/- 94)
test iter::bench_skip_while         ... bench:       158 ns/iter (+/- 6)

after
test iter::bench_multiple_take      ... bench:        15 ns/iter (+/- 0)
test iter::bench_rposition          ... bench:       314 ns/iter (+/- 2)
test iter::bench_skip_while         ... bench:       107 ns/iter (+/- 0)
```
@koalazen has the code for `Skip`.

Once #16011 is fixed, `min_max` could use a for loop.
2014-08-06 21:56:07 +00:00
bors
8fcfd02d85 auto merge of #16276 : nham/rust/fix_marker_docs, r=steveklabnik 2014-08-06 13:21:27 +00:00
Piotr Czarnecki
a55149b84e core: Refactor iterators
Simplifying the code of methods: nth, fold, rposition
and iterators: Filter, FilterMap, SkipWhile
Adding basic benchmarks
2014-08-06 11:20:37 +01:00
bors
84782c4e26 auto merge of #16258 : aturon/rust/stabilize-atomics, r=alexcrichton
This commit stabilizes the `std::sync::atomics` module, renaming it to
`std::sync::atomic` to match library precedent elsewhere, and tightening
up behavior around incorrect memory ordering annotations.

The vast majority of the module is now `stable`. However, the
`AtomicOption` type has been deprecated, since it is essentially unused
and is not truly a primitive atomic type. It will eventually be replaced
by a higher-level abstraction like MVars.

Due to deprecations, this is a:

[breaking-change]
2014-08-06 08:31:28 +00:00
nham
6df514b061 Use byte literals in libcore 2014-08-06 02:30:17 -04:00
nham
8650040b8a Remove references to ~[] in core::kinds::marker docs. 2014-08-05 15:23:23 -04:00
bors
ade92c6e35 auto merge of #16188 : nham/rust/immut_slice_split_at, r=brson
This operation seems common enough that it would be convenient for it to be a standard method.
2014-08-05 03:21:27 +00:00
bors
4b54110c33 auto merge of #16187 : steveklabnik/rust/gh15830, r=alexcrichton
Fixes #15830.
2014-08-05 01:41:25 +00:00
Aaron Turon
68bde0a073 stabilize atomics (now atomic)
This commit stabilizes the `std::sync::atomics` module, renaming it to
`std::sync::atomic` to match library precedent elsewhere, and tightening
up behavior around incorrect memory ordering annotations.

The vast majority of the module is now `stable`. However, the
`AtomicOption` type has been deprecated, since it is essentially unused
and is not truly a primitive atomic type. It will eventually be replaced
by a higher-level abstraction like MVars.

Due to deprecations, this is a:

[breaking-change]
2014-08-04 16:03:21 -07:00
Steve Klabnik
acf66b1027 Clarify Argument docs.
Fixes #15830.
2014-08-04 18:05:10 -04:00
OGINO Masanori
3e6edee002 num: Fix the documentation of abs_sub.
Use proper argument names and unbackquote the word "zero" because it is
not an identifier.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-08-04 14:04:28 +09:00
bors
ce01b4b1b7 auto merge of #16155 : huonw/rust/Ordering-reverse, r=alexcrichton
This flips the comparison and is designed to be used when sorting etc.
2014-08-03 06:31:09 +00:00
Huon Wilson
7df277115a core: add a reverse method to Ordering.
This flips the comparison and is designed to be used when sorting etc.
2014-08-03 11:50:19 +10:00
nham
7e5440ea9d Add a split_at method to slice::ImmutableVector
This method is similar to the mut_split_at method of slice::MutableVector.
2014-08-01 23:05:16 -04:00
Joseph Crail
ad06dfe496 Fix misspelled comments. 2014-08-01 19:42:52 -04:00
bors
cd1216a054 auto merge of #16152 : tshepang/rust/patch-1, r=alexcrichton 2014-08-01 07:56:06 +00:00
Tshepang Lekhonkhobe
4dc323f019 doc: fix typos in std::num::Int 2014-08-01 02:43:51 +02:00
Derek Harland
2467c6e5a7 Implement slice::Vector for Option<T> and CVec<T> 2014-07-31 11:50:24 -07:00
Tobias Bucher
4c196c27c4 Fix deprecation commment on core::cmp::lexical_ordering 2014-07-31 07:30:45 -07:00
Brian Anderson
4562803a3d core: Fix failure doc comment 2014-07-31 07:30:17 -07:00
Brian Anderson
678814aafa core: Add #[inline(never)] to failure functions
For consistency, just because `fail_` has it.
2014-07-31 07:30:17 -07:00
Brian Anderson
4db68e644e Modify failure lang items to take less pointers.
Divide-by-zero before:

```
        leaq    "str\"str\"(1762)"(%rip), %rax
        movq    %rax, 16(%rsp)
        movq    $27, 24(%rsp)
        leaq    "str\"str\"(1542)"(%rip), %rax
        movq    %rax, (%rsp)
        movq    $19, 8(%rsp)
        leaq    16(%rsp), %rdi
        leaq    (%rsp), %rsi
        movl    $32, %edx
        callq   _ZN7failure5fail_20hc04408f955ce60aaqWjE@PLT
```

After:

```
        leaq    .Lconst(%rip), %rdi
        callq   _ZN7failure5fail_20haf918a97c8f7f2bfqWjE@PLT
```

Bounds check before:

```
        leaq    "str\"str\"(1542)"(%rip), %rax
        movq    %rax, 8(%rsp)
        movq    $19, 16(%rsp)
        leaq    8(%rsp), %rdi
        movl    $38, %esi
        movl    $1, %edx
        movl    $1, %ecx
        callq   _ZN7failure17fail_bounds_check20hf4bc3c69e96caf41RXjE@PLT
```

Bounds check after:

```
        leaq    .Lconst2(%rip), %rdi
        movl    $1, %esi
        movl    $1, %edx
        callq   _ZN7failure17fail_bounds_check20h5267276a537a7de22XjE@PLT
```

Size before:

21277995 librustc-4e7c5e5c.s

```
text       data
12554881   6089335
```

Size after:

21247617 librustc-4e7c5e5c.so

```
text       data
12518497   6095748
```
2014-07-31 07:30:17 -07:00
Piotr Jawniak
f399d30802 Improve documentation of rounding functions 2014-07-29 15:43:59 -07:00
bors
279a780804 auto merge of #15983 : brson/rust/fail, r=alexcrichton
A few refactorings to decrease text size and increase data size. I'm not sure about this tradeoff. Various stats below. cc @pcwalton

This reduces the code needed to pass arguments for `fail!()`, `fail!("{}", ...)`, and to a lesser extent `fail!("...")`. Still more work to be done on compiler-generated failures and the `fail!("...")` case.

do_fail_empty:

```
#[inline(never)]
fn do_fail_empty() {
    fail!()
}
```

do_fail_empty before:

```
	leaq	8(%rsp), %rdi
	movabsq	$13, %rsi
	leaq	"str\"str\"(1494)"(%rip), %rax
	movq	%rax, 8(%rsp)
	movq	$19, 16(%rsp)
	callq	_ZN6unwind31begin_unwind_no_time_to_explain20h57030457935ab6111SdE@PLT
```

do_fail_empty after:

```
	leaq	_ZN13do_fail_empty9file_line20h339df6a0541e837eIaaE(%rip), %rdi
	callq	_ZN6unwind31begin_unwind_no_time_to_explain20h33184cfdcce4dfd8QTdE@PLT
```

do_fail_fmt:

```
#[inline(never)]
fn do_fail_fmt() {
    fail!("guh{}", "faw")
}
```

do_fail_fmt before:

```
        ... (snip lots of fmt stuff)
	callq	_ZN3fmt22Arguments$LT$$x27a$GT$3new20he09b3a3f473879c41paE
	leaq	144(%rsp), %rsi
	movabsq	$23, %rdx
	leaq	"str\"str\"(1494)"(%rip), %rax
	leaq	32(%rsp), %rcx
	movq	%rcx, 160(%rsp)
	movq	160(%rsp), %rdi
	movq	%rax, 144(%rsp)
	movq	$19, 152(%rsp)
	callq	_ZN6unwind16begin_unwind_fmt20h3ebeb42f4d189b2buQdE@PLT
```

do_fail_fmt after:

```
        ... (snip lots of fmt stuff)
	callq	_ZN3fmt22Arguments$LT$$x27a$GT$3new20h42e5bb8d1711ee61OqaE
	leaq	_ZN11do_fail_fmt7run_fmt9file_line20h339df6a0541e837eFbaE(%rip), %rsi
	leaq	32(%rsp), %rax
	movq	%rax, 144(%rsp)
	movq	144(%rsp), %rdi
	callq	_ZN6unwind16begin_unwind_fmt20hfdcadc14d188656biRdE@PLT
```

File size increases.

file size before:

```
-rw-rw-r-- 1 brian brian 100501740 Jul 24 23:28 /home/brian/dev/rust2/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-4e7c5e5c.rlib
-rwxrwxr-x 1 brian brian  21201780 Jul 24 23:27 /home/brian/dev/rust2/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-4e7c5e5c.so
```

file size after:

```
-rw-rw-r-- 1 brian brian 101542484 Jul 25 00:34 x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-4e7c5e5c.rlib
-rwxrwxr-x 1 brian brian  21348862 Jul 25 00:34 x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-4e7c5e5c.so
```

Text size decreases by 52486 while data size increases by 143686.

section size before:

```
   text    data     bss     dec     hex filename
12712262        5924997     368 18637627        11c633b x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-4e7c5e5c.so
```

section size after:

```
   text    data     bss     dec     hex filename
12659776        6068683     368 18728827        11dc77b /home/brian/dev/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-4e7c5e5c.so
```

I don't know if anything can be learned from these benchmarks. Looks like a wash.

std bench before:

```
test collections::hashmap::bench::find_existing             ... bench:     43452 ns/iter (+/- 2423)
test collections::hashmap::bench::find_nonexisting          ... bench:     42416 ns/iter (+/- 3996)
test collections::hashmap::bench::find_pop_insert           ... bench:       214 ns/iter (+/- 11)
test collections::hashmap::bench::hashmap_as_queue          ... bench:       123 ns/iter (+/- 6)
test collections::hashmap::bench::insert                    ... bench:       153 ns/iter (+/- 14)
test collections::hashmap::bench::new_drop                  ... bench:       547 ns/iter (+/- 259)
test collections::hashmap::bench::new_insert_drop           ... bench:       682 ns/iter (+/- 366)
test io::buffered::test::bench_buffered_reader              ... bench:      1046 ns/iter (+/- 86)
test io::buffered::test::bench_buffered_stream              ... bench:      2156 ns/iter (+/- 801)
test io::buffered::test::bench_buffered_writer              ... bench:      1057 ns/iter (+/- 75)
test io::extensions::bench::u64_from_be_bytes_4_aligned     ... bench:        80 ns/iter (+/- 5)
test io::extensions::bench::u64_from_be_bytes_4_unaligned   ... bench:        81 ns/iter (+/- 6)
test io::extensions::bench::u64_from_be_bytes_7_aligned     ... bench:        80 ns/iter (+/- 4)
test io::extensions::bench::u64_from_be_bytes_7_unaligned   ... bench:        69 ns/iter (+/- 4)
test io::extensions::bench::u64_from_be_bytes_8_aligned     ... bench:        69 ns/iter (+/- 3)
test io::extensions::bench::u64_from_be_bytes_8_unaligned   ... bench:        81 ns/iter (+/- 4)
test io::mem::test::bench_buf_reader                        ... bench:       628 ns/iter (+/- 18)
test io::mem::test::bench_buf_writer                        ... bench:       478 ns/iter (+/- 19)
test io::mem::test::bench_mem_reader                        ... bench:       712 ns/iter (+/- 44)
test io::mem::test::bench_mem_writer_001_0000               ... bench:        31 ns/iter (+/- 1)
test io::mem::test::bench_mem_writer_001_0010               ... bench:        51 ns/iter (+/- 3)
test io::mem::test::bench_mem_writer_001_0100               ... bench:       121 ns/iter (+/- 8)
test io::mem::test::bench_mem_writer_001_1000               ... bench:       774 ns/iter (+/- 47)
test io::mem::test::bench_mem_writer_100_0000               ... bench:       756 ns/iter (+/- 50)
test io::mem::test::bench_mem_writer_100_0010               ... bench:      2726 ns/iter (+/- 198)
test io::mem::test::bench_mem_writer_100_0100               ... bench:      8961 ns/iter (+/- 712)
test io::mem::test::bench_mem_writer_100_1000               ... bench:    105673 ns/iter (+/- 24711)
test num::bench::bench_pow_function                         ... bench:      5849 ns/iter (+/- 371)
test num::strconv::bench::f64::float_to_string              ... bench:       662 ns/iter (+/- 202)
test num::strconv::bench::int::to_str_base_36               ... bench:       424 ns/iter (+/- 7)
test num::strconv::bench::int::to_str_bin                   ... bench:      1227 ns/iter (+/- 80)
test num::strconv::bench::int::to_str_dec                   ... bench:       466 ns/iter (+/- 13)
test num::strconv::bench::int::to_str_hex                   ... bench:       498 ns/iter (+/- 22)
test num::strconv::bench::int::to_str_oct                   ... bench:       502 ns/iter (+/- 229)
test num::strconv::bench::uint::to_str_base_36              ... bench:       375 ns/iter (+/- 7)
test num::strconv::bench::uint::to_str_bin                  ... bench:      1011 ns/iter (+/- 590)
test num::strconv::bench::uint::to_str_dec                  ... bench:       407 ns/iter (+/- 17)
test num::strconv::bench::uint::to_str_hex                  ... bench:       442 ns/iter (+/- 7)
test num::strconv::bench::uint::to_str_oct                  ... bench:       433 ns/iter (+/- 46)
test path::posix::bench::ends_with_path_home_dir            ... bench:       167 ns/iter (+/- 10)
test path::posix::bench::ends_with_path_missmatch_jome_home ... bench:       148 ns/iter (+/- 6)
test path::posix::bench::is_ancestor_of_path_with_10_dirs   ... bench:       221 ns/iter (+/- 31)
test path::posix::bench::join_abs_path_home_dir             ... bench:       144 ns/iter (+/- 23)
test path::posix::bench::join_home_dir                      ... bench:       196 ns/iter (+/- 9)
test path::posix::bench::join_many_abs_path_home_dir        ... bench:       143 ns/iter (+/- 6)
test path::posix::bench::join_many_home_dir                 ... bench:       195 ns/iter (+/- 8)
test path::posix::bench::path_relative_from_backward        ... bench:       248 ns/iter (+/- 10)
test path::posix::bench::path_relative_from_forward         ... bench:       241 ns/iter (+/- 13)
test path::posix::bench::path_relative_from_same_level      ... bench:       296 ns/iter (+/- 11)
test path::posix::bench::push_abs_path_home_dir             ... bench:       104 ns/iter (+/- 7)
test path::posix::bench::push_home_dir                      ... bench:     27311 ns/iter (+/- 2727)
test path::posix::bench::push_many_abs_path_home_dir        ... bench:       109 ns/iter (+/- 5)
test path::posix::bench::push_many_home_dir                 ... bench:     23263 ns/iter (+/- 1726)
test rand::bench::rand_isaac                                ... bench:       884 ns/iter (+/- 31) = 904 MB/s
test rand::bench::rand_isaac64                              ... bench:       440 ns/iter (+/- 126) = 1818 MB/s
test rand::bench::rand_shuffle_100                          ... bench:      2518 ns/iter (+/- 1371)
test rand::bench::rand_std                                  ... bench:       429 ns/iter (+/- 17) = 1864 MB/s
test rand::bench::rand_xorshift                             ... bench:         0 ns/iter (+/- 0) = 800000 MB/s
```

std bench after:

```
test collections::hashmap::bench::find_existing             ... bench:     43635 ns/iter (+/- 4508)
test collections::hashmap::bench::find_nonexisting          ... bench:     42323 ns/iter (+/- 1753)
test collections::hashmap::bench::find_pop_insert           ... bench:       216 ns/iter (+/- 11)
test collections::hashmap::bench::hashmap_as_queue          ... bench:       125 ns/iter (+/- 8)
test collections::hashmap::bench::insert                    ... bench:       153 ns/iter (+/- 63)
test collections::hashmap::bench::new_drop                  ... bench:       517 ns/iter (+/- 282)
test collections::hashmap::bench::new_insert_drop           ... bench:       734 ns/iter (+/- 264)
test io::buffered::test::bench_buffered_reader              ... bench:      1063 ns/iter (+/- 206)
test io::buffered::test::bench_buffered_stream              ... bench:      2321 ns/iter (+/- 2302)
test io::buffered::test::bench_buffered_writer              ... bench:      1060 ns/iter (+/- 24)
test io::extensions::bench::u64_from_be_bytes_4_aligned     ... bench:        69 ns/iter (+/- 2)
test io::extensions::bench::u64_from_be_bytes_4_unaligned   ... bench:        81 ns/iter (+/- 7)
test io::extensions::bench::u64_from_be_bytes_7_aligned     ... bench:        70 ns/iter (+/- 5)
test io::extensions::bench::u64_from_be_bytes_7_unaligned   ... bench:        69 ns/iter (+/- 5)
test io::extensions::bench::u64_from_be_bytes_8_aligned     ... bench:        80 ns/iter (+/- 6)
test io::extensions::bench::u64_from_be_bytes_8_unaligned   ... bench:        81 ns/iter (+/- 5)
test io::mem::test::bench_buf_reader                        ... bench:       663 ns/iter (+/- 44)
test io::mem::test::bench_buf_writer                        ... bench:       489 ns/iter (+/- 17)
test io::mem::test::bench_mem_reader                        ... bench:       700 ns/iter (+/- 23)
test io::mem::test::bench_mem_writer_001_0000               ... bench:        31 ns/iter (+/- 3)
test io::mem::test::bench_mem_writer_001_0010               ... bench:        49 ns/iter (+/- 5)
test io::mem::test::bench_mem_writer_001_0100               ... bench:       112 ns/iter (+/- 6)
test io::mem::test::bench_mem_writer_001_1000               ... bench:       765 ns/iter (+/- 59)
test io::mem::test::bench_mem_writer_100_0000               ... bench:       727 ns/iter (+/- 54)
test io::mem::test::bench_mem_writer_100_0010               ... bench:      2586 ns/iter (+/- 215)
test io::mem::test::bench_mem_writer_100_0100               ... bench:      8846 ns/iter (+/- 439)
test io::mem::test::bench_mem_writer_100_1000               ... bench:    105747 ns/iter (+/- 17443)
test num::bench::bench_pow_function                         ... bench:      5844 ns/iter (+/- 421)
test num::strconv::bench::f64::float_to_string              ... bench:       669 ns/iter (+/- 571)
test num::strconv::bench::int::to_str_base_36               ... bench:       417 ns/iter (+/- 24)
test num::strconv::bench::int::to_str_bin                   ... bench:      1216 ns/iter (+/- 36)
test num::strconv::bench::int::to_str_dec                   ... bench:       466 ns/iter (+/- 24)
test num::strconv::bench::int::to_str_hex                   ... bench:       492 ns/iter (+/- 8)
test num::strconv::bench::int::to_str_oct                   ... bench:       496 ns/iter (+/- 295)
test num::strconv::bench::uint::to_str_base_36              ... bench:       366 ns/iter (+/- 8)
test num::strconv::bench::uint::to_str_bin                  ... bench:      1005 ns/iter (+/- 69)
test num::strconv::bench::uint::to_str_dec                  ... bench:       396 ns/iter (+/- 20)
test num::strconv::bench::uint::to_str_hex                  ... bench:       435 ns/iter (+/- 4)
test num::strconv::bench::uint::to_str_oct                  ... bench:       436 ns/iter (+/- 451)
test path::posix::bench::ends_with_path_home_dir            ... bench:       171 ns/iter (+/- 6)
test path::posix::bench::ends_with_path_missmatch_jome_home ... bench:       152 ns/iter (+/- 6)
test path::posix::bench::is_ancestor_of_path_with_10_dirs   ... bench:       215 ns/iter (+/- 8)
test path::posix::bench::join_abs_path_home_dir             ... bench:       143 ns/iter (+/- 6)
test path::posix::bench::join_home_dir                      ... bench:       192 ns/iter (+/- 29)
test path::posix::bench::join_many_abs_path_home_dir        ... bench:       144 ns/iter (+/- 9)
test path::posix::bench::join_many_home_dir                 ... bench:       194 ns/iter (+/- 19)
test path::posix::bench::path_relative_from_backward        ... bench:       254 ns/iter (+/- 15)
test path::posix::bench::path_relative_from_forward         ... bench:       244 ns/iter (+/- 17)
test path::posix::bench::path_relative_from_same_level      ... bench:       293 ns/iter (+/- 27)
test path::posix::bench::push_abs_path_home_dir             ... bench:       108 ns/iter (+/- 5)
test path::posix::bench::push_home_dir                      ... bench:     32292 ns/iter (+/- 4361)
test path::posix::bench::push_many_abs_path_home_dir        ... bench:       108 ns/iter (+/- 6)
test path::posix::bench::push_many_home_dir                 ... bench:     20305 ns/iter (+/- 1331)
test rand::bench::rand_isaac                                ... bench:       888 ns/iter (+/- 35) = 900 MB/s
test rand::bench::rand_isaac64                              ... bench:       439 ns/iter (+/- 17) = 1822 MB/s
test rand::bench::rand_shuffle_100                          ... bench:      2582 ns/iter (+/- 1001)
test rand::bench::rand_std                                  ... bench:       431 ns/iter (+/- 93) = 1856 MB/s
test rand::bench::rand_xorshift                             ... bench:         0 ns/iter (+/- 0) = 800000 MB/s
```
2014-07-28 20:51:33 +00:00
Brian Anderson
f49f1575aa Use correct conventions for static 2014-07-28 13:40:55 -07:00
Alex Crichton
e5da6a71a6 std: Stabilize unit, bool, ty, tuple, arc, any
This commit applies stability attributes to the contents of these modules,
summarized here:

* The `unit` and `bool` modules have become #[unstable] as they are purely meant
  for documentation purposes and are candidates for removal.

* The `ty` module has been deprecated, and the inner `Unsafe` type has been
  renamed to `UnsafeCell` and moved to the `cell` module. The `marker1` field
  has been removed as the compiler now always infers `UnsafeCell` to be
  invariant. The `new` method i stable, but the `value` field, `get` and
  `unwrap` methods are all unstable.

* The `tuple` module has its name as stable, the naming of the `TupleN` traits
  as stable while the methods are all #[unstable]. The other impls in the module
  have appropriate stability for the corresponding trait.

* The `arc` module has received the exact same treatment as the `rc` module
  previously did.

* The `any` module has its name as stable. The `Any` trait is also stable, with
  a new private supertrait which now contains the `get_type_id` method. This is
  to make the method a private implementation detail rather than a public-facing
  detail.

  The two extension traits in the module are marked #[unstable] as they will not
  be necessary with DST. The `is` method is #[stable], the as_{mut,ref} methods
  have been renamed to downcast_{mut,ref} and are #[unstable].

  The extension trait `BoxAny` has been clarified as to why it is unstable as it
  will not be necessary with DST.

This is a breaking change because the `marker1` field was removed from the
`UnsafeCell` type. To deal with this change, you can simply delete the field and
only specify the value of the `data` field in static initializers.

[breaking-change]
2014-07-26 13:12:20 -07:00
bors
c0fa8764ef auto merge of #15982 : alexcrichton/rust/rustdoc-fixes, r=brson
Sadly there's still a lot of open issues, but this tackles some of the more pressing ones. Each commit has its own description along with the issues it closes.
2014-07-26 06:56:23 +00:00
Brian Anderson
a43e7d5cb9 core: Remove unneeded cfgs 2014-07-25 15:54:10 -07:00
Alex Crichton
724bcec089 rustdoc: Hide impls for #[doc(hidden)] traits
Closes #14585
2014-07-25 08:26:17 -07:00
Randati
c7700077a1 Fix assert message 2014-07-25 18:12:21 +03:00
Patrick Walton
f1520ea0cf librustc: Check built-in trait bounds on implementations when direct
method calls are involved.

This breaks code like:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = box 3i; // note no `Copy` bound
        take_param(&x);
    }

Change this code to not contain a type error. For example:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = 3i; // satisfies `Copy` bound
        take_param(&x);
    }

Closes #15860.

[breaking-change]
2014-07-25 00:50:35 -07:00
Brian Anderson
f7ab07c780 Put the struct passed to unwinding functions into a static
Produces very clean asm, but makes bigger binaries.
2014-07-25 00:40:58 -07:00
Brian Anderson
4636b32a42 Make most of the failure functions take &(&'static str, uint)
Passing one pointer takes less code than one pointer and an integer.
2014-07-25 00:02:29 -07:00
Patrick Walton
caa564bea3 librustc: Stop desugaring for expressions and translate them directly.
This makes edge cases in which the `Iterator` trait was not in scope
and/or `Option` or its variants were not in scope work properly.

This breaks code that looks like:

    struct MyStruct { ... }

    impl MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

    for x in MyStruct { ... } { ... }

Change ad-hoc `next` methods like the above to implementations of the
`Iterator` trait. For example:

    impl Iterator<int> for MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

Closes #15392.

[breaking-change]
2014-07-24 18:58:12 -07:00
Patrick Walton
3550068b53 librustc: Make bare functions implement the FnMut trait.
This is done entirely in the libraries for functions up to 16 arguments.
A macro is used so that more arguments can be easily added if we need.
Note that I had to adjust the overloaded call algorithm to not try
calling the overloaded call operator if the callee is a built-in
function type, to prevent loops.

Closes #15448.
2014-07-24 07:26:22 -07:00
nham
62bddfa0a5 Add examples for Checked[Add|Sub|Mul|Div] 2014-07-24 07:26:08 -07:00
bors
2224edcfe1 auto merge of #15407 : sneves/rust/master, r=aturon
At the moment, writing generic functions for integer types that involve shifting is rather verbose. For example, a function at shifts an integer left by 1 currently requires 

    use std::num::One;
    fn f<T: Int>(x : T) -> T {
        x << One::one()
    }

If the shift amount is not 1, it's even worse:

    use std::num::FromPrimitive;
    fn f<T: Int + FromPrimitive>(x: T) -> T {
        x << FromPrimitive::from_int(2).unwrap()
    }

This patch allows the much simpler implementation

    fn f<T: Int>(x: T) -> T { 
        x << 2
    }

It accomplishes this by changing the built-in integer types (and the `Int` trait) to implement `Shl<uint, T>` instead of `Shl<T, T>` as it currently is defined. Note that the internal implementations of `shl` already cast the right-hand side to `uint`. `BigInt` also implements `Shl<uint, BigInt>`, so this increases consistency.

All of the above applies similarly to right shifts, i.e., `Shr<uint, T>`.
2014-07-24 00:26:14 +00:00
bors
b13d6ea6c2 auto merge of #15900 : tbu-/rust/pr_numcleanup, r=kballard
This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.
2014-07-23 08:16:10 +00:00
Tobias Bucher
737d92e11f Clean up some trait impls in core::num.
This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.
2014-07-22 20:59:57 +02:00
Alexis Beingessner
7b83600ea2 clarifying iterator trait documentation 2014-07-22 14:24:04 -04:00
bors
8d43e4474a auto merge of #15867 : cmr/rust/rewrite-lexer4, r=alexcrichton 2014-07-22 07:16:17 +00:00