Commit graph

40693 commits

Author SHA1 Message Date
Alex Crichton f19e763e08 std: Stabilize the rest of Any/BoxAny
This commit stabilizes the following APIs:

* `TypeId::of` - now that it has an `Any` bound it's ready to be stable.
* `Box<Any>::downcast` - now that an inherent impl on `Box<Any>` as well as
  `Box<Any+Send>` is allowed the `BoxAny` trait is removed in favor of these
  inherent methods.

This is a breaking change due to the removal of the `BoxAny` trait, but
consumers can simply remove imports to fix crates.

[breaking-change]
2015-03-30 16:44:11 -07:00
Corey Richardson b314fedc4a mk: build and distribute facade crates unconditionally (for now) 2015-03-30 19:18:47 -04:00
Kevin Butler 2a89d695f4 libcore: Ensure min and max functions are consistent for equal inputs 2015-03-30 23:48:26 +01:00
ray glover 5dc23be5b1 rustdoc: output stderr on doc-test fail
Forward output from stderr when a test executable panics/fails.
2015-03-30 23:42:41 +01:00
Tshepang Lekhonkhobe 1026b06442 book: make Builder Pattern example more complete 2015-03-31 00:26:03 +02:00
Matt Brubeck 10816266d6 Document the effect of # on array formatting 2015-03-30 15:17:22 -07:00
Corey Richardson 31a5285200 lint: handle private traits better
Due to a long-standing conservative approach to trait exports, all traits are
considered exported. However, the missing_docs lint uses the export map to
determine if something is public and ought to have documentation. This commit
modifies the lint to check if traits are private before emitting the warning.

Closes #11592
2015-03-30 18:16:25 -04:00
Emeliov Dmitrii df65f59fe9 replace deprecated as_slice() 2015-03-31 01:03:13 +03:00
Alex Crichton acd48a2b3e std: Standardize (input, output) param orderings
This functions swaps the order of arguments to a few functions that previously
took (output, input) parameters, but now take (input, output) parameters (in
that order).

The affected functions are:

* ptr::copy
* ptr::copy_nonoverlapping
* slice::bytes::copy_memory
* intrinsics::copy
* intrinsics::copy_nonoverlapping

Closes #22890
[breaking-change]
2015-03-30 14:08:40 -07:00
Richo Healey 6e8693b297 std: Add a note about the print! macro and output buffering 2015-03-30 13:55:15 -07:00
Sean McArthur 4c1f5bd6dc convert: add Into<Cow> impls for &str and String 2015-03-30 12:07:16 -07:00
Julian Viereck 085bcfa37e Second attempt to fix #23713 based on follow-up comments in #23791. 2015-03-30 21:00:09 +02:00
Steve Klabnik 8f0c952499 Explain why 'elision' 2015-03-30 14:49:22 -04:00
bcoopers 240734c31e Only zero at most 64k at a time. We still use the doubling
reallocation strategy since extend() calls reserve() and/or
push() for us.
2015-03-30 13:59:32 -04:00
bors 6cf3b0b74a Auto merge of #23861 - Manishearth:rollup, r=Manishearth
- Successful merges: #23746, #23836, #23852
- Failed merges: #23855
2015-03-30 17:16:25 +00:00
Steve Klabnik 6c0314a38a Make note of noalias in unsafe reference section
Fixes #19733
2015-03-30 12:36:10 -04:00
Manish Goregaokar 3b45470100 Rollup merge of #23855 - tshepang:doc-nit, r=Manishearth 2015-03-30 20:18:16 +05:30
bors 9de34a84bb Auto merge of #23673 - nikomatsakis:issue-23319-binops-ng-5, r=pnkfelix
The current binary operator code assumed that if the LHS was a scalar (`i32` etc), then the RHS had to match. This is not true with multidispatch. This PR generalizes the existing code to (primarily) use the traits -- this also allows us to defer the precise type-checking when the types aren't fully known. The one caveat is the unstable SIMD types, which don't fit in with the current traits -- in that case, the LHS type must be known to be SIMD ahead of time.

There is one semi-hacky bit in that during writeback, for builtin operators, if the types resolve to scalars (i32 etc) then we clear the method override. This is because we know what the semantics are and it is more efficient to generate the code directly. It also ensures that we can use these overloaded operators in constants and so forth.

cc @japaric
cc @aturon 

Fixes #23319 (and others).
2015-03-30 14:25:48 +00:00
Niko Matsakis 7595c25ef9 Add test case for #22743.
Fixes #22743.
Fixes #19035.
Fixes #22099.

