96537 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
e1de70b045
Rollup merge of #62735 - petrochenkov:galloc, r=alexcrichton
Turn `#[global_allocator]` into a regular attribute macro

It was a 99% macro with exception of some diagnostic details.

As a result of the change, `#[global_allocator]` now works in nested modules and even in nameless blocks.

Fixes https://github.com/rust-lang/rust/issues/44113
Fixes https://github.com/rust-lang/rust/issues/58072
2019-07-25 23:21:00 +02:00
Mazdak Farrokhzad
6f0e57fb1d
Rollup merge of #62707 - JohnTitor:add-test-for-61922, r=tmandry
Add tests for overlapping explicitly dropped locals in generators

Closes #62686

r? @tmandry
2019-07-25 23:20:58 +02:00
Mazdak Farrokhzad
008d9d0fea
Rollup merge of #62528 - SimonSapin:concat, r=alexcrichton
Add joining slices of slices with a slice separator, not just a single item

https://github.com/rust-lang/rust/issues/27747#issuecomment-294525391
> It's kinda annoying to be able to join strings with a str (which can have multiple chars), but joining a slice of slices, you can only join with a single element.

This turns out to be fixable, with some possible inference regressions.

# TL;DR

Related trait(s) are unstable and tracked at https://github.com/rust-lang/rust/issues/27747, but the `[T]::join` method that is being extended here is already stable.

Example use of the new insta-stable functionality:

```rust
let nested: Vec<Vec<Foo>> = /* … */;
let separator: &[Foo] = /* … */;  // Previously: could only be a single &Foo
nested.join(separator)
```

Complete API affected by this PR, after changes:

```rust
impl<T> [T] {
    pub fn concat<Item: ?Sized>(&self) -> <Self as Concat<Item>>::Output
        where Self: Concat<Item>
    {
        Concat::concat(self)
    }
    pub fn join<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
        where Self: Join<Separator>
    {
        Join::join(self, sep)
    }
}

// The `Item` parameter is only useful for the the slice-of-slices impl.
pub trait Concat<Item: ?Sized> {
    type Output;
    fn concat(slice: &Self) -> Self::Output;
}

pub trait Join<Separator> {
    type Output;
    fn join(slice: &Self, sep: Separator) -> Self::Output;
}

impl<T: Clone, V: Borrow<[T]>> Concat<T> for [V] {
    type Output = Vec<T>;
}

impl<T: Clone, V: Borrow<[T]>> Join<&'_ T> for [V] {
    type Output = Vec<T>;
}

// New functionality here!
impl<T: Clone, V: Borrow<[T]>> Join<&'_ [T]> for [V] {
    type Output = Vec<T>;
}

impl<S: Borrow<str>> Concat<str> for [S] {
    type Output = String;
}

impl<S: Borrow<str>> Join<&'_ str> for [S] {
    type Output = String;
}
```

# Details

After https://github.com/rust-lang/rust/pull/62403 but before this PR, the API is:

```rust
impl<T> [T] {
    pub fn concat<Separator: ?Sized>(&self) -> T::Output
        where T: SliceConcat<Separator>
    {
        SliceConcat::concat(self)
    }

    pub fn join<Separator: ?Sized>(&self, sep: &Separator) -> T::Output
        where T: SliceConcat<Separator>
    {
        SliceConcat::join(self, sep)
    }
}

pub trait SliceConcat<Separator: ?Sized>: Sized {
    type Output;
    fn concat(slice: &[Self]) -> Self::Output;
    fn join(slice: &[Self], sep: &Separator) -> Self::Output;
}

impl<T: Clone, V: Borrow<[T]>> SliceConcat<T> for V {
    type Output = Vec<T>;
}

impl<S: Borrow<str>> SliceConcat<str> for S {
    type Output = String;
}
```

By adding a trait impl we should be able to accept a slice of `T` as the separator, as an alternative to a single `T` value.

In a `some_slice.join(some_separator)` call, trait resolution will pick an impl or the other based on the type of `some_separator`. In `some_slice.concat()` however there is no separator, so this call would become ambiguous. Some regression in type inference or trait resolution may be acceptable on principle, but requiring a turbofish for every single call to `concat` isn’t great.

The solution to that is splitting the `SliceConcat` trait into two `Concat` and `Join` traits, one for each eponymous method. Only `Join` would gain a new impl, so that `some_slice.concat()` would not become ambiguous.

Now, at the trait level the `Concat` trait does not need a `Separator` parameter anymore. However, simply removing it causes one of the impls not to be accepted anymore:

```rust
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
  --> src/liballoc/slice.rs:608:6
    |
608 | impl<T: Clone, V: Borrow<[T]>> Concat for [V] {
    |      ^ unconstrained type parameter
```

This makes sense: if `[V]::concat` is a method that is itself not generic, then its return type (which is the `Concat::Output` associated type) needs to be determined based on solely `V`. And although there is no such type in the standard library, there is nothing stopping another crate from defining a `V` type that implements both `Borrow<[Foo]>` and `Borrow<[Bar]>`. It might not be a good idea, but it’s possible. Both would apply here, and there would be no way to determine `T`.

This could be a warning sign that this API is too generic. Perhaps we’d be better off having one less type variable, and only implement `Concat for [&'_ [T]]` and `Concat for [Vec<T>]` etc. However this aspect of `[V]::concat` is already stable, so we’re stuck with it.

The solution is to keep a dummy type parameter on the `Concat` trait. That way, if a type has multiple `Borrow<[_]>` impls, it’ll end up with multiple corresponding `Concat<_>` impls.

In `impl<S: Borrow<str>> Concat<str> for [S]`, the second occurrence of `str` is not meaningful. It could be any type. As long as there is only once such type with an applicable impl, trait resolution will be appeased without demanding turbofishes.

# Joining strings with `char`

For symmetry I also tried adding this impl (because why not):

```rust
impl<S: Borrow<str>> Join<char> for [S] {
    type Output = String;
}
```

This immediately caused an inference regression in a dependency of rustc:

```rust
error[E0277]: the trait bound `std::string::String: std::borrow::Borrow<[std::string::String]>` is not satisfied
   --> /home/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/getopts-0.2.19/src/lib.rs:595:37
    |
595 |             row.push_str(&desc_rows.join(&desc_sep));
    |                                     ^^^^ the trait `std::borrow::Borrow<[std::string::String]>` is not implemented for `std::string::String`
    |
    = help: the following implementations were found:
              <std::string::String as std::borrow::Borrow<str>>
    = note: required because of the requirements on the impl of `std::slice::Join<&std::string::String>` for `[std::string::String]`
```

In the context of this code, two facts are known:

* `desc_rows` is a `Vec<String>`
* `desc_sep` is a `String`

Previously the first fact alone reduces the resolution of `join` to only one solution, where its argument it expected to be `&str`. Then, `&String` is coerced to `&str`.

With the new `Join` impl, the first fact leavs two applicable impls where the separator can be either `&str` or `char`. But `&String` is neither of these things. It appears that possible coercions are not accounted for, in the search for a solution in trait resolution.

I have not included this new impl in this PR. It’s still possible to add later, but the `getopts` breakage does not need to block the rest of the PR. And the functionality easy for end-user to duplicate: `slice_of_strings.join(&*char_separator.encode_utf8(&mut [0_u8, 4]))`

The `&*` part of that last code snippet is another case of the same issue: `encode_utf8` returns `&mut str` which can be coerced to `&str`, but isn’t when trait resolution is ambiguous.
2019-07-25 23:20:56 +02:00
Mazdak Farrokhzad
dbd0028dcc
Rollup merge of #61890 - golddranks:fix_sanity_check_llvm, r=Dylan-DPC
Fix some sanity checks

Update: Changes that made it not to work dropped.

* Fix `building_llvm` in sanity check
  * This was subtly broken: we build LLVM if any of the hosts builds LLVM, and not setting the config meant that LLVM is built for that target. Because of filtering away the targets not configured and the semantics of `Iterator::any`, it currently didn't set the `building_llvm` flag even if we indeed build it.
* Add `swig` sanity check
  * This checks whether there is a `swig` executable needed for LLDB.
2019-07-25 23:20:54 +02:00
Mazdak Farrokhzad
a57c4f6297
Rollup merge of #61884 - crlf0710:stablize_euc, r=dtolnay,Centril
Stablize Euclidean Modulo (feature euclidean_division)

Closes #49048
2019-07-25 23:20:53 +02:00
Mazdak Farrokhzad
845e146d04
Rollup merge of #60938 - jonas-schievink:doc-include-paths, r=petrochenkov
rustdoc: make #[doc(include)] relative to the containing file

This matches the behavior of other in-source paths like `#[path]` and the `include_X!` macros.

Fixes https://github.com/rust-lang/rust/pull/58373#issuecomment-462349380
Also addresses https://github.com/rust-lang/rust/issues/44732#issuecomment-467660239

cc #44732

This is still missing a stdsimd change (42ed30e0b5), so CI will currently fail. I'll land that change once I get initial feedback for this PR.
2019-07-25 23:20:51 +02:00
Mazdak Farrokhzad
3b19dc96fc
Rollup merge of #60066 - sfackler:type-name, r=Centril
Stabilize the type_name intrinsic in core::any

