Commit Graph

79820 Commits

Author SHA1 Message Date
Niko Matsakis
327093007a add is_trait(DefId) helper to TyCtxt
Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-02 10:38:37 -04:00
Niko Matsakis
7bbbed9046 drive-by nits and debug
Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-02 10:38:35 -04:00
Niko Matsakis
c9d4f0615f use ty::TraitRef::identity where possible
Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-02 10:38:33 -04:00
Niko Matsakis
5c15163cb9 prove defaults meet WF requirements, not that they are WF
If we have

```rust
struct Foo<T: Copy = String> { .. }
```

the old code would have proven that `String: Copy` was WF -- this,
incidentally, also proved that `String: Copy`. The new code just
proves `String: Copy` directly.

Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-02 10:38:30 -04:00
bors
2eb6969c6a Auto merge of #51290 - Pslydhh:master, r=alexcrichton
park/park_timeout: prohibit spurious wakeups in next park

<pre><code>
// The implementation currently uses the trivial strategy of a Mutex+Condvar
// with wakeup flag, which does not actually allow spurious wakeups.
</pre></code>

Because does not actually allow spurious wakeups.
so we have let thread.inner.cvar.wait(m) in the loop to prohibit spurious wakeups.
but if notified after we locked, this notification doesn't be consumed, it return, the next park will consume this notification...this is also 'spurious wakeup' case, 'one unpark() wakeups two  park()'.

We should improve this situation:
`thread.inner.state.store(EMPTY, SeqCst);`
2018-06-29 07:34:13 +00:00
bors
3b50455c61 Auto merge of #50357 - seanmonstar:arc-weak-null, r=KodrAus
Arc: remove unused allocation from Weak::new()

It seems non-obvious that calling `Weak::new()` actually allocates space for the entire size of `T`, even though you can **never** access that data from such a constructed weak pointer. Besides that, if someone were to create many `Weak:new()`s, they could be unknowingly wasting a bunch of memory.

This change makes it so that `Weak::new()` allocates no memory at all. Instead, it is created with a null pointer. The only things done with a `Weak` are trying to upgrade, cloning, and dropping, meaning there are very few places that the code actually needs to check if the pointer is null.
2018-06-29 04:09:02 +00:00
bors
775ce97497 Auto merge of #51592 - GuillaumeGomez:fix-macro-doc-search, r=GuillaumeGomez
Fix macro missing from doc search

Fixes #51095.

r? @QuietMisdreavus
2018-06-29 01:05:02 +00:00
bors
57dd722606 Auto merge of #51884 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 6 pull requests

Successful merges:

 - #51636 (Refactor error reporting of constants)
 - #51765 (Use assert_eq! in copy_from_slice)
 - #51822 (Provide existing ref suggestions for more E0308 errors)
 - #51839 (Detect overflows of non u32 shifts)
 - #51868 (Remove process::id from 'Stabilized APIs' in 1.27.0 release notes)
 - #51875 (Explicitely disable WASM code generation for Emscripten)

Failed merges:

r? @ghost
2018-06-28 22:20:14 +00:00
Mark Rousskov
3332c0c7e1
Rollup merge of #51875 - badboy:emscripten-no-wasm, r=nikomatsakis
Explicitely disable WASM code generation for Emscripten

Emscripten changed the default behavior recently:
bd050e64bb/ChangeLog.markdown (v1381-05172018)

It now defaults to WebAssembly and requires an explicit flag to generate asm.js.
WASM=0 is also valid for older emcc and thus doesn't break it.
2018-06-28 16:07:16 -06:00
Mark Rousskov
7c0dd79e02
Rollup merge of #51868 - Lireer:master, r=pietroalbini
Remove process::id from 'Stabilized APIs' in 1.27.0 release notes

process::id was already stabilized in 1.26.0 and is marked as such in the docs.
2018-06-28 16:07:15 -06:00
Mark Rousskov
7b8fc87733
Rollup merge of #51839 - oli-obk:const_shift_overflow, r=nikomatsakis
Detect overflows of non u32 shifts
2018-06-28 16:07:14 -06:00
Mark Rousskov
e0179dfdce
Rollup merge of #51822 - estebank:suggest-more, r=nikomatsakis
Provide existing ref suggestions for more E0308 errors
2018-06-28 16:07:13 -06:00
Mark Rousskov
85804f66be
Rollup merge of #51765 - jonas-schievink:patch-1, r=KodrAus
Use assert_eq! in copy_from_slice

This will print both lengths when the assertion fails instead of just saying that they're different.

Output of current stable and nightly (modulo the exact line number):
```
thread 'main' panicked at 'destination and source slices have different lengths', libcore/slice/mod.rs:1645:9
```

Output after this PR:
```
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `123`,
 right: `456`: destination and source slices have different lengths', libcore/slice/mod.rs:1645:9
```