(Those all seem to be exactly the same scenario.)
2015-03-30 09:05:59 -04:00
Niko Matsakis e2b2a53d70 Fallout in tests: largely changes to error messages. 2015-03-30 09:05:59 -04:00
Felix S. Klock II e4340531c2 Fallout to test. 2015-03-30 14:10:46 +02:00
Felix S. Klock II f513380cf5 Address Issue 14270 by making cmt::freely_aliasable result more fine-grained.
Instead of encoding the aliasability (i.e. whether the cmt is uniquely
writable or not) as an option, now pass back an enum indicating
either: 1. freely-aliasable (thus not uniquely-writable),
2. non-aliasble (thus uniquely writable), or 3. unique but immutable
(and thus not uniquely writable, according to proposal from issue
14270.)

This is all of course a giant hack that will hopefully go away with an
eventually removal of special treatment of `Box<T>` (aka `ty_unique`)
from the compiler.
2015-03-30 14:10:45 +02:00
Felix S. Klock II 492b3b163f mem_categorization.rs removed pub from method called only from this mod. 2015-03-30 14:10:45 +02:00
Felix S. Klock II 0705e6a12e expr_use_visitor: Added comment explaining meaning of boolean return value. 2015-03-30 14:10:45 +02:00
Felix S. Klock II aa1398176e Mucho debug instrumentation. 2015-03-30 14:10:44 +02:00
bors 14192d6df5 Auto merge of #23848 - cmr:no-compiler-docs, r=huonw
This saves a bunch of a time and will make distributions smaller, as well as
avoiding filling the implementors page with internal garbage. Turn it back on
with `--enable-compiler-docs` if you want them.

(Crates behind the facade are not documented at all)

[breaking-change]
2015-03-30 11:35:52 +00:00
Vadim Petrochenkov 883adc6763 Fix the fallout 2015-03-30 12:19:11 +03:00
Vadim Petrochenkov ee76be5486 Remove unnecessary as usize 2015-03-30 12:19:11 +03:00
Vadim Petrochenkov 5825c72e73 Change the type of constants BYTES/BITS to usize 2015-03-30 12:19:11 +03:00
Niko Matsakis c92bdcb232 Fallout where types must be specified.
This is due to a [breaking-change] to operators. The primary affected
code is uses of the `Rng` trait where we used to (incorrectly) infer the
right-hand-side type from the left-hand-side, in the case that the LHS
type was a scalar like `i32`. The fix is to add a type annotation like
`x + rng.gen::<i32>()`.
2015-03-30 05:02:20 -04:00
Niko Matsakis d6466ff13a Driveby cleanup of the impl for negation, which had some kind of
surprising casts. This version more obviously corresponds to the builtin
semantics.
2015-03-30 04:59:56 -04:00
Niko Matsakis d649292e60 Implement new type-checking strategy for binary operators. Basically,
the plan is to treat all binary operators as if they were overloaded,
relying on the fact that we have impls for all the builtin scalar
operations (and no more). But then during writeback we clear the
overload if the types correspond to a builtin op.

This strategy allows us to avoid having to know the types of the
operands ahead of time. It also avoids us overspecializing as we did in
the past.
2015-03-30 04:59:56 -04:00
bors f00264074f Auto merge of #23843 - apasel422:thrads, r=steveklabnik 2015-03-30 08:49:18 +00:00
Tshepang Lekhonkhobe d9252bde18 book: improve a bit of grammar in Method Syntax chapeter 2015-03-30 07:10:09 +02:00
bors f55d03c8d8 Auto merge of #23838 - kgv:master, r=steveklabnik
Remove the last sentence about standard io chapter.

Additional Fixes #23760
2015-03-30 04:22:38 +00:00
bors c748864485 Auto merge of #23837 - wesleywiser:patch-1, r=alexcrichton
Fixes #23397
2015-03-30 01:31:34 +00:00
bcoopers 8d3e55908a Clearer wording 2015-03-29 19:29:11 -04:00
bcoopers 2982fe39ad 80 character line limit 2015-03-29 19:23:46 -04:00
bcoopers 45c10db41f Clarified and simplified algorithm for increasing size of buffer in
read_to_end()
2015-03-29 19:08:53 -04:00
bors d8be84eb44 Auto merge of #23830 - petrochenkov:spellcheck, r=steveklabnik
With help of https://github.com/lucasdemarchi/codespell

