Commit Graph

77114 Commits

Author SHA1 Message Date
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
Josh Stone
93734e9c46 Make debuginfo-tools always default false 2018-04-13 21:58:21 -07:00
Josh Stone
bc7403d067 Avoid specific claims about debuginfo size 2018-04-13 21:57:53 -07: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
csmoe
6f5a16bf1e fix error span 2018-04-14 11:04:39 +08: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
Josh Stone
cc2906cb26 rustbuild: allow building tools with debuginfo
Debugging information for the extended tools is currently disabled for
concerns about the size.  This patch adds `--enable-debuginfo-tools` to
let one opt into having that debuginfo.

This is useful for debugging the tools in distro packages.  We always
strip debuginfo into separate packages anyway, so the extra size is not
a concern in regular use.
2018-04-13 16:52:54 -07:00
Mike Hommey
bd9ff8476d 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 08:43:13 +09:00
Vadim Petrochenkov
7e1f73beb6 macros: Do not match on "complex" nonterminals requiring AST comparisons 2018-04-14 02:28:39 +03:00
bors
e7252f616c Auto merge of #49585 - GuillaumeGomez:rename-to-compile-pass, r=Mark-Simulacrum
Rename must-compile-successfully into compile-pass

Fixes #49568.

r? @Mark-Simulacrum
2018-04-13 22:11:06 +00:00
Guillaume Gomez
812656dc95 Rename must-compile-successfully into compile-pass 2018-04-13 23:28:03 +02:00
QuietMisdreavus
a5456bdd87 add -C to the rustdoc book 2018-04-13 16:21:27 -05:00
QuietMisdreavus
1a0d7a8207 add -C parameter to rustdoc 2018-04-13 16:07:12 -05:00
Aleksey Kladov
d0159453af Update RLS 2018-04-13 23:20:18 +03:00
bors
7291829268 Auto merge of #49830 - sinkuu:fix_ice_47715, r=cramertj
Fix ICE by disallowing `impl Trait` in unsupported position

Fixes #47715.
2018-04-13 19:22:14 +00:00
varkor
6234d4192a Use InternedString rather than Name for RegionParameterDef
This makes it consistent with TypeParameterDef.
2018-04-13 18:41:40 +01:00
Aleksey Kladov
6c7d3a1216 Update Cargo
This includes https://github.com/rust-lang/cargo/pull/5353,
which we might want to test via opt-in in the wild
2018-04-13 20:21:51 +03:00
Andre Bogus
b744e3d7f5 [doc] note the special type inference handling for shifts 2018-04-13 18:30:57 +02:00
bors
9c2bfcbea2 Auto merge of #49808 - spastorino:dump_cause_ice, r=nikomatsakis
[NLL] Fix ICE when a borrow wrapped in a temporary is used after dropped

Fixes #47646

r? @nikomatsakis
2018-04-13 16:06:14 +00:00
Oliver Schneider
4f6d118048
Don't abort const eval due to long running evals, just warn 2018-04-13 17:56:45 +02:00
Alex Crichton
46d16b66e0 std: Avoid allocating panic message unless needed
This commit removes allocation of the panic message in instances like
`panic!("foo: {}", "bar")` if we don't actually end up needing the message. We
don't need it in the case of wasm32 right now, and in general it's not needed
for panic=abort instances that use the default panic hook.

For now this commit only solves the wasm use case where with LTO the allocation
is entirely removed, but the panic=abort use case can be implemented at a later
date if needed.
2018-04-13 07:04:24 -07:00
Alex Crichton
2bb5b5c07c core: Remove an implicit panic from Formatter::pad
The expression `&s[..i]` in general can panic if `i` is out of bounds or not on
a character boundary for a string, and this caused the codegen for
`Formatter::pad` to be a bit larger than it otherwise needed to be. This commit
replaces this with `s.get(..i).unwrap_or(&s)` which while having different
behavior if `i` is out of bounds has a much smaller code footprint and otherwise
avoids the need for `unsafe` code.
2018-04-13 07:04:24 -07:00
Alex Crichton
66c5e3ffb2 Reduce the size of panics in RawVec
Create one canonical location which panics with "capacity overflow" instead of
having many. This reduces the size of a `panic!("{}", 1)` binary on wasm from
34k to 17k.
2018-04-13 07:04:23 -07:00
Alex Crichton
c3a5d6b130 std: Minimize size of panicking on wasm
This commit applies a few code size optimizations for the wasm target to
the standard library, namely around panics. We notably know that in most
configurations it's impossible for us to print anything in
wasm32-unknown-unknown so we can skip larger portions of panicking that
are otherwise simply informative. This allows us to get quite a nice
size reduction.

