Commit Graph

84501 Commits

Author SHA1 Message Date
Alex Crichton
cbe9f33b8b std: Implement TLS for wasm32-unknown-unknown
This adds an implementation of thread local storage for the
`wasm32-unknown-unknown` target when the `atomics` feature is
implemented. This, however, comes with a notable caveat of that it
requires a new feature of the standard library, `wasm-bindgen-threads`,
to be enabled.

Thread local storage for wasm (when `atomics` are enabled and there's
actually more than one thread) is powered by the assumption that an
external entity can fill in some information for us. It's not currently
clear who will fill in this information nor whose responsibility it
should be long-term. In the meantime there's a strategy being gamed out
in the `wasm-bindgen` project specifically, and the hope is that we can
continue to test and iterate on the standard library without committing
to a particular strategy yet.

As to the details of `wasm-bindgen`'s strategy, LLVM doesn't currently
have the ability to emit custom `global` values (thread locals in a
`WebAssembly.Module`) so we leverage the `wasm-bindgen` CLI tool to do
it for us. To that end we have a few intrinsics, assuming two global values:

* `__wbindgen_current_id` - gets the current thread id as a 32-bit
  integer. It's `wasm-bindgen`'s responsibility to initialize this
  per-thread and then inform libstd of the id. Currently `wasm-bindgen`
  performs this initialization as part of the `start` function.
* `__wbindgen_tcb_{get,set}` - in addition to a thread id it's assumed
  that there's a global available for simply storing a pointer's worth
  of information (a thread control block, which currently only contains
  thread local storage). This would ideally be a native `global`
  injected by LLVM, but we don't have a great way to support that right
  now.

To reiterate, this is all intended to be unstable and purely intended
for testing out Rust on the web with threads. The story is very likely
to change in the future and we want to make sure that we're able to do
that!
2018-10-11 09:57:55 -07:00
bors
eae47a4048 Auto merge of #54734 - pawroman:fix_range_borrowing_suggestion, r=varkor
Fix range literals borrowing suggestions

Fixes #54505. The compiler issued incorrect range borrowing suggestions (missing `()` around borrows of range literals). This was not correct syntax (see the issue for an example).

With changes in this PR, this is fixed for all types of `Range` literals.

Thanks again to @varkor and @estebank for their invaluable help and guidance.

r? @varkor
2018-10-09 22:36:14 +00:00
bors
96cafc53cf Auto merge of #54613 - matthiaskrgr:string_from_inline_53681, r=nagisa
liballoc: mark str.to_owned() and String::from(&str) as #[inline].

Fixes #53681
2018-10-09 19:57:55 +00:00
bors
0e07c4281c Auto merge of #54762 - RalfJung:miri-validate, r=oli-obk
Prepare miri engine for enforcing validity invariant during execution

In particular, make recursive checking of references optional, and add a `const_mode` parameter that says whether `usize` is allowed to contain a pointer. Also refactor validation a bit to be type-driven at the "leafs" (primitive types), and separately validate scalar layout to catch `NonNull` violations (which it did not properly validate before).

Fixes https://github.com/rust-lang/rust/issues/53826
Also fixes https://github.com/rust-lang/rust/issues/54751

r? @oli-obk
2018-10-09 17:19:56 +00:00
Ralf Jung
fe96f8235c validity: check dynamic size, not static
also less verbose logging
2018-10-09 13:08:00 +02:00
Ralf Jung
976880aa84 dont fail when validating non-local closures 2018-10-09 13:08:00 +02:00
Ralf Jung
6899af82fd box is also a primitive type 2018-10-09 13:08:00 +02:00
Ralf Jung
db1663d598 update miri 2018-10-09 13:08:00 +02:00
Ralf Jung
fcf6b5c79b add fixme for potential perf optimization 2018-10-09 13:08:00 +02:00
Ralf Jung
e09e3c898c fix nits and handling of extern static 2018-10-09 13:08:00 +02:00
Ralf Jung
322017b2bc unify handling of thin and fat pointers by moving primitive type handling out of aggregate handling
Also, make enum variant handling a bit nicer
2018-10-09 13:08:00 +02:00
Ralf Jung
95593331bf add some tests with constants that better be valid 2018-10-09 13:08:00 +02:00
Ralf Jung
22c1a0acc8 For now, accept all data for integer types when not in const mode
We'll try ruling out undef later
2018-10-09 13:08:00 +02:00
Ralf Jung
9bb4bcd770 tidy up 2018-10-09 13:08:00 +02:00
Ralf Jung
654d9ff618 do not look at refs to external statics at all 2018-10-09 13:08:00 +02:00
Ralf Jung
616cb6356f miri engine: also check return type before calling function 2018-10-09 13:08:00 +02:00
Ralf Jung
d2b9b1de05 add machine option to validate things on every copy 2018-10-09 13:08:00 +02:00
Ralf Jung
13bdc1673d move a test to a better place 2018-10-09 13:08:00 +02:00
Ralf Jung
69a320f40d also validate everything that has a Scalar layout, to catch NonNull 2018-10-09 13:08:00 +02:00
Ralf Jung
0a2fae6cb7 fix validating arrays of ZSTs
Fixes #54751
2018-10-09 13:08:00 +02:00
Ralf Jung
f65d3b5491 switch validation of scalars to be type-driven
This does not actually regress anything.  It would regress NonNull, but we
didn't handle that correctly previously either.
2018-10-09 13:08:00 +02:00
Ralf Jung
ff5a245f52 check that entire ref is in-bounds before recursing; add macro for validation msgs on error 2018-10-09 13:08:00 +02:00
Ralf Jung
bf5e6ebdd3 miri validity: make recursive ref checking optional 2018-10-09 13:08:00 +02:00
bors
e1643a8968 Auto merge of #54757 - nikomatsakis:nll-issue-54573-user-annot, r=pnkfelix
user annotations in patterns

