Commit Graph

56827 Commits

Author SHA1 Message Date
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
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
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
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
Ariel Ben-Yehuda
f1bd907789 use adt::trans_const when translating constant closures and tuples
Fixes #36401
2016-09-12 01:53:43 +03:00
bors
0be88eb794 Auto merge of #36308 - dtolnay:inputitem, r=alexcrichton
Point macros 1.1 errors to the input item

Moved from https://github.com/alexcrichton/rust/pull/6 to continue discussion. Fixes #36218.

Before:

```rust
error[E0106]: missing lifetime specifier
  --> src/main.rs:10:10
   |
10 | #[derive(Serialize, Deserialize)]
   |          ^ expected lifetime parameter

error[E0038]: the trait `T` cannot be made into an object
  --> src/main.rs:15:15
   |
15 | #[derive(Serialize, Deserialize)]
   |          ^^^^^^^^^^ the trait `T` cannot be made into an object
```

After:

```rust
error[E0106]: missing lifetime specifier
  --> src/main.rs:11:1
   |
11 | struct A {
   | ^ expected lifetime parameter

error[E0038]: the trait `T` cannot be made into an object
  --> src/main.rs:16:1
   |
16 | struct B<'a> {
   | ^ the trait `T` cannot be made into an object
```
2016-09-11 15:12:27 -07:00
Keegan McAllister
54c680cdb1 Tweak array docs
Fixes #29331.
2016-09-11 12:36:24 -07:00
bors
4812cf392f Auto merge of #36369 - uweigand:s390x, r=alexcrichton
Add s390x support

This adds support for building the Rust compiler and standard
library for s390x-linux, allowing a full cross-bootstrap sequence
to complete.  This includes:

- Makefile/configure changes to allow native s390x builds
- Full Rust compiler support for the s390x C ABI
  (only the non-vector ABI is supported at this point)
- Port of the standard library to s390x
- Update the liblibc submodule to a version including s390x support
- Testsuite fixes to allow clean "make check" on s390x

Caveats:

- Resets base cpu to "z10" to bring support in sync with the default
  behaviour of other compilers on the platforms.  (Usually, upstream
  supports all older processors; a distribution build may then chose
  to require a more recent base version.)  (Also, using zEC12 causes
  failures in the valgrind tests since valgrind doesn't fully support
  this CPU yet.)

- z13 vector ABI is not yet supported.  To ensure compatible code
  generation, the -vector feature is passed to LLVM.  Note that this
  means that even when compiling for z13, no vector instructions
  will be used.  In the future, support for the vector ABI should be
  added (this will require common code support for different ABIs
  that need different data_layout strings on the same platform).

- Two test cases are (temporarily) ignored on s390x to allow passing
  the test suite.  The underlying issues still need to be fixed:
  * debuginfo/simd.rs fails because of incorrect debug information.
    This seems to be a LLVM bug (also seen with C code).
  * run-pass/union/union-basic.rs simply seems to be incorrect for
    all big-endian platforms.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-11 10:53:24 -07:00
Richard Janis Goldschmidt
c8b656bea5 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-11 16:48:04 +02:00
John Firebaugh
f647db4c8a Update E0297 to new error format 2016-09-10 13:22:19 -07:00
bors
1fca1ab0e7 Auto merge of #36351 - pnkfelix:fix-36278-size-miscalc, r=eddyb
When sizing DST, don't double-count nested struct prefixes.

When computing size of `struct P<T>(Q<T>)`, don't double-count prefix added by `Q`

Fix #36278. Fix #36294.
2016-09-10 13:10:29 -07:00
Keegan McAllister
72e103fe90 Tweak std::mem docs
Fixes #29362.
2016-09-10 10:48:01 -07:00
Kylo Ginsberg
38009bfa91 book: fix a typo 2016-09-10 07:58:30 -07:00
bors
f8ba7cb863 Auto merge of #36378 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests

- Successful merges: #35691, #36045, #36311, #36314, #36326, #36346
- Failed merges:
2016-09-10 07:03:27 -07:00
Guillaume Gomez
2ded39938a Rollup merge of #36346 - oli-obk:patch-1, r=arielb1
clean up `get_vtable`'s doc comment
2016-09-10 15:57:51 +02:00
Guillaume Gomez
8bfc561752 Rollup merge of #36326 - JDemler:master, r=steveklabnik
Fixed typo in nomicon
2016-09-10 15:57:51 +02:00
Guillaume Gomez
a221ad06f2 Rollup merge of #36314 - tshepang:not-needed, r=GuillaumeGomez
doc: we got coercion going on here, so no need to be this explicit
2016-09-10 15:57:50 +02:00
Guillaume Gomez
30198bf6b6 Rollup merge of #36311 - frewsxcv:instant-elapsed-example, r=GuillaumeGomez
Add doc example for `std::time::Instant::elapsed`.

None
2016-09-10 15:57:50 +02:00
Guillaume Gomez
26315bf015 Rollup merge of #36045 - ollie27:rustdoc_titles3, r=steveklabnik
rustdoc: Add missing item types to page titles

Most pages include the item type in the title such as "Struct std::vec::Vec". However it is missing from the pages for foreign functions, type definitions, macros, statics and constants. This adds them so for example, instead of a title of "std::u32::MAX" it is "Constant std::u32::MAX" to match the others.

