Commit Graph

56866 Commits

Author SHA1 Message Date
Guillaume Gomez
e368cdd2d5 Rollup merge of #36467 - frewsxcv:ipaddr, r=GuillaumeGomez
Add doc examples for std::net::IpAddr construction.

None
2016-09-14 17:15:37 +02:00
Guillaume Gomez
a89690ec00 Rollup merge of #36396 - athulappadan:Default-docs, r=bluss
Documentation of what Default does for each type

Addresses #36265
I haven't changed the following types due to doubts:

1)src/libstd/ffi/c_str.rs
2)src/libcore/iter/sources.rs
3)src/libcore/hash/mod.rs
4)src/libcore/hash/mod.rs
5)src/librustc/middle/privacy.rs

r? @steveklabnik
2016-09-14 17:15:37 +02:00
Guillaume Gomez
4476b7b43b Rollup merge of #36374 - dangcheng:patch-1, r=steveklabnik
book: fix mistake (File::open -> File::create)
2016-09-14 17:15:37 +02:00
Guillaume Gomez
99c2f72814 Rollup merge of #36363 - GuillaumeGomez:add_urls, r=steveklabnik
Add urls

r? @steveklabnik
2016-09-14 17:15:37 +02:00
Guillaume Gomez
d939cbeefe Rollup merge of #36334 - GuillaumeGomez:run_but, r=steveklabnik
Set run button transparent instead of invisible

r? @steveklabnik

And of course a screenshot:

