Commit Graph

57183 Commits

Author SHA1 Message Date
Corey Farwell
5cab9525ae Don't ignore a doc code-block we can compile. 2016-09-14 22:49:36 -04:00
Eugene Bulkin
b6321bd133 Add feature crate attribute for duration_checked_ops to docs 2016-09-14 17:13:06 -07:00
Eugene Bulkin
f2eb4f11d0 Fix doc-tests for Duration 2016-09-14 15:41:19 -07:00
bors
6ffdda1ba1 Auto merge of #36293 - liigo:docblock-short, r=steveklabnik
rustdoc: don't collapse `docblock-short`

![docblock-short](https://cloud.githubusercontent.com/assets/346530/18267298/137d2542-7451-11e6-9c8e-dd4e1f1fea29.png)
2016-09-14 15:39:23 -07:00
Tshepang Lekhonkhobe
a6da082e10 doc: make that sound better 2016-09-14 22:47:56 +02:00
bors
5bdf79bf37 Auto merge of #36270 - petrochenkov:pipwarnagain, r=nikomatsakis
Make `private_in_public` compatibility lint warn-by-default again

More details: https://internals.rust-lang.org/t/regression-report-stable-2016-08-16-vs-beta-2016-08-26/3930/10

r? @nikomatsakis
2016-09-14 12:04:30 -07:00
Ulrik Sverdrup
a4ee9c6e96 core: Use primitive indexing in slice's Index/IndexMut
[T]'s Index implementation is normally not used for indexing, instead
the compiler supplied indexing is used.

Use the compiler supplied version in Index/IndexMut.

This removes an inconsistency:

Compiler supplied bound check failures look like this:

thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4'

If you convince Rust to use the Index impl for slices, bounds check
failure looks like this instead:

thread 'main' panicked at 'assertion failed: index < self.len()'

The latter is used if you for example use Index generically::

   use std::ops::Index;
   fn foo<T: ?Sized>(x: &T) where T: Index<usize> { &x[4]; }

   foo(&[1, 2, 3][..])
2016-09-14 20:19:35 +02:00
Guillaume Gomez
35584629f4 Update E0049 to new error format 2016-09-14 19:03:18 +02:00
bors
5a5736db91 Auto merge of #36472 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests

- Successful merges: #36334, #36335, #36363, #36374, #36467
- Failed merges:
2016-09-14 08:28:05 -07:00
Alex Burka
0d3d23bdee add stronger warning to CString::from_raw 2016-09-14 15:24:04 +00:00
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
Niko Matsakis
6353e30bb2 clear obligations-added flag with nested fulfillcx
This flag is a debugging measure designed to detect cases where we start
a snapshot, create type variables, register obligations involving those
type variables in the fulfillment cx, and then have to unroll the
snapshot, leaving "dangling type variables" behind.  HOWEVER, in some
cases the flag is wrong. In particular, we sometimes create a
"mini-fulfilment-cx" in which we enroll obligations. As long as this
fulfillment cx is fully drained before we return, this is not a problem,
as there won't be any escaping obligations in the main cx. So we add a
fn to save/restore the flag.
2016-09-14 11:04:39 -04:00
bors
97b561a094 Auto merge of #35667 - ollie27:rustdoc_opaque_structs, r=steveklabnik
rustdoc: Don't add extra newlines for fully opaque structs

Changes the definition for braced structs with only private or hidden fields to save space on the page.

Before:
```
pub struct Vec<T> {
    // some fields omitted
}
```
After:
```
pub struct Vec<T> { /* fields omitted */ }
```

This also cleans up empty braced structs.

Before:
```
pub struct Foo {
}
```
After:
```
pub struct Foo {}
```

[before](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html) [after](https://ollie27.github.io/rust_doc_test/std/vec/struct.Vec.html)

cc #34713
2016-09-14 04:57:47 -07:00
Nicholas Nethercote
4715985b07 Remove unused Token::to_binop function. 2016-09-14 15:57:16 +10:00
bors
739d57180f Auto merge of #36041 - ahmedcharles:try, r=nrc
Replace try! with ?.
2016-09-13 22:41:34 -07:00
Michael Woerister
1b3a588f55 trans: Let the collector find drop-glue for all vtables, not just VTableImpl. 2016-09-13 22:11:01 -04:00
Corey Farwell
fae439b92f Add doc examples for std::net::IpAddr construction. 2016-09-13 22:07:38 -04:00
Eugene Bulkin
b1bcd185b0 Implement add, sub, mul and div methods using checked methods for Duration 2016-09-13 17:58:45 -07:00
Eugene Bulkin
07b41b5555 Fix Duration::checked_mul documentation 2016-09-13 17:32:24 -07:00
Eugene Bulkin
606cdede0d Add checked operation methods to Duration 2016-09-13 17:21:54 -07:00
Niko Matsakis
693676da4f add missing test 2016-09-13 18:33:35 -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
Vadim Petrochenkov
b57f1099b5 Remove parsing of obsolete pre-1.0 syntaxes 2016-09-13 23:33:50 +03:00
Vadim Petrochenkov
03161e9b12 Remove some more dead code from mem categorization 2016-09-13 23:33:50 +03:00
Vadim Petrochenkov
4b6c4c08df Remove some ancient code providing special support for newtypes 2016-09-13 23:33:50 +03:00
Niko Matsakis
b49a26ec6f invoke drop glue with a ptr to (data, meta)
This is done by creating a little space on the stack. Hokey, but it's
the simplest fix I can see.
2016-09-13 16:05:12 -04:00
Michael Woerister
7ec9b81326 TypeIdHasher: Remove more redundant explicit visit calls. 2016-09-13 16:01:39 -04:00
Michael Woerister
377c3e1123 Fix rebasing fallout. 2016-09-13 15:46:21 -04: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
Michael Woerister
869d14447a TypeIdHasher: Let projections be hashed implicitly by the visitor. 2016-09-13 15:22:51 -04:00
Michael Woerister
75a0dd0fca Make TypeIdHasher use DefPath::deterministic_hash() for stability. 2016-09-13 15:22:51 -04:00
Michael Woerister
94d75013bc Remove redundant sorting of projections in TypeIdHasher. 2016-09-13 15:22:51 -04:00
Michael Woerister
5c923f0159 Remove redundant sorting of projection bounds in tyencode. 2016-09-13 15:22:51 -04:00
Michael Woerister
5a881e920e Make sure that projection bounds in ty::TraitObject are sorted in a way that is stable across compilation sessions and crate boundaries. 2016-09-13 15:22:51 -04: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
Jeffrey Seyfried
b54e1e3997 Differentiate between monotonic and non-monotonic expansion and
only assign node ids during monotonic expansion.
2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
78c0039878 Expand generated test harnesses and macro registries. 2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
f3c2dca353 Remove scope placeholders from the crate root. 2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
c86c8d41a2 Perform node id assignment and macros_at_scope construction during
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
72a636975f Move macro resolution into librustc_resolve. 2016-09-13 09:40:26 +00: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