Commit Graph

44144 Commits

Author SHA1 Message Date
Tshepang Lekhonkhobe
7a0a69f801 book: remove a stray code block 2015-06-22 20:14:27 +02:00
Tshepang Lekhonkhobe
e13077f7f0 book: whitespace 2015-06-22 19:29:34 +02:00
Tshepang Lekhonkhobe
0adda45c04 book: fix sentence 2015-06-22 19:29:29 +02:00
Guillaume Gomez
97e1615735 Add E0045 error explanation 2015-06-22 18:39:25 +02:00
Guillaume Gomez
3f9fc39ab9 Unify variadic errors 2015-06-22 18:34:52 +02:00
bors
4e2a898afc Auto merge of #25784 - geofft:subprocess-signal-masks, r=alexcrichton
UNIX specifies that signal dispositions and masks get inherited to child processes, but in general, programs are not very robust to being started with non-default signal dispositions or to signals being blocked. For example, libstd sets `SIGPIPE` to be ignored, on the grounds that Rust code using libstd will get the `EPIPE` errno and handle it correctly. But shell pipelines are built around the assumption that `SIGPIPE` will have its default behavior of killing the process, so that things like `head` work:

```
geofft@titan:/tmp$ for i in `seq 1 20`; do echo "$i"; done | head -1
1
geofft@titan:/tmp$ cat bash.rs
fn main() {
        std::process::Command::new("bash").status();
}
geofft@titan:/tmp$ ./bash
geofft@titan:/tmp$ for i in `seq 1 20`; do echo "$i"; done | head -1
1
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
bash: echo: write error: Broken pipe
[...]
```

Here, `head` is supposed to terminate the input process quietly, but the bash subshell has inherited the ignored disposition of `SIGPIPE` from its Rust grandparent process. So it gets a bunch of `EPIPE`s that it doesn't know what to do with, and treats it as a generic, transient error. You can see similar behavior with `find / | head`, `yes | head`, etc.

This PR resets Rust's `SIGPIPE` handler, as well as any signal mask that may have been set, before spawning a child. Setting a signal mask, and then using a dedicated thread or something like `signalfd` to dequeue signals, is one of two reasonable ways for a library to process signals. See carllerche/mio#16 for more discussion about this approach to signal handling and why it needs a change to `std::process`. The other approach is for the library to set a signal-handling function (`signal()` / `sigaction()`): in that case, dispositions are reset to the default behavior on exec (since the function pointer isn't valid across exec), so we don't have to care about that here.

As part of this PR, I noticed that we had two somewhat-overlapping sets of bindings to signal functionality in `libstd`. One dated to old-IO and probably the old runtime, and was mostly unused. The other is currently used by `stack_overflow.rs`. I consolidated the two bindings into one set, and double-checked them by hand against all supported platforms' headers. This probably means it's safe to enable `stack_overflow.rs` on more targets, but I'm not including such a change in this PR.

r? @alexcrichton
cc @Zoxc for changes to `stack_overflow.rs`
2015-06-22 16:11:38 +00:00
Seo Sanghyeon
6f7b4ce65a Do not consider fields matched by wildcard patterns to be used 2015-06-22 21:36:14 +09:00
bors
2287b4b628 Auto merge of #26037 - nhowell:plain_js_playpen, r=steveklabnik
Since the "Book" already avoids jQuery in its inline script tags and playpen.js is tiny, I figured I would convert it to plain old JS as well.

Side note: This is a separate issue, but another thing I noticed in my testing is that the "⇱" character doesn't display correctly in Chrome on Windows 7. (Firefox and IE work fine; other browsers not tested)

r? @steveklabnik

Edit: Github didn't like the "script" tag above
Edit 2: Actually, now IE seems to render "⇱" fine for me. Odd.
2015-06-22 05:23:50 +00:00
Geoffrey Thomas
a8dbb92b47 Fix build on Android API levels below 21
signal(), sigemptyset(), and sigaddset() are only available as inline
functions until Android API 21. liblibc already handles signal()
appropriately, so drop it from c.rs; translate sigemptyset() and
sigaddset() (which is only used in a test) by hand from the C inlines.