Fixes https://github.com/rust-lang/rust/issues/54573

r? @pnkfelix
2018-10-09 10:15:44 +00:00
bors
607243b6f9 Auto merge of #54798 - matthewjasper:free-region-closure-errors, r=nikomatsakis
[NLL]  Improve closure region bound errors

Previously, we would report free region errors that originate from closure with the span of the closure and a "closure body requires ..." message. This is now updated to use a reason and span from inside the closure.
2018-10-09 07:22:14 +00:00
Paweł Romanowski
1f7dafbb77 Fix test for windows os 2018-10-09 08:24:29 +02:00
Niko Matsakis
ccba716099 add some debug! to type checking 2018-10-08 19:21:22 -04:00
Niko Matsakis
16e1aaf09d document create_substs_for_generic_args 2018-10-08 19:20:37 -04:00
Niko Matsakis
40ab41fd18 add pattern type ascriptions for tuple/brace structs/enums 2018-10-08 19:20:37 -04:00
Niko Matsakis
a609384561 do not skip renumbering the place in place-type-ascriptions 2018-10-08 19:20:37 -04:00
Niko Matsakis
71fed065f7 extract more helper fns around user substs 2018-10-08 19:20:37 -04:00
Niko Matsakis
f4b711516d move user_annotated_ty_for_adt into a helper trait 2018-10-08 19:20:37 -04:00
bors
b1a137d015 Auto merge of #54686 - zackmdavis:zero_life, r=nikomatsakis
structured suggestions for unused-lifetimes lint

Regretfully, resolve_lifetime.rs is suffering from a bit of rightward-drift, but

