Commit Graph

76939 Commits

Author SHA1 Message Date
Guillaume Gomez
035ec5bbb6 Add warning if a resolution failed 2018-04-16 23:33:43 +02:00
bors
49317cd511 Auto merge of #49130 - smmalis37:range, r=alexcrichton
Move Range*::contains to a single default impl on RangeBounds

Per the ongoing discussion in #32311.

This is my first PR to Rust (woo!), so I don't know if this requires an amendment to the original range_contains RFC, or not, or if we can just do a psuedo-RFC here. While this may no longer follow the explicit decision made in that RFC, I believe this better follows its spirit by adding the new contains method to all Ranges. It also allows users to be generic over all ranges and use this method without writing it themselves (my personal desired use case).

This also somewhat answers the unanswered question about Wrapping ranges in the above issue by instead just punting it to the question of what those types should return for start() & end(), or if they should implement RangeArgument at all. Those types could also implement their own contains method without implementing this trait, in which case the question remains the same.

This does add a new contains method to types that already implemented RangeArgument but not contains. These types are RangeFull, (Bound<T>, Bound<T>), (Bound<&'a T>, Bound<&'a T>). No tests have been added for these types yet. No inherent method has been added either.

r? @alexcrichton
2018-04-16 16:07:10 +00:00
bors
1ef1563518 Auto merge of #48945 - clarcharr:iter_exhaust, r=Kimundi
Replace manual iterator exhaust with for_each(drop)

This originally added a dedicated method, `Iterator::exhaust`, and has since been replaced with `for_each(drop)`, which is more idiomatic.

<del>This is just shorthand for `for _ in &mut self {}` or `while let Some(_) = self.next() {}`. This states the intent a lot more clearly than the identical code: run the iterator to completion.

<del>At least personally, my eyes tend to gloss over `for _ in &mut self {}` without fully paying attention to what it does; having a `Drop` implementation akin to:

<del>`for _ in &mut self {}; unsafe { free(self.ptr); }`</del>

<del>Is not as clear as:

<del>`self.exhaust(); unsafe { free(self.ptr); }`

<del>Additionally, I've seen debate over whether `while let Some(_) = self.next() {}` or `for _ in &mut self {}` is more clear, whereas `self.exhaust()` is clearer than both.
2018-04-16 13:21:56 +00:00
bors
d6a2dd9912 Auto merge of #49433 - varkor:metadata-skip-mir-opt, r=michaelwoerister
Skip MIR encoding for cargo check

Resolves #48662.

r? @michaelwoerister
2018-04-16 10:30:57 +00:00
bors
532764cb79 Auto merge of #49963 - llogiq:stabilize-13226, r=kennytm
stabilize fetch_nand

This closes #13226 and makes `Atomic*.fetch_nand` stable.
2018-04-16 07:44:25 +00:00
bors
3e70dfd655 Auto merge of #49956 - QuietMisdreavus:rustdoc-codegen, r=GuillaumeGomez
rustdoc: port the -C option from rustc

Blocked on https://github.com/rust-lang/rust/pull/49864. The included test won't work without those changes, so this PR includes those commits as well.

When documenting items that require certain target features, it helps to be able to force those target features into existence. Rather than include a flag just to parse those features, i instead decided to port the `-C` flag from rustc in its entirety. It takes the same parameters, because it runs through the same parsing function. This has the added benefit of being able to control the codegen of doctests as well.

One concern i have with the flag is that i set it to stable here. My rationale is that it is a direct port of functionality on rustc that is currently stable, used only in mechanisms that it is originally used for. If needed, i can set it back to be unstable.
2018-04-16 05:00:14 +00:00
bors
748c549185 Auto merge of #49847 - sinkuu:save_analysis_implicit_extern, r=petrochenkov
Fix save-analysis generation with extern_in_paths/extern_absolute_paths

Fixes #48742.
2018-04-16 02:34:32 +00:00
bors
d6ba1b9b02 Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov
Update `?` repetition disambiguation.

**Do not merge** (yet)