We probably want to revert this commit when we bump Android API level.
2015-06-22 00:55:42 -04:00
Geoffrey Thomas
cae005162d sys/unix/process: Reset signal behavior before exec
Make sure that child processes don't get affected by libstd's desire to
ignore SIGPIPE, nor a third-party library's signal mask (which is needed
to use either a signal-handling thread correctly or to use signalfd /
kqueue correctly).
2015-06-22 00:55:42 -04:00
Geoffrey Thomas
56d904c4bb sys/unix: Consolidate signal-handling FFI bindings
Both c.rs and stack_overflow.rs had bindings of libc's signal-handling
routines. It looks like the split dated from #16388, when (what is now)
c.rs was in libnative but not libgreen. Nobody is currently using the
c.rs bindings, but they're a bit more accurate in some places.

Move everything to c.rs (since I'll need signal handling in process.rs,
and we should avoid duplication), clean up the bindings, and manually
double-check everything against the relevant system headers (fixing a
few things in the process).
2015-06-22 00:55:42 -04:00
Geoffrey Thomas
e13642163a sys/unix/c.rs: Remove unused code
It looks like a lot of this dated to previous incarnations of the io
module, etc., and went unused in the reworking leading up to 1.0. Remove
everything we're not actively using (except for signal handling, which
will be reworked in the next commit).
2015-06-22 00:55:42 -04:00
Geoffrey Thomas
feba393b8e std::process: Remove helper function pwd_cmd from test module
The test that used it was removed in 700e627cf7.
2015-06-22 00:55:42 -04:00
OGINO Masanori
59399088ca Put CFG_BUILD triples into CFG_HOST triples.
I've configured with the parameters suggested by @brson in #18670 and
confirmed that it works on Gentoo Linux amd64.

Fixes #18670.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2015-06-22 12:53:34 +09:00
Alex Crichton
db5b463705 rustc_trans: Use custom PATH for archive commands
This commit ensures that the modifications made in #26382 also apply to the
archive commands run in addition to the linker commands.
2015-06-21 20:47:20 -07:00
bors
ba7f79e9f8 Auto merge of #26481 - nham:test-18655, r=arielb1
These issues are fixed but still open.

Closes #18655.
Closes #18988.
2015-06-22 01:43:02 +00:00
bors
31d9aee684 Auto merge of #26394 - arielb1:implement-rfc401-part2, r=nrc
This makes them compliant with the new version of RFC 401 (i.e.
    RFC 1052).

Fixes #26391. I *hope* the tests I have are enough.

This is a [breaking-change]

r? @nrc
2015-06-22 00:11:00 +00:00
Alexis Beingessner
3f56e9a984 remove erroneous error check 2015-06-21 16:16:14 -07:00
bors
4a788a2003 Auto merge of #26479 - arielb1:expr-kind, r=eddyb
Previously it also tried to find out the best way to translate the
expression, which could ICE during type-checking.

Fixes #23173
Fixes #24322
Fixes #25757

r? @eddyb
2015-06-21 22:41:00 +00:00
bors
fd874cd02e Auto merge of #26463 - sfackler:stdout-panic-fix, r=alexcrichton
If a local stderr is present but the normal stderr is missing, we still
want to print.

r? @alexcrichton
2015-06-21 20:14:45 +00:00
Nick Hamann
57a66f8ef3 Add regression tests for issues #18655 and #18988.
Closes #18655.
Closes #18988.
2015-06-21 15:09:05 -05:00
Ariel Ben-Yehuda
59be753544 Make expr_is_lval more robust
Previously it also tried to find out the best way to translate the
expression, which could ICE during type-checking.

