Commit Graph

43563 Commits

Author SHA1 Message Date
bors
467e4a6681 Auto merge of #25952 - alexcrichton:fix-scoped-tls, r=aturon
Currently the compiler has no knowledge of `#[thread_local]` which forces users
to take on two burdens of unsafety:

* The lifetime of the borrow of a `#[thread_local]` static is **not** `'static`
* Types in `static`s are required to be `Sync`

The thread-local modules mostly curb these facets of unsafety by only allowing
very limited scopes of borrows as well as allowing all types to be stored in a
thread-local key (regardless of whether they are `Sync`) through an `unsafe
impl`.

Unfortunately these measures have the consequence of being able to take the
address of the key itself and send it to another thread, allowing the same key
to be accessed from two different threads. This is clearly unsafe, and this
commit fixes this problem with the same trick used by `LocalKey`, which is to
have an indirect function call to find the address of the *current thread's*
thread local. This way the address of thread local keys can safely be sent among
threads as their lifetime truly is `'static`.

This commit will reduce the performance of cross-crate scoped thread locals as
it now requires an indirect function call, but this can likely be overcome in a
future commit.

Closes #25894
2015-06-16 20:00:46 +00:00
bors
10356458a7 Auto merge of #24738 - joliv:patch-2, r=steveklabnik
The "unit value" is a value of the "unit type," not the "unit value type." Regardless of correctness, this straight syntax is easier to grok.

Part of #16676

Sorry if something's off here, it's my first pull request to rust!
2015-06-16 17:08:36 +00:00
bors
520a471bc5 Auto merge of #26323 - steveklabnik:gh26320, r=alexcrichton
Fixes #26320
2015-06-16 10:40:33 +00:00
bors
4806210db9 Auto merge of #26318 - steveklabnik:gh26268, r=alexcrichton
Fixes #26268
2015-06-16 08:20:57 +00:00
bors
00382a592b Auto merge of #26317 - steveklabnik:gh25956, r=alexcrichton
It isn't really neccesary, but is pretty dense.

Fixes #25956
2015-06-16 06:44:56 +00:00
bors
f6d53af85f Auto merge of #24719 - :patch-1, r=steveklabnik 2015-06-16 05:08:13 +00:00
joliv
b87056fa31 Add unit type info and update associated link
Fixes #25244
2015-06-15 23:04:55 -04:00
bors
af8a4a0805 Auto merge of #26313 - steveklabnik:fix_str_docs, r=alexcrichton
Because these structures are created by a macro, the doc comments
don't quite work: the leading /// isn't stripped. Instead, just
use #[doc] so that they render correctly.
2015-06-16 01:57:34 +00:00
bors
906ad72462 Auto merge of #26311 - jooert:fix25855, r=steveklabnik
Use result of the computation to prevent the compiler from optimising
too much. Change `_x` to `x` and therefore remove the paragraph about
the underscore.

Fixes #25855.

r? @steveklabnik
2015-06-15 23:48:39 +00:00
bors
c656e99e43 Auto merge of #26282 - arielb1:probe-leak, r=nikomatsakis
It can introduce obligations to the fulfillment context, which would
incorrectly still remain after the probe finished.

Fixes #25679.

r? @eddyb
2015-06-15 21:27:43 +00:00
Steve Klabnik
22b6a5dc2a Significantly simplify generic example
Fixes #26320
2015-06-15 16:38:05 -04:00
bors
73fb19c04a Auto merge of #26275 - arielb1:unconstrained-projection, r=nikomatsakis
Fixes #26262

Because this rejects code that previously compiled, this is a [breaking-change]

r? @nikomatsakis
2015-06-15 19:52:15 +00:00
bors
a53a098b72 Auto merge of #26293 - mihneadb:rustdoc-search-orphan-methods, r=alexcrichton
In https://github.com/rust-lang/rust/pull/23289, I did not include the type information for searching for orphan methods (methods that are defined in a module and implemented in another - doing this causes rustdoc sometimes to first find the impl before the actual type).

This PR fixes this. By merging this, searches for `char -> bool` will also find `is_alphabetic`, for example (which otherwise was only found for `charext -> bool`).


cc @alexcrichton
2015-06-15 18:17:22 +00:00
Steve Klabnik
1792ef6ae4 Clarify that the following will error
Fixes #26268
2015-06-15 13:18:07 -04:00
Steve Klabnik
75ffcd8e59 Remove confusing paragraph from Trait Objects
It isn't really neccesary, but is pretty dense.

Fixes #25956
2015-06-15 13:16:16 -04:00
Johannes Oertel
3e7ab1b5cb Update example in "Rust Inside Other Languages"
Use result of the computation to prevent the compiler from optimising
too much. Change `_x` to `x` and therefore remove the paragraph about
the underscore.