Stabilize `type_name` in `core::any`.

Closes rust-lang/rfcs#1428

FCP completed over there.

`RELEASES.md`: Prefer T-libs for categorization.
2019-07-25 23:20:49 +02:00
bors
eedf6ce4ef Auto merge of #62944 - RalfJung:miri, r=oli-obk
bump Miri

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

r? @oli-obk
2019-07-25 06:14:48 +00:00
Steven Fackler
91fa898975 Stabilize the type_name intrinsic in core::any
Closes rust-lang/rfcs#1428
2019-07-24 21:35:49 -07:00
bors
185b9acb66 Auto merge of #62961 - Centril:rollup-kydeswa, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #61727 (Add binary dependencies to dep-info files)
 - #62736 (Polonius: fix some cases of `killed` fact generation, and most of the `ui` test suite)
 - #62758 (ci: Install clang on Windows through tarballs)
 - #62784 (Add riscv32i-unknown-none-elf target)
 - #62814 (add support for hexagon-unknown-linux-musl)
 - #62827 (Don't link mcjit/interpreter LLVM components)
 - #62901 (cleanup: Remove `extern crate serialize as rustc_serialize`s)
 - #62903 (Support SDKROOT env var on iOS)
 - #62906 (Require a value for configure --debuginfo-level)

Failed merges:

 - #62910 (cleanup: Remove lint annotations in specific crates that are already enforced by rustbuild)

r? @ghost
2019-07-25 02:04:55 +00:00
Mazdak Farrokhzad
0340d72bf5
Rollup merge of #62906 - cuviper:debuginfo-level, r=Mark-Simulacrum
Require a value for configure --debuginfo-level

In `configure.py`, using the `o` function creates an enable/disable
boolean setting, and writes `true` or `false` in `config.toml`. However,
rustbuild is expecting to parse a `u32` debuginfo level. We can change
to the `v` function to have the options require a value.
2019-07-25 01:05:07 +02:00
Mazdak Farrokhzad
6e1ed3a116
Rollup merge of #62903 - swolchok:ios-sdkroot, r=alexcrichton
Support SDKROOT env var on iOS

Following what clang does (296a80102a/clang/lib/Driver/ToolChains/Darwin.cpp (L1661-L1678)), allow allow SDKROOT to tell us where the Apple SDK lives so we don't have to invoke xcrun.

Replaces #62551.
2019-07-25 01:05:05 +02:00
Mazdak Farrokhzad
5a7db0e19a
Rollup merge of #62901 - petrochenkov:serde, r=Centril
cleanup: Remove `extern crate serialize as rustc_serialize`s
2019-07-25 01:05:03 +02:00
Mazdak Farrokhzad
e5590425e9
Rollup merge of #62827 - nikic:llvm-components, r=alexcrichton
Don't link mcjit/interpreter LLVM components

We don't use these. Drop related unused ExecutionEngine header uses.

As some drive-by cleanup drop the unused `EnableARMEHABI` global and remove an outdated version check for the hexagon component.

r? @alexcrichton
2019-07-25 01:05:02 +02:00
Mazdak Farrokhzad
b1a866012d
Rollup merge of #62814 - androm3da:hexagon_19jul_2019, r=alexcrichton
add support for hexagon-unknown-linux-musl
2019-07-25 01:05:00 +02:00
Mazdak Farrokhzad
8d9000d38c
Rollup merge of #62784 - Disasm:riscv32i, r=estebank
Add riscv32i-unknown-none-elf target

This target is likely to be useful for constrained FPGA soft-cores, such as picorv32 and HeavyX.
2019-07-25 01:04:59 +02:00
Mazdak Farrokhzad
5ef2162fb1
Rollup merge of #62758 - alexcrichton:llvm-tarball-windows, r=pietroalbini
ci: Install clang on Windows through tarballs

Previously we used the executables built the LLVM project but these
executables are difficult to run in a CI environment, they can
accidentally pollute global state, etc. In testing some of the possible
4-core machine environments for Azure this step would frequently cause
issues.

To assuage these future issues and hopefully make builds slightly more
self-contained, this commit changes to install from a tarball instead.
The tarball isn't provided by LLVM itself, but we use the offical LLVM
installer to extract itself and then we pack up the LLVM installation
directory into the tarball.
2019-07-25 01:04:57 +02:00
Mazdak Farrokhzad
a676a36662
Rollup merge of #62736 - lqd:polonius_tests3, r=matthewjasper
Polonius: fix some cases of `killed` fact generation, and most of the `ui` test suite