Note that I have not run the tests locally.
2018-06-28 16:07:12 -06:00
Mark Rousskov
57aceeecc0
Rollup merge of #51636 - oli-obk:const_diagnostics, r=eddyb
Refactor error reporting of constants

cc @eddyb

This PR should not change any behaviour. It solely simplifies the internal handling of the errors
2018-06-28 16:07:10 -06:00
Sean McArthur
24ce259782 Arc: remove unused allocation from Weak::new() 2018-06-28 11:49:47 -07:00
Esteban Küber
54a04b3b03 Provide existing ref suggestions for more E0308 errors 2018-06-28 11:37:15 -07:00
bors
e3bf634e06 Auto merge of #51687 - japaric:gh51671, r=alexcrichton
translate / export weak lang items

see #51671 for details

fixes #51671
fixes #51342

r? @michaelwoerister or @alexcrichton
2018-06-28 15:34:17 +00:00
bors
5d95db34a4 Auto merge of #51630 - joshlf:map-split-perf, r=dtolnay
Optimize RefCell refcount tracking

Address the performance concern raised in https://github.com/rust-lang/rust/pull/51466#issuecomment-398255276

cc @dtolnay  @nnethercote @rust-lang/wg-compiler-performance

cc @RalfJung @jhjourdan for soundness concerns

Can somebody kick off a perf run on this? I'm not sure how that's done, but I understand it has to be started manually.

The idea of this change is to switch to representing mutable refcount as values below 0 to eliminate some branching that was required with the old algorithm.
2018-06-28 13:23:07 +00:00
Jan-Erik Rediger
8983ff5226 Explicitely disable WASM code generation for Emscripten
Emscripten changed the default behavior recently:
bd050e64bb/ChangeLog.markdown (v1381-05172018)

It now defaults to WebAssembly and requires an explicit flag to generate asm.js.
WASM=0 is also valid for older emcc and thus doesn't break it.

Closes #51856
2018-06-28 15:02:38 +02:00
bors
9f79d2f86a Auto merge of #50997 - michaelwoerister:pre-analyze-filemaps, r=Mark-Simulacrum
Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable.

This PR removes most of the interior mutability from `FileMap`, which should be beneficial, especially in a multithreaded setting. This is achieved by initializing the state in question when the filemap is constructed instead of during lexing. Hopefully this doesn't degrade performance.

cc @wesleywiser
2018-06-28 11:20:41 +00:00
Lireer
fc8f852ebe
Remove process::id from 'Stabilized APIs' in 1.27 2018-06-28 11:30:53 +02:00
Oliver Schneider
2a55d2fc45 Rebase fallout 2018-06-28 11:19:45 +02:00
bors
d84ad59710 Auto merge of #51492 - petrochenkov:hirident, r=eddyb
Use `Ident`s in HIR and remove emulation of hygiene with gensyms

continuation of https://github.com/rust-lang/rust/pull/51072, part of https://github.com/rust-lang/rust/issues/49300

Not all `Name`s in HIR are replaced with `Ident`s, only those needed for hygiene or already having attached spans.
2018-06-28 09:16:10 +00:00
Oliver Schneider
4d473300a2 Turn the use of erroneous constants into errors again 2018-06-28 11:04:26 +02:00
Oliver Schneider
4eea1a4e5e Don't const propagate the body of constants 2018-06-28 11:04:25 +02:00
Oliver Schneider
4bb9648b27 Merge ConstVal and ConstValue 2018-06-28 11:04:25 +02:00
Oliver Schneider
221a499bf1 Fixup 2018-06-28 11:02:31 +02:00
Oliver Schneider
05994779ea Move everything over from middle::const_val to mir::interpret 2018-06-28 11:02:31 +02:00
Oliver Schneider
6005b0ad2f Move the Lrc outside the error type and name the fields 2018-06-28 11:01:35 +02:00
Oliver Schneider
6e5951c734 Remove unused type 2018-06-28 11:01:35 +02:00
Oliver Schneider
57e190c850 Address review comments 2018-06-28 11:01:35 +02:00
Oliver Schneider
6f8fe4eaef Eliminate old CTFE's ErrKind 2018-06-28 11:01:35 +02:00
Oliver Schneider
58fdac638e Simplify const error reporting 2018-06-28 11:01:35 +02:00
Michael Woerister
a1f8a6ce80 Fix FileMap::line_begin_pos().
The method relied on the FileMap still being under construction in
order for it to do what the name promises. It's now independent of
the current state.
2018-06-28 10:46:04 +02:00
Vadim Petrochenkov
d7072b5bb4 Fix rebase 2018-06-28 11:04:51 +03:00
Vadim Petrochenkov
554b4282d8 incremental: Do not hash spans for things that didn't have spans previously 2018-06-28 11:04:51 +03:00
Vadim Petrochenkov
d5e9dffddf Support delegation in stable hashing macros 2018-06-28 11:04:50 +03:00
Vadim Petrochenkov
f0622dfe5d Use Idents for associated item definitions in HIR
Remove emulation of hygiene with gensyms
2018-06-28 11:04:50 +03:00
Vadim Petrochenkov
c6ca1e4abd Use Idents in a number of structures in HIR
Namely: labels, type parameters, bindings in patterns, parameter names in functions without body.
All of these do not need hygiene after lowering to HIR, only span locations.
2018-06-28 11:04:50 +03:00
Vadim Petrochenkov
e8215a4f6f Use Idents for path segments in HIR 2018-06-28 11:04:50 +03:00
Vadim Petrochenkov
1fe9b4d763 Use Idents for associated type bindings in HIR 2018-06-28 11:04:50 +03:00
Vadim Petrochenkov
c5454c04bc Use Idents for lifetimes in HIR 2018-06-28 11:04:50 +03:00
bors
ba196bdcb1 Auto merge of #51444 - estebank:impl-static, r=nikomatsakis
Suggestion for 'static impl Trait return