This is a test implementation of some ideas from discussion in https://github.com/rust-lang/rust/issues/48075 . This PR
- disallows `?` repetition from taking a separator, since the separator is never used.
- disallows the use of `?` as a separator. This allows patterns like `$(a)?+` to match `+` and `a+` rather than `a?a?a`. This is a _breaking change_, but maybe that's ok? Perhaps a crater run is the right approach?

cc @durka @alexreg @nikomatsakis
2018-04-16 00:06:10 +00:00
bors
8de5353f75 Auto merge of #49947 - oli-obk:turing_complete_const_eval, r=nagisa
Don't abort const eval due to long running evals, just warn

one check-box of #49930

r? @nagisa (https://github.com/rust-lang/rfcs/pull/2344#issuecomment-368246665)
2018-04-15 21:18:37 +00:00
Shotaro Yamada
c3dc014378 Check generated save-analysis, instead of bug!()ing
Injected crates don't have extern info. Let's skip them.
2018-04-15 21:41:28 +09:00
bors
7360d6dd67 Auto merge of #49833 - oli-obk:incremental_miri_regression, r=michaelwoerister
Don't recurse into allocations, use a global table instead

r? @michaelwoerister

fixes #49663
2018-04-15 12:32:13 +00:00
Oliver Schneider
907df8c0f7
Add a tracking issue for making the warning a lint 2018-04-15 13:28:15 +02:00
bors
602b3957f1 Auto merge of #49885 - spastorino:fn_ref_unsound, r=nikomatsakis
Fix unsoundness bug in functions input references

Fixes #48803

r? @nikomatsakis
2018-04-15 09:14:43 +00:00
bors
56109dbf70 Auto merge of #49884 - alexcrichton:less-unwrap, r=Mark-Simulacrum
core: Remove panics from some `Layout` methods

`Layout` is often used at the core of allocation APIs and is as a result pretty
sensitive to codegen in various circumstances. I was profiling `-C opt-level=z`
with a wasm project recently and noticed that the `unwrap()` wasn't removed
inside of `Layout`, causing the program to be much larger than it otherwise
would be. If inlining were more aggressive LLVM would have figured out that the
panic could be eliminated, but in general the methods here can't panic in the
first place!

As a result this commit makes the following tweaks:

* Removes `unwrap()` and replaces it with `unsafe` in `Layout::new` and
  `Layout::for_value`. For posterity though a debug assertion was left behind.
* Removes an `unwrap()` in favor of `?` in the `repeat` method. The comment
  indicating that the function call couldn't panic wasn't quite right in that if
  `alloc_size` becomes too large and if `align` is high enough it could indeed
  cause a panic.

This'll hopefully mean that panics never get introduced into code in the first
place, ensuring that `opt-level=z` is closer to `opt-level=s` in this regard.
2018-04-15 06:33:48 +00:00
bors
bc001fa07f Auto merge of #49881 - varkor:partialord-opt, r=Manishearth
Fix derive(PartialOrd) and optimise final field operation

```rust
// Before (`lt` on 2-field struct)
self.f1 < other.f1 || (!(other.f1 < self.f1) &&
(self.f2 < other.f2 || (!(other.f2 < self.f2) &&
(false)
))
)

// After
self.f1 < other.f1 || (!(other.f1 < self.f1) &&
self.f2 < other.f2
)

// Before (`le` on 2-field struct)
self.f1 < other.f1 || (!(other.f1 < self.f1) &&
(self.f2 < other.f2 || (!(other.f2 < self.f2) &&
(true)
))
)

// After
self.f1 < other.f1 || (self.f1 == other.f1 &&
self.f2 <= other.f2
)
```

(The big diff is mainly because of a past faulty rustfmt application that I corrected 😒)

Fixes #49650 and fixes #49505.
2018-04-15 03:54:15 +00:00
bors
d4d43e2483 Auto merge of #48173 - GuillaumeGomez:error-codes-libsyntax_ext, r=estebank
Add error codes for libsyntax_ext

I intend to add error codes for `libsyntax_ext` as well. However, they cannot be used at stage 0 directly so I thought it might be possible to enable them at the stage 1 only so we can have access to the macros. However, the error code registration seems to not work this way. Currently I get the following error:

```
error: used diagnostic code E0660 not registered
  --> libsyntax_ext/asm.rs:93:25
   |
93 |                         span_err!(cx, sp, E0660, "malformed inline assembly");
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: used diagnostic code E0661 not registered
   --> libsyntax_ext/asm.rs:151:33
    |
151 | /                                 span_err!(cx, sp, E0661,
152 | |                                           "output operand constraint lacks '=' or '+'");
    | |________________________________________________________________________________________^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

error: Could not compile `syntax_ext`.
```

If anyone has an idea, I'd gladly take it. I'm trying to figure this out on my side as well. I also opened this PR to know if it was worth it to continue (maybe we don't want this?).

Anyway, any answer for both questions is very welcome!

cc @rust-lang/compiler
2018-04-15 01:26:11 +00:00
bors
bd40cbbe1f Auto merge of #49850 - alexcrichton:moreinline, r=sfackler
core: Inline `From<AllocErr> for CollectionAllocErr`

This shows up in allocations of vectors and such, so no need for it to not be
inlined!
2018-04-14 20:22:19 +00:00
Guillaume Gomez
f367567e06 ignore stage1 testing 2018-04-14 18:04:16 +02:00
Guillaume Gomez
5d52ef5091 Add tests and longer error explanation 2018-04-14 17:25:35 +02:00
Guillaume Gomez
44c686113f Add error codes for libsyntax_ext 2018-04-14 17:25:35 +02:00
Andre Bogus
c68c90a232 stabilize fetch_nand 2018-04-14 15:51:31 +02:00
bors
21dae950be Auto merge of #49939 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

Successful merges: #49908, #49876, #49916, #49951, #49465, #49922, #49866, #49915, #49886, #49913, #49852, #49958, #49871, #49864

Failed merges:
2018-04-14 13:11:24 +00:00
kennytm
0e9d6f9bb0
Rollup merge of #49864 - QuietMisdreavus:doctest-target-features, r=GuillaumeGomez
add target features when extracting and running doctests

When rendering documentation, rustdoc will happily load target features into the cfg environment from the current target, but fails to do this when doing anything with doctests. This would lead to situations where, thanks to https://github.com/rust-lang/rust/pull/48759, functions tagged with `#[target_feature]` couldn't run doctests, thanks to the automatic `#[doc(cfg(target_feature = "..."))]`.

Currently, there's no way to pass codegen options to rustdoc that will affect its rustc sessions, but for now this will let you use target features that come default on the platform you're targeting.

Fixes https://github.com/rust-lang/rust/issues/49723
2018-04-14 18:50:41 +08:00
kennytm
709ec4010d
Rollup merge of #49871 - SimonSapin:int-bytes, r=sfackler
Add to_bytes and from_bytes to primitive integers

Discussion issue turned tracking issue: https://github.com/rust-lang/rust/issues/49792
2018-04-14 18:49:58 +08:00
kennytm
9659f052a4
Rollup merge of #49958 - glandium:cleanup, r=SimonSapin
Cleanup liballoc use statements

Some modules were still using the deprecated `allocator` module, use the
`alloc` module instead.

Some modules were using `super` while it's not needed.

Some modules were more or less ordering them, and other not, so the
latter have been modified to match the others.
2018-04-14 18:48:09 +08:00
Simon Sapin
447299130a Add to_bytes and from_bytes to primitive integers 2018-04-14 12:31:22 +02:00
bors
cfc3465b9d Auto merge of #49289 - varkor:emit-metadata-without-link, r=michaelwoerister
Make --emit=metadata output metadata regardless of link

Fixes #40109. I'm not sure whether this condition was important here or not, but I can't see why it is required (removing it doesn't cause the error the comment warns about, so I'm assuming it's safe). If this is too heavy-handed, I can special-case on `OutputType::Metadata`.

r? @nrc
2018-04-14 10:27:03 +00:00
Oliver Schneider
7f7d4c376a
Get rid of redundant HashSet 2018-04-14 12:22:10 +02:00
Oliver Schneider
748e71e8f4
Reduce the number of calls to cdata 2018-04-14 12:21:46 +02:00
Oliver Schneider
04b3ab67d9
Encode items before encoding the list of AllocIds 2018-04-14 12:21:46 +02:00
Oliver Schneider
6f251c2a03
Use LazySeq instead of Vec 2018-04-14 12:21:46 +02:00
Oliver Schneider
62c0501be8
Stop referring to statics' AllocIds directly 2018-04-14 12:21:46 +02:00
Oliver Schneider
a67ded06a3
Don't recurse into allocations, use a global table instead 2018-04-14 12:21:46 +02:00
Mike Hommey
e35499ca15 Replace remaining uses of deprecated Heap with Global 2018-04-14 16:48:27 +09:00
Mike Hommey
4c8e9b9751 Replace remaining uses of deprecated std::heap with std::alloc 2018-04-14 16:47:38 +09:00
kennytm
e681ba22d2
Rollup merge of #49922 - f-bro:zmiri, r=oli-obk
Remove -Zmiri debugging option
2018-04-14 15:23:37 +08:00
kennytm
31906e4f8c
Rollup merge of #49916 - llogiq:doc-atomic-fetch-update, r=kennytm
improve Atomic*::fetch_update docs

This clarifies that fetch_update *always* returns the previous value, either as `Ok(_)` or `Err(_)`, depending on whether the supplied update function returned `Some(_)` or `None`.
2018-04-14 15:23:21 +08:00
kennytm
d21433eeae
Rollup merge of #49915 - llogiq:doc-shift-types, r=joshtriplett
[doc] note the special type inference handling for shift ops

This adds a note to the docs about the difference between the shift ops and the corresponding trait methods when it comes to type inference.
2018-04-14 15:23:08 +08:00
kennytm
6f629d3654
Rollup merge of #49913 - varkor:RegionParameterDef-InternedString, r=petrochenkov
Use InternedString rather than Name for RegionParameterDef

This makes it consistent with `TypeParameterDef`.
2018-04-14 15:22:57 +08:00
kennytm
44a71e2e61
Rollup merge of #49908 - chrisccoulson:fix-rustdoc-themes-test-without-rpath, r=Mark-Simulacrum
Fix test failure in src/tools/rustdoc-themes when rust.rpath = false

See https://github.com/rust-lang/rust/issues/49907
2018-04-14 15:22:39 +08:00
kennytm
070a7719bb
Rollup merge of #49886 - varkor:generate-deriving-span-tests-usability, r=nikomatsakis
Ignore copyright year when generating deriving span tests

Previously, generate-deriving-span-tests.py would regenerate all the tests anew, even if they hadn't changed. This creates unnecessary diffs that only change the copyright year. Now we check to see if any of the content of the test has changed before generating the new one.
2018-04-14 15:22:27 +08:00
kennytm
15eb465b35
Rollup merge of #49465 - ollie27:rustbuild_test_docs, r=steveklabnik,QuietMisdreavus,frewsxcv,GuillaumeGomez
Add docs for the test crate with the std docs

If the compiler docs aren't going to include the test crate then it may as well be included with std.

Fixes #49388
2018-04-14 15:22:17 +08:00
kennytm
c22b4db0f5
Rollup merge of #49876 - oli-obk:no_secret_clippy_on_stable_☹, r=nrc
Don't inject clippy into rls on stable/beta

as discussed at the all-hands
2018-04-14 15:22:06 +08:00
kennytm
642bcc488b
Rollup merge of #49866 - Mark-Simulacrum:pr-travis-windows, r=alexcrichton
Cross-compile builder to Windows for PRs on Travis

I chose a completely arbitrary windows target here (I have no idea what's best, we could do multiple -- they are relatively fast).
2018-04-14 15:21:39 +08:00
kennytm
95b7e6fe92
Rollup merge of #49852 - alexcrichton:fix-more-proc-macros, r=nrc
proc_macro: Avoid cached TokenStream more often

This commit adds even more pessimization to use the cached `TokenStream` inside
of an AST node. As a reminder the `proc_macro` API requires taking an arbitrary
AST node and transforming it back into a `TokenStream` to hand off to a
procedural macro. Such functionality isn't actually implemented in rustc today,
so the way `proc_macro` works today is that it stringifies an AST node and then
reparses for a list of tokens.

This strategy unfortunately loses all span information, so we try to avoid it
whenever possible. Implemented in #43230 some AST nodes have a `TokenStream`
cache representing the tokens they were originally parsed from. This
`TokenStream` cache, however, has turned out to not always reflect the current
state of the item when it's being tokenized. For example `#[cfg]` processing or
macro expansion could modify the state of an item. Consequently we've seen a
number of bugs (#48644 and #49846) related to using this stale cache.

This commit tweaks the usage of the cached `TokenStream` to compare it to our
lossy stringification of the token stream. If the tokens that make up the cache
and the stringified token stream are the same then we return the cached version
(which has correct span information). If they differ, however, then we will
return the stringified version as the cache has been invalidated and we just
haven't figured that out.

Closes #48644
Closes #49846
2018-04-14 15:21:19 +08:00
kennytm
fbbc9907b1
Rollup merge of #49951 - matklad:update-cargo, r=nrc
Update Cargo

This includes https://github.com/rust-lang/cargo/pull/5353, which we  want to test via opt-in in the wild.

This'll break RLS, the fix is https://github.com/rust-lang-nursery/rls/pull/822
2018-04-14 15:21:10 +08:00
bors
fb730d75d4 Auto merge of #49396 - Zoxc:sync-on-disk-cache, r=michaelwoerister
Make OnDiskCache thread-safer

I'm not sure if `synthetic_expansion_infos` is handled correctly.

`interpret_alloc_cache` and `interpret_alloc_size` seems to be wrong though, since the code may now decode two `AllocId`s in parallel. I'd like some input on how to fix that.

cc @oli-obk

r? @michaelwoerister
2018-04-14 06:32:20 +00:00
bors
410e895bd5 Auto merge of #49957 - nrc:update, r=simulacrum
Update Rustfmt

Should fix broken RLS/nightlies

r? @alexcrichton
2018-04-14 03:51:44 +00:00
Nick Cameron
eb1b502d02 Update Rustfmt 2018-04-14 13:33:28 +12:00
bors
5724462f62 Auto merge of #49326 - petrochenkov:nteq, r=eddyb
macros: Remove matching on "complex" nonterminals requiring AST comparisons

So, you can actually use nonterminals from outer macros in left hand side of nested macros and invocations of nested macros will try to match passed arguments to them.

```rust
macro outer($nt_item: item) {
    macro inner($nt_item) {
        struct S;
    }

    inner!($nt_item); // OK, `$nt_item` matches `$nt_item`
}
```

Why this is bad:
- We can't do this matching correctly. When two nonterminals are compared, the original tokens are lost and we have to compare AST fragments instead. Right now the comparison is done by `PartialEq` impls derived on AST structures.
    - On one hand, AST loses information compared to original tokens (e.g. trailing separators and other simplifications done during parsing to AST), so we can produce matches that are not actually correct.
    - On another hand derived `PartialEq` impls for AST structures don't make much sense in general and compare various auxiliary garbage like spans. For the argument nonterminal to match we should use literally the same token (possibly cloned) as was used in the macro LHS (as in the example above). So we can reject matches that are actually correct.
    - Support for nonterminal matching is the only thing that forces us to derive `PartialEq` for all (!) AST structures. As I mentioned these impls are also mostly nonsensical.

This PR removes support for matching on all nonterminals except for "simple" ones like `ident`, `lifetime` and `tt` for which we have original tokens that can be compared.
After this is done I'll submit another PR removing huge number of `PartialEq` impls from AST and HIR structures.

This is an arcane feature and I don't personally know why would anyone use it, but the change should ideally go through crater.
We'll be able to support this feature again in the future when all nonterminals have original token streams attached to them in addition to (or instead of) AST fragments.
2018-04-14 01:28:13 +00:00