Fixes #23173
Fixes #24322
Fixes #25757
2015-06-21 22:31:57 +03:00
Ulrik Sverdrup
71006bd654 StrSearcher: Use trait to specialize two way algorithm by case
Use a trait to be able to implement both the fast search that skips to
each match, and the slower search that emits `Reject` intervals
regularly. The latter is important for uses of `next_reject`.
2015-06-21 19:58:56 +02:00
Ulrik Sverdrup
a6dd2031a3 StrSearcher: Specialize is_prefix_of/is_suffix_of for &str 2015-06-21 19:58:56 +02:00
Ulrik Sverdrup
b890b7bbc7 StrSearcher: Update substring search to use the Two Way algorithm
To improve our substring search performance, revive the two way searcher
and adapt it to the Pattern API.

Fixes #25483, a performance bug: that particular case now completes faster
in optimized rust than in ruby (but they share the same order of magnitude).

Much thanks to @gereeter who helped me understand the reverse case
better and wrote the comment explaining `next_back` in the code.

I had quickcheck to fuzz test forward and reverse searching thoroughly.

The two way searcher implements both forward and reverse search,
but not double ended search. The forward and reverse parts of the two
way searcher are completely independent.

The two way searcher algorithm has very small, constant space overhead,
requiring no dynamic allocation. Our implementation is relatively fast,
especially due to the `byteset` addition to the algorithm, which speeds
up many no-match cases.

A bad case for the two way algorithm is:

```
let haystack = (0..10_000).map(|_| "dac").collect::<String>();
let needle = (0..100).map(|_| "bac").collect::<String>());
```

For this particular case, two way is not much faster than the naive
implementation it replaces.
2015-06-21 19:58:50 +02:00
bors
dedd4302d1 Auto merge of #25641 - geofft:execve-const, r=alexcrichton
The `execv` family of functions and `getopt` are prototyped somewhat strangely in C: they take a `char *const argv[]` (and `envp`, for `execve`), an immutable array of mutable C strings -- in other words, a `char *const *argv` or `argv: *const *mut c_char`. The current Rust binding uses `*mut *const c_char`, which is backwards (a mutable array of constant C strings).

That said, these functions do not actually modify their arguments. Once upon a time, C didn't have `const`, and to this day, string literals in C have type `char *` (`*mut c_char`). So an array of string literals has type `char * []`, equivalent to `char **` in a function parameter (Rust `*mut *mut c_char`). C allows an implicit cast from `T **` to `T * const *` (`*const *mut T`) but not to `const T * const *` (`*const *const T`). Therefore, prototyping `execv` as taking `const char * const argv[]` would have broken existing code (by requiring an explicit cast), despite being more correct. So, even though these functions don't need mutable data, they're prototyped as if they do.