[before](https://doc.rust-lang.org/nightly/std/u32/constant.MAX.html) [after](https://ollie27.github.io/rust_doc_test/std/u32/constant.MAX.html)
[before](https://doc.rust-lang.org/nightly/std/io/type.Result.html) [after](https://ollie27.github.io/rust_doc_test/std/io/type.Result.html)

Previous discussions: #34345, #35003
2016-09-10 15:57:50 +02:00
Guillaume Gomez
65af27b000 Rollup merge of #35691 - jaredwy:update-error-63, r=jonathandturner
Update the wording for E0063. This will truncate the fields to 3.

Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field
This is for #35218 as part of #35233

r? @jonathandturner
2016-09-10 15:57:50 +02:00
bors
a5f4cc527d Auto merge of #36333 - apasel422:issue-35668, r=eddyb
Handle `ReEmpty` for `impl Trait`

Closes #35668

r? @eddyb
2016-09-10 02:24:27 -07:00
Mikhail Modin
fb85dd398b fix span for errors E0537, E0535 & E0536 2016-09-10 10:21:13 +03:00
bors
f508ddc547 Auto merge of #36332 - llogiq:static_consts_feature, r=nikomatsakis
add static_in_const feature gate

also updates tests and deletes the spurious .bk files I inadvertently added last time.

r? @nikomatsakis
2016-09-09 21:35:30 -07:00
David Tolnay
fe41520fce Add ExpnId to expanded procedural macro code 2016-09-09 18:50:05 -07:00
Ulrich Weigand
19b84088d7 Add s390x support
This adds support for building the Rust compiler and standard
library for s390x-linux, allowing a full cross-bootstrap sequence
to complete.  This includes:

- Makefile/configure changes to allow native s390x builds
- Full Rust compiler support for the s390x C ABI
  (only the non-vector ABI is supported at this point)
- Port of the standard library to s390x
- Update the liblibc submodule to a version including s390x support
- Testsuite fixes to allow clean "make check" on s390x

Caveats:

- Resets base cpu to "z10" to bring support in sync with the default
  behaviour of other compilers on the platforms.  (Usually, upstream
  supports all older processors; a distribution build may then chose
  to require a more recent base version.)  (Also, using zEC12 causes
  failures in the valgrind tests since valgrind doesn't fully support
  this CPU yet.)

- z13 vector ABI is not yet supported.  To ensure compatible code
  generation, the -vector feature is passed to LLVM.  Note that this
  means that even when compiling for z13, no vector instructions
  will be used.  In the future, support for the vector ABI should be
  added (this will require common code support for different ABIs
  that need different data_layout strings on the same platform).

- Two test cases are (temporarily) ignored on s390x to allow passing
  the test suite.  The underlying issues still need to be fixed:
  * debuginfo/simd.rs fails because of incorrect debug information.
    This seems to be a LLVM bug (also seen with C code).
  * run-pass/union/union-basic.rs simply seems to be incorrect for
    all big-endian platforms.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-09 22:28:19 +01:00
bors
1284081d33 Auto merge of #36256 - rjgoldsborough:make-configure-detect-nodejs-36207, r=alexcrichton
adding a check to bootstrap script

and a check to the rust config script

refs #36207

first crack at making configure detect nodejs
2016-09-09 14:04:31 -07:00
bors
f1f40f850e Auto merge of #36331 - petrochenkov:tyadt, r=eddyb
Refactor `TyStruct`/`TyEnum`/`TyUnion` into `TyAdt`

r? @eddyb
2016-09-09 04:57:11 -07:00
bors
3344f893a8 Auto merge of #36324 - nrc:save-docs, r=eddyb
save-analysis bits and pieces
2016-09-09 01:43:46 -07:00
Jared Wyles
0e32d11868 Update the wording for E0063. This will truncate the fields to 3.
Instead of listing every field it will now show missing `a`, `z`, `b`, and 1 other field
2016-09-09 18:04:26 +10:00
orbea
5e9149d73f Allow setting --docdir 2016-09-08 23:18:20 -07:00
bors
5440a1fae7 Auto merge of #36322 - uweigand:nonblocking, r=alexcrichton
Fix argument to FIONBIO ioctl

The FIONBIO ioctl takes as argument a pointer to an integer, which
should be either 0 or 1 to indicate whether nonblocking mode is to
be switched off or on.  The type of the pointed-to variable is "int".

However, the set_nonblocking routine in libstd/sys/unix/net.rs passes
a pointer to a libc::c_ulong variable.  This doesn't matter on all
32-bit platforms and on all litte-endian platforms, but it will
break on big-endian 64-bit platforms.

Found while porting Rust to s390x (a big-endian 64-bit platform).

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-08 22:30:12 -07:00
bors
1df64450ec Auto merge of #36321 - uweigand:enum-abi, r=eddyb
Follow target ABI sign-/zero-extension rules for enum types

While attempting to port Rust to s390x, I ran into an ABI violation
(that caused rust_eh_personality to be miscompiled, breaking unwinding).
The problem is that this function returns an enum type, which is
supposed to be sign-extended according to the s390x ABI.  However,
common code would ignore target sign-/zero-extension rules for any
types that do not satisfy is_integral(), which includes enums.

For the general case of Rust enum types, which map to structure types
with a discriminant, that seems correct.  However, in the special case
of simple enums that map directly to C enum types (i.e. LLVM integers),
this is incorrect; we must follow the target extension rules for those.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-08 19:15:50 -07:00
Jake Goldsborough
89bc13c37d tweaking the nodejs cmd sanity check 2016-09-08 17:51:06 -07:00
Ulrik Sverdrup
765700ba7a 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).
2016-09-09 02:38:47 +02:00