When encountering a named or anonymous sup requirement (for example,
`&'a self`) and a `'static` impl Trait return type, suggest adding the
`'_` lifetime constraing to the return type.

Fix #43719, #51282.

```
error: cannot infer an appropriate lifetime
  --> $DIR/static-return-lifetime-infered.rs:17:16
   |
LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
   |                                   ----------------------- this return type evaluates to the `'static` lifetime...
LL |         self.x.iter().map(|a| a.0)
   |         ------ ^^^^
   |         |
   |         ...but this borrow...
   |
note: ...can't outlive the anonymous lifetime #1 defined on the method body at 16:5
  --> $DIR/static-return-lifetime-infered.rs:16:5
   |
LL | /     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
LL | |         self.x.iter().map(|a| a.0)
LL | |     }
   | |_____^
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 16:5
   |
LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2018-06-28 03:57:28 +00:00
bors
99a9d6806d Auto merge of #51538 - nikomatsakis:nll-perf-examination, r=eddyb
convert NLL ops to caches

This is a extension of <https://github.com/rust-lang/rust/pull/51460>. It uses a lot more caching than we used to do. This caching is not yet as efficient as it could be, but I'm curious to see the current perf results.

This is the high-level idea: in the MIR type checker, use [canonicalized queries](https://rust-lang-nursery.github.io/rustc-guide/traits/canonical-queries.html) for all the major operations. This is helpful because the MIR type check is operating in a context where all types are fully known (mostly, anyway) but regions are completely renumbered. This means we often wind up with duplicate queries like `Foo<'1, '2> :Bar` and `Foo<'3, '4>: Bar`. Canonicalized queries let us re-use the results. By the final commit in this PR, we can essentially just "read off" the resulting region relations and add them to the NLL type check.
2018-06-28 01:41:40 +00:00
bors
266afeb17c Auto merge of #51859 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

Successful merges:

 - #49987 (Add str::split_ascii_whitespace.)
 - #50342 (Document round-off error in `.mod_euc()`-method, see issue #50179)
 - #51658 (Only do sanity check with debug assertions on)
 - #51799 (Lower case some feature gate error messages)
 - #51800 (Add a compiletest header for edition)
 - #51824 (Fix the error reference for LocalKey::try_with)
 - #51842 (Document that Layout::from_size_align does not allow align=0)

Failed merges:

r? @ghost
2018-06-27 23:41:23 +00:00
kennytm
99a0d6bf0e
Rollup merge of #51842 - rust-lang:align-is-nonzero, r=cramertj
Document that Layout::from_size_align does not allow align=0

This was already implied since zero is not a power of two, but maybe worth pointing out.
2018-06-28 06:15:43 +08:00
kennytm
7f4347f8e2
Rollup merge of #51824 - vorner:thread-local-try-with-doc, r=kennytm
Fix the error reference for LocalKey::try_with

There's no such thing as `ThreadLocalError` and the method obviously returns `AccessError`, so adjusting (probably only outdated docs).
2018-06-28 06:15:42 +08:00
kennytm
700a2f799a
Rollup merge of #51800 - mark-i-m:edition2018compiletest, r=nikomatsakis
Add a compiletest header for edition

r? @nikomatsakis

Are the `-Zunstable-options` options needed in these tests? It looks like they aren't. If not, I can remove them.
2018-06-28 06:15:41 +08:00
kennytm
770d0fba63
Rollup merge of #51799 - mark-i-m:lower_case_feature_gate, r=mark-i-m
Lower case some feature gate error messages
2018-06-28 06:15:40 +08:00
kennytm
1ebd9adef4
Rollup merge of #51658 - oli-obk:unregress_perf, r=nikomatsakis
Only do sanity check with debug assertions on

r? @nnethercote

I'm slighty confused. These changes address code that the `unused-warnings` benchmark doesn't go through, yet I see a 5% improvement to nightly on the `check` run, and no improvement on the other runs.

Maybe this change allows unrelated code in the same function to be better optimized?
2018-06-28 06:15:39 +08:00