r? @steveklabnik
2015-03-29 22:39:46 +00:00
Andrew Hobden d4b5f65afc Fix line spacing. 2015-03-29 15:25:06 -07:00
Andrew Paseltiner bf9c27d885 s/THRADS/THREADS/ 2015-03-29 17:22:21 -04:00
Germano Gabbianelli b77a09c17e Fixed wrong name of test module in testing.md
The documentation says that 'The current convention is to use the `test` module
to hold your "unit-style"' but then defines the module as "tests" instead.
2015-03-29 22:50:51 +02:00
kgv f575acaf5f Remove about standard io chapter from the book (from arrays-vectors-and-slices chapter)
Remove the last sentence about standard io chapter.

Additional Fixes #23760
2015-03-29 23:26:31 +03:00
bors 92f3d9a6b4 Auto merge of #23820 - sfackler:fast_read_to_end, r=alexcrichton
with_end_to_cap is enormously expensive now that it's initializing
memory since it involves 64k allocation + memset on every call. This is
most noticable when calling read_to_end on very small readers, where the
new version if **4 orders of magnitude** faster.

BufReader also depended on with_end_to_cap so I've rewritten it in its
original form.

As a bonus, converted the buffered IO struct Debug impls to use the
debug builders.

I first came across this in sfackler/rust-postgres#106 where a user reported a 10x performance regression. A call to read_to_end turned out to be the culprit: 9cd413d42c.

The new version differs from the old in a couple of ways. The buffer size used is now adaptive. It starts at 32 bytes and doubles each time EOF hasn't been reached up to a limit of 64k. In addition, the buffer is only truncated when EOF or an error has been reached, rather than after every call to read as was the case for the old implementation.

I wrote up a benchmark to compare the old version and new version: https://gist.github.com/sfackler/e979711b0ee2f2063462

It tests a couple of different cases: a high bandwidth reader, a low bandwidth reader, and a low bandwidth reader that won't return more than 10k per call to `read`. The high bandwidth reader should be analagous to use cases when reading from e.g. a `BufReader` or `Vec`, and the low bandwidth readers should be analogous to reading from something like a `TcpStream`.

Of special note, reads from a high bandwith reader containing 4 bytes are now *4,495 times faster*. 
```
~/foo ❯ cargo bench
   Compiling foo v0.0.1 (file:///home/sfackler/foo)
     Running target/release/foo-7498d7dd7faecf5c

running 13 tests
test test_new ... ignored
test new_delay_4      ... bench:    230768 ns/iter (+/- 14812)
test new_delay_4_cap  ... bench:    231421 ns/iter (+/- 7211)
test new_delay_5m     ... bench:  14495370 ns/iter (+/- 4008648)
test new_delay_5m_cap ... bench:  73127954 ns/iter (+/- 59908587)
test new_nodelay_4    ... bench:        83 ns/iter (+/- 2)
test new_nodelay_5m   ... bench:  12527237 ns/iter (+/- 335243)
test std_delay_4      ... bench:    373095 ns/iter (+/- 12613)
test std_delay_4_cap  ... bench:    374190 ns/iter (+/- 19611)
test std_delay_5m     ... bench:  17356012 ns/iter (+/- 15906588)
test std_delay_5m_cap ... bench: 883555035 ns/iter (+/- 205559857)
test std_nodelay_4    ... bench:    144937 ns/iter (+/- 2448)
test std_nodelay_5m   ... bench:  16095893 ns/iter (+/- 3315116)

test result: ok. 0 passed; 0 failed; 1 ignored; 12 measured
```

r? @alexcrichton
2015-03-29 19:47:18 +00:00
Wesley Wiser 2a1bad70dd Fix extremely small stability bars on docs page
Fixes #23397
2015-03-29 15:14:02 -04:00
Andrew Hobden 1a5e73a82d Fix trailing whitespace. Whoops! 2015-03-29 11:06:38 -07:00
Andrew Hobden e489eaa0c5 Update std::error example
To not use `old_io` and `os`, which are deprecated. Since there is no more `MemoryMap` used byte parsing instead to generate the second potential error.
2015-03-29 10:03:49 -07:00
bors c5370be36e Auto merge of #23816 - frewsxcv:fromiterator-example, r=Manishearth 2015-03-29 16:54:40 +00:00
Corey Farwell 8fe7f1fa97 Add an example for FromIterator::from_iter 2015-03-29 10:32:53 -04:00