Since basic Polonius functionality was re-enabled by @matthewjasper in #54468, some tests were still failing in the polonius compare-mode.

This PR fixes all but one test in the `ui` suite by:
- fixing some bugs in the fact generation code, related to the `killed` relation: Polonius would incorrectly reject some NLL-accepted code, because of these missing `killed` facts.
- ignoring some tests in the polonius compare-mode: a lot of those manually test the NLL or migrate mode, and the failures were mostly artifacts of the test revisions, e.g. that `-Z polonius` requires full NLLs. Some others were also both failing with NLL and succeeding with Polonius, which we can't encode in tests at the moment.
- blessing the output of some tests: whenever Polonius and NLL have basically the same errors, except for diagnostics differences, the Polonius output is blessed. Whenever we've advanced into a less experimental phase, we'll want to revisit these cases (much like we did on the NLL test suite last year) to specifically work on diagnostics.

Fact generation changes:
- we now kill loans on the destination place of `Call` terminators
- we now kill loans on the locals destroyed by `StorageDead`
- we now also handle assignments to projections: killing the loans on a either a deref-ed local, or the ones whose `borrowed_place` conflicts with the current place.

One failing test remains: an overflow during fact generation, on a case of polymorphic recursion (and which I'll continue investigating later).

This adds some tests for the fact generation changes, with some simple Polonius cases similar to the existing smoke tests, but also for some cases encountered in the wild (in the `rand` crate for example).

A more detailed write-up is available [here](https://hackmd.io/CjYB0fs4Q9CweyeTdKWyEg?view) with an explanation for each test failure, the steps taken to resolve it (as a commit in the current PR), NLL and Polonius outputs (and diff), etc.

Since they've worked on this before, and we've discussed some of these failures together:

r? @matthewjasper
2019-07-25 01:04:55 +02:00
Mazdak Farrokhzad
40be4000b9
Rollup merge of #61727 - Mark-Simulacrum:crate-deps-in-deps, r=alexcrichton
Add binary dependencies to dep-info files

I'm not sure about the lack of incremental-tracking here, but since I'm pretty sure this runs on every compile anyway it might not matter? If there's a better place/way to get at the information I want, I'm happy to refactor the code to match.

r? @alexcrichton
2019-07-25 01:04:54 +02:00
Yuki Okushi
404281125e Use Foo instead of raw arrays 2019-07-25 07:47:57 +09:00
Ralf Jung
f2900b0b41 re-enable debug checks in Miri 2019-07-24 20:47:24 +02:00
Ralf Jung
01512616d1 bump Miri 2019-07-24 20:18:15 +02:00
Scott Wolchok
287db19e9a Add comment 2019-07-24 10:28:14 -07:00
bors
03f19f7ff1 Auto merge of #62935 - Centril:rollup-hzj9att, r=Centril
Rollup of 10 pull requests

Successful merges:

 - #62641 (Regenerate character tables for Unicode 12.1)
 - #62716 (state also in the intro that UnsafeCell has no effect on &mut)
 - #62738 (Remove uses of mem::uninitialized from std::sys::cloudabi)
 - #62772 (Suggest trait bound on type parameter when it is unconstrained)
 - #62890 (Normalize use of backticks in compiler messages for libsyntax/*)
 - #62905 (Normalize use of backticks in compiler messages for doc)
 - #62916 (Add test `self-in-enum-definition`)
 - #62917 (Always emit trailing slash error)
 - #62926 (Fix typo in mem::uninitialized doc)
 - #62927 (use PanicMessage in MIR, kill InterpError::description)

Failed merges:

r? @ghost
2019-07-24 15:59:00 +00:00
Mark Rousskov
d749b5e223 Gate binary dependency information behind -Zbinary-dep-depinfo 2019-07-24 11:00:09 -04:00
Mark Rousskov
eafb42dc94 Add binary dependencies to dep-info files 2019-07-24 10:49:22 -04:00
Mazdak Farrokhzad
e27927d2ff
Rollup merge of #62927 - RalfJung:panic, r=oli-obk
use PanicMessage in MIR, kill InterpError::description

r? @oli-obk @eddyb
Cc @saleemjaffer https://github.com/rust-rfcs/const-eval/issues/4
2019-07-24 16:13:23 +02:00
Mazdak Farrokhzad
0466237555
Rollup merge of #62926 - Smibu:fix-typo, r=jonas-schievink
Fix typo in mem::uninitialized doc
2019-07-24 16:13:22 +02:00
Mazdak Farrokhzad
c44e29bb59
Rollup merge of #62917 - estebank:trailing-slash, r=matklad
Always emit trailing slash error

Fix #62913.

r? @petrochenkov
2019-07-24 16:13:20 +02:00
Mazdak Farrokhzad
92aff0a982
Rollup merge of #62916 - Centril:self-in-enum-def, r=oli-obk
Add test `self-in-enum-definition`

Apparently there was no test covering this...

r? @oli-obk
cc @petrochenkov
2019-07-24 16:13:18 +02:00
Mazdak Farrokhzad
52247b2383
Rollup merge of #62905 - fakenine:normalize_use_of_backticks_compiler_messages_p16, r=Centril
Normalize use of backticks in compiler messages for doc

https://github.com/rust-lang/rust/issues/60532
2019-07-24 16:13:17 +02:00
Mazdak Farrokhzad
5c8dfd589c
Rollup merge of #62890 - fakenine:normalize_use_of_backticks_compiler_messages_p15, r=Centril
Normalize use of backticks in compiler messages for libsyntax/*

https://github.com/rust-lang/rust/issues/60532
2019-07-24 16:13:15 +02:00
Mazdak Farrokhzad
e933f54793
Rollup merge of #62772 - estebank:trait-bound, r=matthewjasper
Suggest trait bound on type parameter when it is unconstrained

Given

```
trait Foo { fn method(&self) {} }

fn call_method<T>(x: &T) {
    x.method()
}
```

suggest constraining `T` with `Foo`.

Fix #21673, fix #41030.
2019-07-24 16:13:14 +02:00
Mazdak Farrokhzad
efdcce1955
Rollup merge of #62738 - nathanwhit:fix_mem_uninit_cloudabi, r=RalfJung
Remove uses of mem::uninitialized from std::sys::cloudabi

Addresses #62397 for std::sys::cloudabi, excluding the tests within cloudabi, which will be a separate PR
2019-07-24 16:13:12 +02:00
Mazdak Farrokhzad
a7d993961f
Rollup merge of #62716 - RalfJung:unsafe-cell, r=Centril
state also in the intro that UnsafeCell has no effect on &mut

Just to be extra sure.
2019-07-24 16:13:09 +02:00
Mazdak Farrokhzad
21caaba2bc
Rollup merge of #62641 - cuviper:unicode-12.1, r=matklad
Regenerate character tables for Unicode 12.1
2019-07-24 16:13:07 +02:00
bors
27a6a304e2 Auto merge of #62908 - fakenine:normalize_use_of_backticks_compiler_messages_p17, r=alexreg
normalize use of backticks for compiler messages in remaining modules

https://github.com/rust-lang/rust/issues/60532
2019-07-24 10:03:20 +00:00
Ralf Jung
ff18786683
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-07-24 11:45:39 +02:00
Ralf Jung
18551e7d45 fix unused import 2019-07-24 11:43:59 +02:00
Mazdak Farrokhzad
7fdfe8b854 Refer to #50072 re. hack. 2019-07-24 11:37:09 +02:00
Vadim Petrochenkov
a0c2c640d5 Fix rebase 2019-07-24 12:29:45 +03:00
Vadim Petrochenkov
6e4f16173c Demote template check error to a lint for #[test] and #[bench] 2019-07-24 12:29:45 +03:00
Vadim Petrochenkov
bf8fc8adfc syntax_ext: Improve and simplify code generated by #[global_allocator]
Instead of
```
mod allocator_abi { /* methods */ }
```
we now generate
```
const _: () = { /* methods */ }
```
and use `std_path` for paths referring to standard library entities.

This way we no longer need to generate `use` and `extern crate` imports, and `#[global_allocator]` starts working inside unnamed blocks.
2019-07-24 12:29:45 +03:00
Vadim Petrochenkov
76b1ffaf6c syntax_ext: Reuse built-in attribute template checking for macro attributes 2019-07-24 12:29:45 +03:00
Vadim Petrochenkov
433024147a syntax_ext: Turn #[global_allocator] into a regular attribute macro 2019-07-24 12:29:44 +03:00
Vadim Petrochenkov
a93fdfedf3 Merge rustc_allocator into libsyntax_ext 2019-07-24 12:27:58 +03:00
Mika Lehtinen
a44f43e8b5 Fix typo in mem::uninitialized doc 2019-07-24 11:34:30 +03:00
Ralf Jung
495f9509fe use PanicMessage type for MIR assertion errors 2019-07-24 10:24:55 +02:00
Ralf Jung
3694d176a2 kill InterpError::description 2019-07-24 09:29:18 +02:00
Ralf Jung
c0420b1a59 do not use InterpError::description outside librustc::mir 2019-07-24 09:12:21 +02:00