Finally we can also tweak where the allocation happens for the
`Box<Any>` that we panic with. By only allocating once unwinding starts
we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-13 07:03:00 -07:00
Alex Crichton
68e555b7d0 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-13 07:02:10 -07:00
Alex Crichton
2e73e76e73 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-13 07:00:03 -07:00
Oliver Middleton
abded6111b rustdoc: Don't include private paths in all.html 2018-04-13 14:58:43 +01:00
bors
b8f60f3fc4 Auto merge of #49800 - ishitatsuyuki:intern-goal, r=nikomatsakis
traits: Implement interning for Goal and Clause

r? @nikomatsakis

Close #49054

Contains some refactoring for the interning mechanism, mainly aimed at reducing pain when changing types of interning map.

This should be mostly good, although I'm not sure with the naming of `Goal::from_poly_domain_goal`.
2018-04-13 13:09:40 +00:00
bors
99d4886ead Auto merge of #49669 - SimonSapin:global-alloc, r=alexcrichton
Add GlobalAlloc trait + tweaks for initial stabilization

This is the outcome of discussion at the Rust All Hands in Berlin. The high-level goal is stabilizing sooner rather than later the ability to [change the global allocator](https://github.com/rust-lang/rust/issues/27389), as well as allocating memory without abusing `Vec::with_capacity` + `mem::forget`.

Since we’re not ready to settle every detail of the `Alloc` trait for the purpose of collections that are generic over the allocator type (for example the possibility of a separate trait for deallocation only, and what that would look like exactly), we propose introducing separately **a new `GlobalAlloc` trait**, for use with the `#[global_allocator]` attribute.

We also propose a number of changes to existing APIs. They are batched in this one PR in order to minimize disruption to Nightly users.

The plan for initial stabilization is detailed in the tracking issue https://github.com/rust-lang/rust/issues/49668.

CC @rust-lang/libs, @glandium

## Immediate breaking changes to unstable features

* For pointers to allocated memory, change the pointed type from `u8` to `Opaque`, a new public [extern type](https://github.com/rust-lang/rust/issues/43467). Since extern types are not `Sized`, `<*mut _>::offset` cannot be used without first casting to another pointer type. (We hope that extern types can also be stabilized soon.)
* In the `Alloc` trait, change these pointers to `ptr::NonNull` and change the `AllocErr` type to a zero-size struct. This makes return types `Result<ptr::NonNull<Opaque>, AllocErr>` be pointer-sized.
* Instead of a new `Layout`, `realloc` takes only a new size (in addition to the pointer and old `Layout`). Changing the alignment is not supported with `realloc`.
* Change the return type of `Layout::from_size_align` from `Option<Self>` to `Result<Self, LayoutErr>`, with `LayoutErr` a new opaque struct.
* A `static` item registered as the global allocator with the `#[global_allocator]` **must now implement the new `GlobalAlloc` trait** instead of `Alloc`.

## Eventually-breaking changes to unstable features, with a deprecation period

* Rename the respective `heap` modules to `alloc` in the `core`, `alloc`, and `std` crates. (Yes, this does mean that `::alloc::alloc::Alloc::alloc` is a valid path to a trait method if you have `exetrn crate alloc;`)
* Rename the the `Heap` type to `Global`, since it is the entry point for what’s registered with `#[global_allocator]`.

Old names remain available for now, as deprecated `pub use` reexports.

## Backward-compatible changes

* Add a new [extern type](https://github.com/rust-lang/rust/issues/43467) `Opaque`, for use in pointers to allocated memory.
* Add a new `GlobalAlloc` trait shown below. Unlike `Alloc`, it uses bare `*mut Opaque` without `NonNull` or `Result`. NULL in return values indicates an error (of unspecified nature). This is easier to implement on top of `malloc`-like APIs.
* Add impls of `GlobalAlloc` for both the `Global` and `System` types, in addition to existing impls of `Alloc`. This enables calling `GlobalAlloc` methods on the stable channel before `Alloc` is stable. Implementing two traits with identical method names can make some calls ambiguous, but most code is expected to have no more than one of the two traits in scope. Erroneous code like `use std::alloc::Global; #[global_allocator] static A: Global = Global;` (where `Global` is defined to call itself, causing infinite recursion) is not statically prevented by the type system, but we count on it being hard enough to do accidentally and easy enough to diagnose.

```rust
extern {
    pub type Opaque;
}

pub unsafe trait GlobalAlloc {
    unsafe fn alloc(&self, layout: Layout) -> *mut Opaque;
    unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout);

    unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut Opaque {
        // Default impl: self.alloc() and ptr::write_bytes()
    }
    unsafe fn realloc(&self, ptr: *mut Opaque, old_layout: Layout, new_size: usize) -> *mut Opaque {
        // Default impl: self.alloc() and ptr::copy_nonoverlapping() and self.dealloc()
    }

    fn oom(&self) -> ! {
        // intrinsics::abort
    }

    // More methods with default impls may be added in the future
}
```

## Bikeshed

The tracking issue https://github.com/rust-lang/rust/issues/49668 lists some open questions. If consensus is reached before this PR is merged, changes can be integrated.
2018-04-13 10:33:51 +00:00
Fabio B
35087fcb89 Remove -Z miri debugging option 2018-04-13 09:43:10 +02:00
bors
f9f9050f50 Auto merge of #49389 - fanzier:euclidean-division, r=KodrAus
Implement RFC #2169 (Euclidean modulo).

Tracking issue: #49048
2018-04-13 07:34:37 +00:00
bors
eec3208c4c Auto merge of #49360 - topecongiro:run-rustfmt/build_helper, r=nrc
Run rustfmt on build_helper

Using rustfmt 0.4.1-nightly (e784712f 2018-04-09).
2018-04-13 04:42:10 +00:00
bors
defcfe7142 Auto merge of #49718 - petrochenkov:fieldcmp, r=eddyb
Hygiene 2.0: Avoid comparing fields by name

There are two separate commits here (not counting tests):
- The first one unifies named (`obj.name`) and numeric (`obj.0`) field access expressions in AST and HIR. Before field references in these expressions are resolved it doesn't matter whether the field is named or numeric (it's just a symbol) and 99% of code is common. After field references are resolved we work with
them by index for all fields (see the second commit), so it's again not important whether the field was named or numeric (this includes MIR where all fields were already by index).
(This refactoring actually fixed some bugs in HIR-based borrow checker where borrows through names (`S {
0: ref x }`) and indices (`&s.0`) weren't considered overlapping.)
- The second commit removes all by-name field comparison and instead resolves field references to their indices  once, and then uses those resolutions. (There are still a few name comparisons in save-analysis, because save-analysis is weird, but they are made correctly hygienic).
Thus we are fixing a bunch of "secondary" field hygiene bugs (in borrow checker, lints).

Fixes https://github.com/rust-lang/rust/issues/46314
2018-04-13 01:43:09 +00:00
Shotaro Yamada
2c7e83f746 Move path_len to ExternCrate 2018-04-13 09:31:43 +09:00
bors
c4a03283cd Auto merge of #45298 - toidiu:ak-44493-infer-predicate, r=nikomatsakis
Ak 44493 infer predicate

 **WIP**  Implements #44493

Things to do:

- [x] add feature gate and appropriate tests (see [forge](https://forge.rust-lang.org/feature-guide.html) for some details)
- [x] add a unit testing system similar to `#[rustc_variance]`
  - [x] to see how, maybe `rg rustc_variance` and take some notes
- [ ] add more tests:
- [x] we need to decide how to handle `struct Foo<'a, T> { x: &'a T::Item }`
- [x] handle explicit predicates on types
- [ ] handle explicit predicates on `dyn Trait` (this could be put off to a follow-up PR)
- [ ] handle explicit predicates on projections (this could be put off to a follow-up PR)
2018-04-12 23:07:07 +00:00
Fabian Zaiser
ca4e458089 Address more nits. 2018-04-12 23:12:11 +02:00
Simon Sapin
c5ffdd787d Initial docs for the GlobalAlloc trait 2018-04-12 22:53:22 +02:00
Simon Sapin
f607a3872a Rename alloc::Void to alloc::Opaque 2018-04-12 22:53:22 +02:00
Simon Sapin
ed29777759 Remove conversions for allocated pointers
One was now unused, and `NonNull::new(…).ok_or(AllocErr)` feels short enough
for the few cases that need the other conversion.
2018-04-12 22:53:22 +02:00
Mike Hommey
fddf51ee0b Use NonNull<Void> instead of *mut u8 in the Alloc trait
Fixes #49608
2018-04-12 22:53:22 +02:00
Simon Sapin
fd242ee64c impl GlobalAlloc for Global 2018-04-12 22:53:22 +02:00
Simon Sapin
eae0d46893 Restore Global.oom() functionality
… now that #[global_allocator] does not define a symbol for it
2018-04-12 22:53:21 +02:00
Simon Sapin
96c9d225a9 Remove impl Alloc for &'a System
This was relevant to `#[global_allocator]`,
which is now based on `GlobalAlloc` trait instead.
2018-04-12 22:53:14 +02:00
Simon Sapin
c033f1ff5f Move platform-specific OOM handling to functions 2018-04-12 22:53:14 +02:00
Simon Sapin
747cc74943 Conversions between Result<*mut u8, AllocErr>> and *mut Void 2018-04-12 22:53:14 +02:00
Simon Sapin
c957e99b30 realloc with a new size only, not a full new layout.
Changing the alignment with realloc is not supported.
2018-04-12 22:53:13 +02:00
Simon Sapin
b017742136 Return Result instead of Option in alloc::Layout constructors 2018-04-12 22:53:13 +02:00
Simon Sapin
f9c96d70bd Add FIXME comments for Void::null_mut usage 2018-04-12 22:53:13 +02:00