![zero_life](https://user-images.githubusercontent.com/1076988/46253407-010e7880-c430-11e8-8faf-b9afc1405415.png)

r? @nikomatsakis
2018-10-08 22:06:52 +00:00
Paweł Romanowski
882e373275 Attempt to fix #54505 tests for wasm 2018-10-08 18:39:09 +02:00
bors
423d810986 Auto merge of #54871 - u32i64:master, r=frewsxcv
Remove unnecessary comma in `libstd/thread/mod.rs` doc comment

Fix typo in `libstd/thread/mod.rs` doc comment: remove unnecessary comma.
2018-10-08 12:17:36 +00:00
bors
96734ae0d4 Auto merge of #54865 - pietroalbini:1.29.2-notes, r=pietroalbini
Backport 1.29.2 release notes to master

r? @ghost
2018-10-08 09:29:59 +00:00
bors
25a75a4d86 Auto merge of #54847 - ljedrz:kill_graphviz_intocow, r=pnkfelix
Cleanup: remove graphviz::IntoCow

It's just `Into<Cow<...>>` and the applicable methods already exist for `Vec`/`[T]` and `String`/`str`.
2018-10-08 06:50:25 +00:00
bors
ef5c00d0ca Auto merge of #54700 - frewsxcv:frewsxcv-binary-search, r=GuillaumeGomez
Clarify docs for when binary_search has many matches.

Fixes https://github.com/rust-lang/rust/issues/51817.
2018-10-08 03:04:50 +00:00
Zack M. Davis
efd7a31150 in which rightward drift is opposed
Thanks to reviewers Tyler Mandry (for pointing out that this is
ridiculous and we need a helper function), Niko Matsakis (for pointing
out that the span-calculation code only has a couple free variables),
and Esteban Küber (for pointing out `get_generics`).
2018-10-07 19:46:19 -07:00
Zack M. Davis
b1b684ef23 structured suggestions for unused-lifetimes lint 2018-10-07 19:17:39 -07:00
bors
aefe9b099a Auto merge of #54609 - kzys:404-search, r=GuillaumeGomez
Add the library search box on the 404 page

It actually has a link to search already, but it would be better to
have the search "box" as like index.md to be consistent.

<style> can be shared with index.md, but these pages currently
use https://doc.rust-lang.org/rust.css directly.

Fixes #14572.
2018-10-08 00:33:19 +00:00
bors
b9adc3327e Auto merge of #53517 - phungleson:fix-impl-from-for-error, r=frewsxcv
Add doc for impl From for Error

As part of issue #51430 (cc @skade).

The impl is very simple, let me know if we need to go into any details.
2018-10-07 22:00:04 +00:00
bors
b2d6ea98b0 Auto merge of #54810 - 1aim:unused-impl-trait, r=oli-obk
Fix dead code lint for functions using impl Trait

Fixes https://github.com/rust-lang/rust/issues/54754

This is a minimal fix that doesn't add any new queries or touches unnecessary code. Please nominate for beta backport if wanted.
2018-10-07 19:30:24 +00:00
bors
0ee045ea09 Auto merge of #54835 - oli-obk:mögen_konstante_funktionen_doch_bitte_endlich_stabil_sein, r=Centril
Stabilize `min_const_fn`

tracking issue: #53555

r? @Centril
2018-10-07 13:37:07 +00:00
Corey Farwell
b5c64e2e26 Clarify docs for when binary_search has many matches.
Fixes https://github.com/rust-lang/rust/issues/51817.
2018-10-07 08:46:22 -04:00
bors
5a6f122126 Auto merge of #54813 - petrochenkov:uilocale, r=alexcrichton
Fix two UI tests with locale-dependent output

Closes https://github.com/rust-lang/rust/issues/54719
2018-10-07 11:10:39 +00:00
bors
987a50bab3 Auto merge of #54823 - euclio:needs-test, r=alexcrichton
Add tests for some E-needstest issues

Fixes #28134.
Fixes #24338.
Fixes #29743.
2018-10-07 08:32:19 +00:00
bors
13429136b8 Auto merge of #54451 - alexcrichton:no-mangle-extern-linkage, r=michaelwoerister
rustc: Allow `#[no_mangle]` anywhere in a crate

This commit updates the compiler to allow the `#[no_mangle]` (and
`#[export_name]` attributes) to be located anywhere within a crate.
These attributes are unconditionally processed, causing the compiler to
always generate an exported symbol with the appropriate name.

After some discussion on #54135 it was found that not a great reason
this hasn't been allowed already, and it seems to match the behavior
that many expect! Previously the compiler would only export a
`#[no_mangle]` symbol if it were *publicly reachable*, meaning that it
itself is `pub` and it's otherwise publicly reachable from the root of
the crate. This new definition is that `#[no_mangle]` *is always
reachable*, no matter where it is in a crate or whether it has `pub` or
not.

This should make it much easier to declare an exported symbol with a
known and unique name, even when it's an internal implementation detail
of the crate itself. Note that these symbols will persist beyond LTO as
well, always making their way to the linker.

Along the way this commit removes the `private_no_mangle_functions` lint
(also for statics) as there's no longer any need to lint these
situations. Furthermore a good number of tests were updated now that
symbol visibility has been changed.

Closes #54135
2018-10-07 03:07:16 +00:00
bors
dbecb7a644 Auto merge of #54782 - pnkfelix:issue-54556-semi-on-tail-diagnostic, r=nikomatsakis
NLL: temps in block tail expression diagnostic

This change adds a diagnostic that explains when temporaries in a block tail expression live longer than block local variables that they borrow, and attempts to suggest turning the tail expresion into a statement (either by adding a semicolon at the end, when its result value is clearly unused, or by introducing a `let`-binding for the result value and then returning that).

Fix #54556
2018-10-07 00:28:26 +00:00
Alex Crichton
d7d7045374 rustc: Allow #[no_mangle] anywhere in a crate
This commit updates the compiler to allow the `#[no_mangle]` (and
`#[export_name]` attributes) to be located anywhere within a crate.
These attributes are unconditionally processed, causing the compiler to
always generate an exported symbol with the appropriate name.

After some discussion on #54135 it was found that not a great reason
this hasn't been allowed already, and it seems to match the behavior
that many expect! Previously the compiler would only export a
`#[no_mangle]` symbol if it were *publicly reachable*, meaning that it
itself is `pub` and it's otherwise publicly reachable from the root of
the crate. This new definition is that `#[no_mangle]` *is always
reachable*, no matter where it is in a crate or whether it has `pub` or
not.

This should make it much easier to declare an exported symbol with a
known and unique name, even when it's an internal implementation detail
of the crate itself. Note that these symbols will persist beyond LTO as
well, always making their way to the linker.

Along the way this commit removes the `private_no_mangle_functions` lint
(also for statics) as there's no longer any need to lint these
situations. Furthermore a good number of tests were updated now that
symbol visibility has been changed.

Closes #54135
2018-10-06 13:57:30 -07:00