Fixes #25855.
2015-06-15 19:12:34 +02:00
Steve Klabnik
759a5d1022 Fix up Split docs
Because these structures are created by a macro, the doc comments
don't quite work: the leading /// isn't stripped. Instead, just
use #[doc] so that they render correctly.
2015-06-15 12:25:10 -04:00
Ariel Ben-Yehuda
6cdccc5a78 Make impl-trait-ref associated types work in methods 2015-06-15 18:27:35 +03:00
Ariel Ben-Yehuda
1af72660a7 Don't call instantiate_type_scheme during method probing
It can introduce obligations to the fulfillment context, which would
incorrectly still remain after the probe finished.

Fixes #25679.
2015-06-15 18:27:35 +03:00
bors
d9b8015828 Auto merge of #26302 - aidanhs:aphs-fix-musl-libc, r=alexcrichton
musl may not be available on the target user's machine, and even if it is, we may not be able to find it because of how static libraries are searched for.
Instead, use the liblibc archive created at rust compile time which already contains libc.a.

---

To be honest, my brain is bending a bit at this point and I wonder if I'm doing something a bit stupid.

Problem: building the libc crate with target musl. It says "could not find native static library `c`, perhaps an -L flag is missing?".

Some pondering: the key problem is the way static archives are searched for (note that a musl build attempts to statically link to libc) - they aren't. There are three locations which are checked (including `$PREFIX/lib/rustlib/x86_64-unknown-linux-musl/lib`), but this does not include `$PREFIX/lib`...and it probably shouldn't - rustc is mimicking the way native lib generation works by forcing you to provide the path yourself. You can make it work `cargo rustc` with `-L native=/path/to/musl/lib`, but even if this went in a build script for the libc crate, it wouldn't work if musl isn't installed by the end user.

I've sprinkled `not(test)` around but I've no idea if I've done it right.

This patch allows `cargo build --target x86_64-unknown-linux-musl` to work on a crate with a dependency on libc, where the musl-enabled rust was compiled before this patch. I've not yet kicked off the long process to build a musl-enabled rust with this patch, so it might be broken there.

Sorry for the rambling.

r? @alexcrichton
2015-06-15 14:07:48 +00:00
Aidan Hobson Sayers
52862e4cda When building libc crate with musl, don't look for libc.a
musl may not be available on the target user's machine, and even if
it is, we may not be able to find it because of how static libraries
are searched for.
Instead, use the transitively included liblibc which includes libc.a.
2015-06-15 13:42:18 +01:00
bors
0d82fb55db Auto merge of #26307 - nrc:save-bugs, r=cmr
r? @brson (or anyone, really)
2015-06-15 09:02:31 +00:00
bors
7517ecf4fc Auto merge of #26168 - sfackler:stdout-panic, r=alexcrichton
Closes #25977

The various `stdfoo_raw` methods in std::io now return `io::Result`s,
since they may not exist on Windows. They will always return `Ok` on
Unix-like platforms.

[breaking-change]
2015-06-15 06:44:42 +00:00
Nick Cameron
a54bbac99a save-analysis: fix a couple of span bugs 2015-06-15 18:10:49 +12:00
bors
a54a809219 Auto merge of #25359 - thepowersgang:result-expect-2, r=alexcrichton
As it says in the title. I've added an `expect` method to `Result` that allows printing both an error message (e.g. what operation was attempted), and the error value. This is separate from the `unwrap` and `ok().expect("message")` behaviours.
2015-06-15 05:11:53 +00:00
John Hodge
0937c10f3c libcore/Result - RFC#1119 Add an 'expect' method to Result 2015-06-15 12:00:16 +08:00
Steven Fackler
a7bbd7da4e Implement RFC 1014
Closes #25977

The various `stdfoo_raw` methods in std::io now return `io::Result`s,
since they may not exist on Windows. They will always return `Ok` on
Unix-like platforms.