![screenshot from 2016-09-08 01-15-45](https://cloud.githubusercontent.com/assets/3050060/18331849/31fe1f8c-7562-11e6-9ae9-1dab44089ec6.png)
2016-09-14 17:15:36 +02:00
bors
739d57180f Auto merge of #36041 - ahmedcharles:try, r=nrc
Replace try! with ?.
2016-09-13 22:41:34 -07:00
Corey Farwell
fae439b92f Add doc examples for std::net::IpAddr construction. 2016-09-13 22:07:38 -04:00
bors
b1363a73ed Auto merge of #35021 - japaric:rustc-builtins, r=alexcrichton
crate-ify compiler-rt into compiler-builtins

libcompiler-rt.a is dead, long live libcompiler-builtins.rlib

This commit moves the logic that used to build libcompiler-rt.a into a
compiler-builtins crate on top of the core crate and below the std crate.
This new crate still compiles the compiler-rt instrinsics using gcc-rs
but produces an .rlib instead of a static library.

Also, with this commit rustc no longer passes -lcompiler-rt to the
linker. This effectively makes the "no-compiler-rt" field of target
specifications a no-op. Users of `no_std` will have to explicitly add
the compiler-builtins crate to their crate dependency graph *if* they
need the compiler-rt intrinsics - this is a [breaking-change]. Users
of the `std` have to do nothing extra as the std crate depends
on compiler-builtins.

Finally, this a step towards lazy compilation of std with Cargo as the
compiler-rt intrinsics can now be built by Cargo instead of having to
be supplied by the user by some other method.

closes #34400

---

r? @alexcrichton
2016-09-13 15:08:12 -07:00
Alex Crichton
848cfe20a0 Link test to compiler builtins and make unstable
This commit fixes a test which now needs to explicitly link to the
`compiler_builtins` crate as well as makes the `compiler_builtins` crate
unstable.
2016-09-13 12:27:26 -07:00
bors
2fd060815f Auto merge of #36181 - seanmonstar:likely, r=nikomatsakis
core: add likely and unlikely intrinsics

I'm no good at reading assembly, but I have tried a stage1 compiler with this patch, and it does cause different asm output. Additionally, testing this compiler on my httparse crate with some `likely` usage added in to the branches does affect benchmarks. However, I'm sure a codegen test should be included, if anyone knows what it should look like.

There isn't an entry in `librustc_trans/context.rs` in this diff, because it already exists (`llvm.expect.i1` is used for array indices).

----

Even though this does affect httparse benchmarks, it doesn't seem to affect it the same way GCC's `__builtin_expect` affects picohttpparser. I was confused that the deviation on the benchmarks grew hugely when testing this, especially since I'm absolutely certain that the branchs where I added `likely` were always `true`. I chalk that up to GCC and LLVM handle branch prediction differently.

cc #26179
2016-09-13 10:54:55 -07:00
Alex Crichton
265620225d rustc: Don't pass --whole-archive for compiler-builtins
This flag is intended for rlibs included once, not rlibs that are repeatedly
included.
2016-09-13 08:11:20 -07:00
bors
c87ba3f122 Auto merge of #36264 - matklad:zeroing-cstring, r=alexcrichton
Zero first byte of CString on drop

Hi! This is one more attempt to ameliorate `CString::new("...").unwrap().as_ptr()` problem (related RFC: https://github.com/rust-lang/rfcs/pull/1642).

One of the biggest problems with this code is that it may actually work in practice, so the idea of this PR is to proactively break such invalid code.

Looks like writing a `null` byte at the start of the CString should do the trick, and I think is an affordable cost: zeroing a single byte in `Drop` should be cheap enough compared to actual memory deallocation which would follow.

I would actually prefer to do something like

```Rust
impl Drop for CString {
    fn drop(&mut self) {
        let pattern = b"CTHULHU FHTAGN ";
        let bytes = self.inner[..self.inner.len() - 1];
        for (d, s) in bytes.iter_mut().zip(pattern.iter().cycle()) {
            *d = *s;
        }
    }
}
```

because Cthulhu error should be much easier to google, but unfortunately this would be too expensive in release builds, and we can't implement things `cfg(debug_assertions)` conditionally in stdlib.

Not sure if the whole idea or my implementation (I've used ~~`transmute`~~ `mem::unitialized` to workaround move out of Drop thing) makes sense :)
2016-09-13 04:57:23 -07:00
bors
58450c047e Auto merge of #36446 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests

- Successful merges: #36357, #36380, #36389, #36397, #36402
- Failed merges:
2016-09-13 01:39:36 -07:00
Guillaume Gomez
c05424f250 Rollup merge of #36402 - kmcallister:gh-29331-array-docs, r=GuillaumeGomez
Tweak array docs

Fixes #29331.

r? @GuillaumeGomez
2016-09-13 10:25:50 +02:00
Guillaume Gomez
d6aa4e828c Rollup merge of #36397 - SuperFluffy:bufwriter_unnecessary_cmp, r=aturon
Remove unnecessary `cmp::min` from BufWriter::write

The first branch of the if statement already checks if `buf.len() >= self.buf.capacity()`, which makes the `cmp::min(buf.len(), self.buf.capacity())` redundant: the result will always be `buf.len()`. Therefore, we can pass the `buf` slice directly into `Write::write`.
2016-09-13 10:25:49 +02:00
Guillaume Gomez
2a88e6c42e Rollup merge of #36389 - jfirebaugh:E0297, r=GuillaumeGomez
Update E0297 to new error format

Fixes #35521.
Part of #35233.

I didn't attempt the bonus of narrowing the span to focus on the "for `<pattern>`" piece (it's my first time contributing), but I'm happy to do so given some hints.

r? @jonathandturner
2016-09-13 10:25:49 +02:00
Guillaume Gomez
f658548c93 Rollup merge of #36380 - kylog:fix-typo, r=steveklabnik
book: fix a typo
2016-09-13 10:25:49 +02:00
Guillaume Gomez
a8d594f59d Rollup merge of #36357 - kmcallister:gh-29362-mem-docs, r=GuillaumeGomez
Tweak std::mem docs (#29362)

r? @steveklabnik
2016-09-13 10:25:49 +02:00
Alex Crichton
2140c4ba36 rustc: Always link compiler-builtins last
All crates depend on compiler-builtins, so we need to always include the crate
last.
2016-09-12 21:52:02 -07:00
athulappadan
5798003438 Doc correction: btree 2016-09-13 10:13:52 +05:30
Jorge Aparicio
521ffe9dbe it's also compiler-rt.lib on windows-gnu 2016-09-12 21:22:15 -07:00
Jorge Aparicio
e5d0bb12ec no emutls for you, windows 2016-09-12 21:22:15 -07:00
Jorge Aparicio
e6da837e99 it's libcompiler-rt.lib on windows 2016-09-12 21:22:15 -07:00
Jorge Aparicio
3fd5fdd8d3 crate-ify compiler-rt into compiler-builtins
libcompiler-rt.a is dead, long live libcompiler-builtins.rlib

This commit moves the logic that used to build libcompiler-rt.a into a
compiler-builtins crate on top of the core crate and below the std crate.
This new crate still compiles the compiler-rt instrinsics using gcc-rs
but produces an .rlib instead of a static library.

Also, with this commit rustc no longer passes -lcompiler-rt to the
linker. This effectively makes the "no-compiler-rt" field of target
specifications a no-op. Users of `no_std` will have to explicitly add
the compiler-builtins crate to their crate dependency graph *if* they
need the compiler-rt intrinsics. Users of the `std` have to do nothing
extra as the std crate depends on compiler-builtins.

Finally, this a step towards lazy compilation of std with Cargo as the
compiler-rt intrinsics can now be built by Cargo instead of having to
be supplied by the user by some other method.

closes #34400
2016-09-12 21:22:15 -07:00
bors
09905b1177 Auto merge of #36019 - frewsxcv:take-into-inner, r=alexcrichton
Introduce `into_inner` method on `std::io::Take`.

https://github.com/rust-lang/rust/issues/23755
2016-09-12 20:33:47 -07:00
bors
fa9d8cc8ac Auto merge of #35960 - nikomatsakis:incr-comp-krate-edges, r=michaelwoerister
fix a few errant `Krate` edges

Exploring the effect of small changes on `syntex` reuse, I discovered the following sources of unnecessary edges from `Krate`

r? @michaelwoerister
2016-09-12 17:15:26 -07:00
Niko Matsakis
9ca578687b check stack discipline of tasks 2016-09-12 17:43:44 -04:00
bors
5531c314a2 Auto merge of #36354 - mikhail-m1:master, r=jonathandturner
fix span for errors E0537, E0535 & E0536

fix #36182 as part of #35233
2016-09-12 14:05:41 -07:00
bors
f81f4964d2 Auto merge of #36204 - c4rlo:patch-3, r=GuillaumeGomez
README.md: fix a "\" in table heading to be "/"
2016-09-12 10:54:08 -07:00
bors
888970370a Auto merge of #36414 - nnethercote:char_lit, r=jseyfried
Improve char_lit's readability and speed

This is my first contribution to rustc. Please let me know if I've done anything wrong. (I ran `make tidy` before making the pull request.)
2016-09-12 07:43:57 -07:00
bors
85592fbe60 Auto merge of #36406 - arielb1:constant-padding, r=eddyb
use `adt::trans_const` when translating constant closures and tuples

The previous way dropped padding on the floor.

Fixes #36401

r? @eddyb
2016-09-12 04:38:55 -07:00
bors
00ce2c0ffa Auto merge of #36360 - orbea:docdir, r=alexcrichton
Allow setting --docdir

This will allow setting `--docdir` during configure, this is useful because not all linux distributions install documentation to `/usr/share/doc`.  For example in Slackware documentation is installed to `/usr/doc/$PRGNAM-$VERSION` and `/usr/share/doc` is a symlink to `/usr/doc`.

To use this `./configure --docdir=/usr/doc/$PRGNAM-$VERSION` can be used.
2016-09-12 01:33:40 -07:00
Nicholas Nethercote
826f673664 Lazily construct panic messages in char_lit().
This reduces the time taken to run
`rustc -Zparse-only rustc-benchmarks/issue-32278-big-array-of-strings`
from 0.18s to 0.15s on my machine, and reduces the number of
instructions (as measured by Cachegrind) from 1.34B to 1.01B.

With the change applied, the time to fully compile that benchmark is
1.96s, so this is a 1.5% improvement.
2016-09-12 17:33:02 +10:00
Nicholas Nethercote
4c274b6aea Avoid an unnecessary intermediate value in char_lit().
This makes the function more concise and easier to understand.
2016-09-12 16:15:52 +10:00
bors
4d9132357f Auto merge of #36355 - bluss:vec-extend-from-slice-aliasing-workaround, r=alexcrichton
Work around pointer aliasing issue in Vec::extend_from_slice, extend_with_element

Due to missing noalias annotations for &mut T in general (issue #31681),
in larger programs extend_from_slice and extend_with_element may both
compile very poorly. What is observed is that the .set_len() calls are
not lifted out of the loop, even for `Vec<u8>`.

Use a local length variable for the Vec length instead, and use a scope
guard to write this value back to self.len when the scope ends or on
panic. Then the alias analysis is easy.

This affects extend_from_slice, extend_with_element, the vec![x; n]
macro, Write impls for Vec<u8>, BufWriter, etc (but may / may not
have triggered since inlining can be enough for the compiler to get it right).

Fixes #32155
Fixes #33518
Closes #17844
2016-09-11 22:28:24 -07:00
dangcheng
5b59c14143 change error message 2016-09-12 12:02:35 +08:00
bors
0f5f325f9a Auto merge of #36344 - sanxiyn:llvm-components, r=alexcrichton
Use LLVM_COMPONENTS to run tests just for supported targets

This is already done for simd-ffi test, but not for atomic-lock-free test.

Fix #35023.
2016-09-11 19:06:35 -07:00
Ahmed Charles
694d601dbc Use question_mark feature in librustc_metadata. 2016-09-11 16:02:44 -07:00
Ahmed Charles
509aa235ba Use question_mark feature in librustc_const_eval. 2016-09-11 16:02:44 -07:00
Ahmed Charles
0dbf77e722 Use question_mark feature in librustc_back. 2016-09-11 16:02:44 -07:00
Ahmed Charles
637f1492e7 Use question_mark feature in libstd. 2016-09-11 16:02:44 -07:00
Ahmed Charles
d73e374ddb Use question_mark feature in libserialize. 2016-09-11 16:02:43 -07:00
Ahmed Charles
14d3937e65 Use question_mark feature in librustc. 2016-09-11 16:02:43 -07:00
Ahmed Charles
e10e0bcf2d Use question_mark feature in librustc_mir. 2016-09-11 16:02:43 -07:00
Ahmed Charles
8a9e52a8e7 Use question_mark feature in librustc_incremental. 2016-09-11 16:02:41 -07:00
Ahmed Charles
8391760bd8 Use question_mark feature in librustc_errors. 2016-09-11 16:00:50 -07:00
Ahmed Charles
bfd123d1e9 Use question_mark feature in libcore. 2016-09-11 16:00:50 -07:00
Ahmed Charles
6d88ab57b3 Fix typo in bootstrap/lib.rs. 2016-09-11 16:00:50 -07:00
Ahmed Charles
f0a414e74e Use question_mark feature in compiletest. 2016-09-11 16:00:50 -07:00
Ahmed Charles
f1c6cad963 Use question_mark feature in linkchecker. 2016-09-11 16:00:50 -07:00