While it's theoretically possible that an implementation could choose to use its freedom to modify the mutable data, such an implementation would break the innumerable users of `execv`-family functions that call them with string literals. Such an implementation would also break `std::process`, which currently works around this with an unsafe `as *mut _` cast, and assumes that `execvp` secretly does not modify its argument. Furthermore, there's nothing useful to be gained by being able to write to the strings in `argv` themselves but not being able to write to the array containing those strings (you can't reorder arguments, add arguments, increase the length of any parameter, etc.).

So, despite the C prototype with its legacy C problems, it's simpler for everyone for Rust to consider these functions as taking `*const *const c_char`, and it's also safe to do so. Rust does not need to expose the mistakes of C here. This patch makes that change, and drops the unsafe cast in `std::process` since it's now unnecessary.
2015-06-21 17:45:01 +00:00
Eljay
c0d485ce9a Temp fix for all constants that are missing docs. 2015-06-21 16:04:37 +01:00
Eljay
00130cff99 Fix missing_docs lint for const and static. 2015-06-21 16:02:05 +01:00
bors
a38e7585fc Auto merge of #26457 - meqif:master, r=alexcrichton
The documentation of `std::net::Shutdown` mentions says it can be passed to the `shutdown` method of `UdpSocket`, which isn't true because `UdpSocket` has no such method. This commit removes that mention.
2015-06-21 08:20:36 +00:00
bors
1ec599c5c1 Auto merge of #26455 - steveklabnik:gh26443, r=gankro
Fixes #26443

r? @Gankro
2015-06-21 06:48:50 +00:00
bors
ffe0b6657f Auto merge of #26450 - rick68:patch-7, r=alexcrichton
`core::num::from_str_radix` can't parse the prefix `+` .

http://is.gd/ewo0T2
2015-06-21 05:18:39 +00:00
bors
ecfcd2a305 Auto merge of #26416 - retep998:error-debug, r=sfackler
Fixes https://github.com/rust-lang/rust/issues/26408

Example output when using `Result::unwrap`:
```
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "The system cannot find the file specified.\r\n" } }', src/libcore\result.rs:731
```

This could technically be considered a breaking change for any code that depends on the format of the `Debug` output for `io::Error` but I sincerely hope nobody wrote code like that.
2015-06-21 03:08:28 +00:00
Steven Fackler
8193133f35 Fix logic in panic printing with no stderr
If a local stderr is present but the normal stderr is missing, we still
want to print.
2015-06-20 19:54:15 -07:00
Alexis Beingessner
b667fab292 remove redundant Send and Sync impl from Vec 2015-06-20 19:51:46 -07:00
Brian Anderson
5ff8e038f4 doc: Make it easier to find the std docs from the index
This is usually the link I want when I come to this page.
2015-06-20 19:09:56 -07:00
bors
7d6e790010 Auto merge of #26460 - nham:test-18809, r=huonw
Closes #18809.
2015-06-21 01:37:50 +00:00
bors
9ad0063a17 Auto merge of #26381 - alexcrichton:fix-srel, r=brson
In #26252 support was added to have prettier paths printed out on failure by not
passing the full path to the source file to the compiler, but instead just a
small relative path. To preserve this relative path across configurations, the
`SREL` variable was used for reconfiguring, but if `SREL` is empty then it will
attempt to run the command `configure` which is distinct from running
`./configure` (e.g. doesn't run the local script).

This commit modifies the `SREL` value to re-run the configure script by setting
it to `./` in the case where `SREL` is empty.
2015-06-20 23:09:55 +00:00
bors
cca281781f Auto merge of #26198 - stygstra:issue-24258, r=huonw
When overflow checking on `<<` and `>>` was added for integers, the `<<` and `>>` operations broke for SIMD types (`u32x4`, `i16x8`, etc.). This PR implements checked shifts on SIMD types.

Fixes #24258.
2015-06-20 21:36:49 +00:00
Nick Hamann
cb8daafe0d Add a regression test for issue #18809.
Closes #18809.
2015-06-20 16:16:54 -05:00
bors
306a99e66a Auto merge of #26411 - dotdash:fat_in_registers, r=aatch
This has a number of advantages compared to creating a copy in memory
and passing a pointer. The obvious one is that we don't have to put the
data into memory but can keep it in registers. Since we're currently
passing a pointer anyway (instead of using e.g. a known offset on the
stack, which is what the `byval` attribute would achieve), we only use a
single additional register for each fat pointer, but save at least two
pointers worth of stack in exchange (sometimes more because more than
one copy gets eliminated). On archs that pass arguments on the stack, we
save a pointer worth of stack even without considering the omitted
copies.

Additionally, LLVM can optimize the code a lot better, to a large degree
due to the fact that lots of copies are gone or can be optimized away.
Additionally, we can now emit attributes like nonnull on the data and/or
vtable pointers contained in the fat pointer, potentially allowing for
even more optimizations.

This results in LLVM passes being about 3-7% faster (depending on the
crate), and the resulting code is also a few percent smaller, for
example:

|text|data|filename|
|----|----|--------|
|5671479|3941461|before/librustc-d8ace771.so|
|5447663|3905745|after/librustc-d8ace771.so|
| | | |
|1944425|2394024|before/libstd-d8ace771.so|
|1896769|2387610|after/libstd-d8ace771.so|

I had to remove a call in the backtrace-debuginfo test, because LLVM can
now merge the tails of some blocks when optimizations are turned on,
which can't correctly preserve line info.

Fixes #22924

Cc #22891 (at least for fat pointers the code is good now)
2015-06-20 19:29:33 +00:00
Steve Klabnik
24c1e109cc TRPL: FFI: address panics
Fixes #26443
2015-06-20 14:18:28 -04:00
bors
40d19bf641 Auto merge of #26456 - Manishearth:rollup, r=Manishearth
- Successful merges: #26410, #26432, #26434, #26439, #26451, #26452
- Failed merges:
2015-06-20 17:53:36 +00:00
Ricardo Martins
7543edc851 Remove mention of UdpSocket in Shutdown docs. 2015-06-20 18:27:11 +01:00
Björn Steinbrink
f777562eab Pass fat pointers in two immediate arguments
This has a number of advantages compared to creating a copy in memory
and passing a pointer. The obvious one is that we don't have to put the
data into memory but can keep it in registers. Since we're currently
passing a pointer anyway (instead of using e.g. a known offset on the
stack, which is what the `byval` attribute would achieve), we only use a
single additional register for each fat pointer, but save at least two
pointers worth of stack in exchange (sometimes more because more than
one copy gets eliminated). On archs that pass arguments on the stack, we
save a pointer worth of stack even without considering the omitted
copies.

Additionally, LLVM can optimize the code a lot better, to a large degree
due to the fact that lots of copies are gone or can be optimized away.
Additionally, we can now emit attributes like nonnull on the data and/or
vtable pointers contained in the fat pointer, potentially allowing for
even more optimizations.

This results in LLVM passes being about 3-7% faster (depending on the
crate), and the resulting code is also a few percent smaller, for
example:

   text    data  filename
5671479 3941461  before/librustc-d8ace771.so
5447663 3905745  after/librustc-d8ace771.so

1944425 2394024  before/libstd-d8ace771.so
1896769 2387610  after/libstd-d8ace771.so

I had to remove a call in the backtrace-debuginfo test, because LLVM can
now merge the tails of some blocks when optimizations are turned on,
which can't correctly preserve line info.

Fixes #22924

Cc #22891 (at least for fat pointers the code is good now)
2015-06-20 18:58:47 +02:00
Manish Goregaokar
7effb31fa2 Rollup merge of #26452 - michaelsproul:the-second-coming, r=pnkfelix
As per #26009 this PR implements a new collation system for extended-error metadata. I've tried to keep it as simple as possible for now, so there's no uniqueness checking and minimal modularity.

Although using a lint was discussed in #26009 I decided against this because it would require converting the AST output from the plugin back into an internal data-structure. Emitting the metadata from within the plugin prevents this double-handling. We also didn't identify this as the source of the failures last time, although something untoward was definitely happening... With that in mind I would like as much feedback as possible on this before it's merged, I don't want to break the bots again!

I've successfully built for my host architecture and I'm building an ARM cross-compiler now to test my assumptions about the various `CFG` variables. Despite the confusing name of `CFG_COMPILER_HOST_TRIPLE` it is actually the compile time target triple, as explained in `mk/target.mk`.

```
# This is the compile-time target-triple for the compiler. For the compiler at
# runtime, this should be considered the host-triple. More explanation for why
# this exists can be found on issue #2400
export CFG_COMPILER_HOST_TRIPLE
```

CC @pnkfelix @brson @nrc @alexcrichton 

Closes #25705, closes #26009.
2015-06-20 21:40:37 +05:30
Manish Goregaokar
6bff14ffea Rollup merge of #26451 - nham:fix_18058, r=arielb1
Fixes #18058.
2015-06-20 21:40:37 +05:30
Manish Goregaokar
f50ae67ec2 Rollup merge of #26439 - Gankro:marker, r=pnkfelix
r? @pnkfelix
2015-06-20 21:40:36 +05:30
Manish Goregaokar
4cf7dc58a0 Rollup merge of #26434 - Munksgaard:issue24227-test, r=alexcrichton 2015-06-20 21:40:36 +05:30
Manish Goregaokar
26caaecbb4 Rollup merge of #26432 - steveklabnik:gh26424, r=alexcrichton
Fixes #26424
2015-06-20 21:40:36 +05:30
Manish Goregaokar
d7b1fd3eb1 Rollup merge of #26410 - tshepang:patch-3, r=steveklabnik 2015-06-20 21:40:36 +05:30