[breaking-change]
2015-06-14 20:17:06 -07:00
bors
7d04623033 Auto merge of #26290 - michaelsproul:url-line-limit, r=alexcrichton
The plugin that enforces error explanation line-length is a bit restrictive, particularly when attempting to use URLs in explanations (cf #26163).

Jashank will still have to do some mucking around with `#[cfg(not(stage0))]` attributes or else wait until a snapshot with this commit lands.
2015-06-15 01:57:17 +00:00
bors
8937ec1004 Auto merge of #26265 - retep998:heapalloc, r=alexcrichton
This removes our dependency on the CRT for memory allocation.
2015-06-15 00:24:31 +00:00
bors
4f3c19f547 Auto merge of #26110 - nrc:save-api-3, r=brson
r? @huonw
2015-06-14 22:47:55 +00:00
Nick Cameron
718268398e Rebasing and bug fixing 2015-06-15 10:06:01 +12:00
bors
b26eeffacb Auto merge of #26213 - semarie:openbsd-morestack, r=alexcrichton
don't try to bind __morestack symbol under OpenBSD as the platform don't
have morestack support.

r? @alexcrichton 

it unbreak build under OpenBSD. Does some others platforms don't have morestack too ? They should be impacted by this problem too.
2015-06-14 21:15:32 +00:00
Nick Cameron
92d6676412 save-analysis: use a macro for 'downcasting' 2015-06-15 08:16:35 +12:00
Nick Cameron
788fdddf37 save-analysis: API-ify struct lits 2015-06-15 08:16:35 +12:00
Nick Cameron
04b32cecac save-analysis: merge StructRef and TypeRef 2015-06-15 08:15:29 +12:00
Nick Cameron
78c25eabd5 save-analysis: API-ify impls 2015-06-15 08:15:29 +12:00
Nick Cameron
abe5f7b95a save-analysis: move fields to the API 2015-06-15 08:14:50 +12:00
bors
e89bb24cb2 Auto merge of #26071 - petrochenkov:assert1, r=alexcrichton
`assert_eq!` has better diagnostics than `assert!` and is more helpful when something actually breaks, but the diagnostics has it's price - `assert_eq!` generate some formatting code which is slower to compile and possibly run.
[My measurements](https://internals.rust-lang.org/t/assert-a-b-or-assert-eq-a-b/1367/12?u=petrochenkov) show that presence of this formatting code doesn't affect compilation + execution time of the test suite significantly, so `assert_eq!` can be used instead of `assert!` consistently.

(Some tests doesn't reside in src/test, they are not affected by these changes, I'll probably open a separate PR for them later)
2015-06-14 19:42:26 +00:00
bors
cc44423566 Auto merge of #26296 - aidanhs:aphs-fix-musl-make-install, r=alexcrichton
musl only creates rlib files for stdlib linking so we need to ignore the `CFG_LIB_GLOB_` setting, otherwise we an error:
```
$ make --debug VERBOSE=1 dist-tar-bins
[...]
            Successfully remade target file `prepare-target-x86_64-unknown-linux-gnu-host-x86_64-unknown-linux-gnu-2-dir-x86_64-unknown-linux-gnu'.
             File `prepare-target-x86_64-unknown-linux-musl-host-x86_64-unknown-linux-gnu-2-dir-x86_64-unknown-linux-gnu' does not exist.
            Must remake target `prepare-target-x86_64-unknown-linux-musl-host-x86_64-unknown-linux-gnu-2-dir-x86_64-unknown-linux-gnu'.
umask 022 && mkdir -p tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unknown-linux-musl/lib
umask 022 && mkdir -p tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unknown-linux-gnu/bin
LIB_NAME="liblibc-d8ace771.rlib"; MATCHES=""; if [ -n "$MATCHES" ]; then echo "warning: one or libraries matching Rust library 'liblibc-*.rlib'" && echo "  (other than '$LIB_NAME' itself) alre
ady present"     && echo "  at destination tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unknown-linux-musl/lib:"      && echo $MATCHES ; fi
install -m644 `ls -drt1 x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-*.rlib` tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unk
nown-linux-musl/lib/
LIB_NAME=""; MATCHES=""; if [ -n "$MATCHES" ]; then echo "warning: one or libraries matching Rust library 'libstd-*.so'" && echo "  (other than '$LIB_NAME' itself) already present"     && echo
 "  at destination tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unknown-linux-musl/lib:"      && echo $MATCHES ; fi
install -m644 `ls -drt1 x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-*.so` tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unknow
n-linux-musl/lib/
ls: cannot access x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-*.so: No such file or directory
install: missing destination file operand after ‘tmp/dist/rustc-1.2.0-dev-x86_64-unknown-linux-gnu-image/lib/rustlib/x86_64-unknown-linux-musl/lib/’
Try 'install --help' for more information.
make: *** [prepare-target-x86_64-unknown-linux-musl-host-x86_64-unknown-linux-gnu-2-dir-x86_64-unknown-linux-gnu] Error 1
```

`CFG_INSTALL_ONLY_RLIB_` is provided for this reason and fixes `make install` and `make dist`.
2015-06-14 17:18:25 +00:00
Aidan Hobson Sayers
5ef250427d musl only uses rlib files for stdlib linking 2015-06-14 16:18:51 +01:00
Mihnea Dobrescu-Balaur
434684bc9e Find type of orphan methods for rustdoc search. 2015-06-14 14:35:44 +03:00
bors
606e4b26c7 Auto merge of #26252 - bluss:relative-paths, r=alexcrichton
mk: Build crates with relative source file paths

The path we pass to rustc will be visible in panic messages and
backtraces: they will be user visible!

Avoid junk in these paths by passing relative paths to rustc.

For most advanced users, `libcore` or `libstd` in the path will be
a clue to the location -- inside our code, not theirs.

Store both the relative path to the source as well as the absolute.
Use the relative path where it matters, compiling the main crates,
instead of changing all of the build process to cope with relative
paths.

Example output after this patch:

```
$ ./testunwrap
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:362
$ RUST_BACKTRACE=1 ./testunwrap
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:362
stack backtrace:
   1:     0x7ff59c1e9956 - sys::backtrace::write::h67a542fd2b201576des
                        at ../src/libstd/sys/unix/backtrace.rs:158
   2:     0x7ff59c1ed5b6 - panicking::on_panic::h3d21c41cdd5c12d41Xw
                        at ../src/libstd/panicking.rs:58
   3:     0x7ff59c1e7b6e - rt::unwind::begin_unwind_inner::h9f3a5440cebb8baeLDw
                        at ../src/libstd/rt/unwind/mod.rs:273
   4:     0x7ff59c1e7f84 - rt::unwind::begin_unwind_fmt::h4fe8a903e0c296b0RCw
                        at ../src/libstd/rt/unwind/mod.rs:212
   5:     0x7ff59c1eced7 - rust_begin_unwind
   6:     0x7ff59c22c11a - panicking::panic_fmt::h00b0cd49c98a9220i5B
                        at ../src/libcore/panicking.rs:64
   7:     0x7ff59c22b9e0 - panicking::panic::hf549420c0ee03339P3B
                        at ../src/libcore/panicking.rs:45
   8:     0x7ff59c1e621d - option::Option<T>::unwrap::h501963526474862829
   9:     0x7ff59c1e61b1 - main::hb5c91ce92347d1e6eaa
  10:     0x7ff59c1f1c18 - rust_try_inner
  11:     0x7ff59c1f1c05 - rust_try
  12:     0x7ff59c1ef374 - rt::lang_start::h7e51e19c6677cffe5Sw
                        at ../src/libstd/rt/unwind/mod.rs:147
                        at ../src/libstd/rt/unwind/mod.rs:130
                        at ../src/libstd/rt/mod.rs:128
  13:     0x7ff59c1e628e - main
  14:     0x7ff59b3f6b44 - __libc_start_main
  15:     0x7ff59c1e6078 - <unknown>
  16:                0x0 - <unknown>
```
2015-06-14 11:20:36 +00:00
Michael Sproul
328df8ebf9 diagnostics: Allow long URLs in error explanations. 2015-06-14 18:46:32 +10:00
Sébastien Marie
b804c241b3 inverse the logic in code inclusion
instead of enumerate the (long) list of platforms to exclude, use only
the short list of platforms to include.

should fixes __morestack symbol problem under openbsd
2015-06-14 07:08:10 +02:00
bors
043f93f278 Auto merge of #26285 - rick68:patch-3, r=alexcrichton
`FormatError` is not exist anymore.
2015-06-14 04:21:47 +00:00
Wei-Ming Yang
7f25185138 Update mod.rs
`FormatError` is not exist anymore.
2015-06-14 11:32:04 +08:00
bors
6e7fcc44ae Auto merge of #26278 - tamird:compiletest, r=alexcrichton 2015-06-13 23:35:28 +00:00
bors
5f3233f092 Auto merge of #26250 - steveklabnik:remove_html_literals_test, r=alexcrichton
This test now works again

Fixes #20673

r? @alexcrichton
2015-06-13 22:03:42 +00:00
bors
325066051f Auto merge of #26249 - steveklabnik:remove_extern_panic, r=alexcrichton
This test has an interesting history, because of fail -> panic. It was
originally called extern-fail.rs:
https://github.com/rust-lang/rust/commits/master/src/test/run-fail/extern-fail.rs

It lived for a while, but was disabled in August 2013:
ce95b01014

As you can see, that failure was not specific to this test, however,
this code does stuff with the runtime, which was removed. Given that
it hasn't even been able to compile in a long time, we should just
remove it.

r? @brson
2015-06-13 20:33:53 +00:00
Peter Atashian
ebbd90d28f Switch to direct HeapAlloc on Windows when not using jemalloc
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-06-13 15:13:16 -04:00