Commit Graph

119875 Commits

Author SHA1 Message Date
bors
3fe4dd2dda Auto merge of #71953 - oli-obk:const_prop_deaggregates, r=wesleywiser
Const prop aggregates even if partially or fully modified

r? @wesleywiser

cc @rust-lang/wg-mir-opt I'm moderately scared of this change, but I'm confident in having reviewed all the cases.
2020-05-11 07:23:31 +00:00
bors
aeb473803d Auto merge of #71825 - contrun:cg-option-strip, r=petrochenkov
add codegen option strip

closes https://github.com/rust-lang/rust/issues/71757

I don't know if the flags added here works for all linkers. I only tested on my Linux pc. I also don't know what is the best for emlinker, PtxLinker, MsvcLinker. The option for WasmLd is copied from https://aransentin.github.io/cwasm/.
2020-05-10 20:48:40 +00:00
bors
9912925c25 Auto merge of #72074 - RalfJung:rollup-1ns58no, r=RalfJung
Rollup of 4 pull requests

Successful merges:

 - #71840 (Rework MIR drop tree lowering)
 - #71882 (Update the `cc` crate)
 - #71945 (Sort "implementations on foreign types" section in the sidebar)
 - #72043 (Add missing backtick in E0569 explanation)

Failed merges:

r? @ghost
2020-05-10 12:07:34 +00:00
Ralf Jung
f2b655f110
Rollup merge of #72043 - GuillaumeGomez:clean-up-e0569, r=Dylan-DPC
Add missing backtick in E0569 explanation

r? @Dylan-DPC
2020-05-10 11:34:36 +02:00
Ralf Jung
d22c18b396
Rollup merge of #71945 - GuillaumeGomez:sort-impl-on-foreign-types-section, r=kinnison,ollie27
Sort "implementations on foreign types" section in the sidebar

Fixes #71926.

We were sorting by the ID instead of sorting by the name. They're not in the same order as the implementations but I think it makes more sense this way considering this is what we do for the methods as well.

r? @kinnison

cc @rust-lang/rustdoc
2020-05-10 11:34:34 +02:00
Ralf Jung
37a9192826
Rollup merge of #71882 - alexcrichton:update-cc, r=Mark-Simulacrum
Update the `cc` crate

Pulls in updated MSVC detection logic landed in alexcrichton/cc-rs#488
2020-05-10 11:34:32 +02:00
Ralf Jung
62353071af
Rollup merge of #71840 - matthewjasper:drop-trees, r=oli-obk
Rework MIR drop tree lowering

This PR changes how drops are generated in MIR construction. This is the first half of the fix for #47949.

Rather than generating the drops for a given unwind/break/continue/return/generator drop path as soon as they are needed, the required drops are recorded and get generated later.

The motivation for this is
* It simplifies the caching scheme, because it's now possible to walk up the currently scheduled drop tree to recover state.
* The basic block order for MIR more closely resembles execution order.

This PR also:
* Highlights cleanup blocks in the graphviz MIR output.
* Removes some unnecessary drop flag assignments.
2020-05-10 11:34:30 +02:00
YI
a6c2f73b6e add linking option strip
move strip option to "Z"

add more strip options, remove strip-debuginfo-if-disabled

merge strip and debuginfo
2020-05-10 16:44:46 +08:00
bors
8d16eeb8c9 Auto merge of #71775 - petrochenkov:crtcfg, r=matthewjasper
Enable `cfg` predicate for `target_feature = "crt-static"` only if the target supports it

That's what all other `target_feature`s do.
2020-05-10 08:25:32 +00:00
bors
b3269536d0 Auto merge of #72020 - alexcrichton:fix-incremental-linker-plugin-lto, r=oli-obk
Fix disagreeement about CGU reuse and LTO

This commit fixes an issue where the codegen backend's selection of LTO
disagreed with what the codegen later thought was being done. Discovered
in #72006 we have a longstanding issue where if `-Clinker-plugin-lto` in
optimized mode is compiled incrementally it will always panic on the
second compilation. The underlying issue turned out to be that the
production of the original artifact determined that LTO should not be
done (because it's being postponed to the linker) but the CGU reuse
selection thought that LTO was done so it was trying to load pre-LTO
artifacts which were never generated.

The fix here is to ensure that the logic when generating code which
determines what kind of LTO is being done is shared amongst the CGU
reuse decision and the backend actually doing LTO. This means that
they'll both be in agreement about whether the previous compilation did
indeed produce incremental pre-LTO artifacts.

Closes #72006
2020-05-10 04:41:01 +00:00
Alex Crichton
c7bd5a635e Fix disagreeement about CGU reuse and LTO
This commit fixes an issue where the codegen backend's selection of LTO
disagreed with what the codegen later thought was being done. Discovered
in #72006 we have a longstanding issue where if `-Clinker-plugin-lto` in
optimized mode is compiled incrementally it will always panic on the
second compilation. The underlying issue turned out to be that the
production of the original artifact determined that LTO should not be
done (because it's being postponed to the linker) but the CGU reuse
selection thought that LTO was done so it was trying to load pre-LTO
artifacts which were never generated.

The fix here is to ensure that the logic when generating code which
determines what kind of LTO is being done is shared amongst the CGU
reuse decision and the backend actually doing LTO. This means that
they'll both be in agreement about whether the previous compilation did
indeed produce incremental pre-LTO artifacts.

Closes #72006
2020-05-09 19:30:48 -07:00
bors
6f5c7827b7 Auto merge of #71557 - matthewjasper:mir-asymmetric-or-pattern, r=oli-obk
Fix ICE for broken or-pattern in async fn

closes #71297
2020-05-10 01:12:21 +00:00
bors
0a3619c9e5 Auto merge of #69530 - Aaron1011:perf/skip-coerce-var, r=nikomatsakis
[perf] Skip attempting to run coerce_unsized on an inference variable

See the included comment for a detailed explanation of why this is
sound.
2020-05-09 21:01:19 +00:00
bors
bad3bf622b Auto merge of #72041 - RalfJung:rollup-xivrvy2, r=RalfJung
Rollup of 5 pull requests

Successful merges:

 - #69406 (upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir)
 - #71185 (Move tests from `test/run-fail` to UI)
 - #71234 (rustllvm: Use .init_array rather than .ctors)
 - #71508 (Simplify the `tcx.alloc_map` API)
 - #71555 (Remove ast::{Ident, Name} reexports.)

Failed merges:

r? @ghost
2020-05-09 17:31:08 +00:00
Guillaume Gomez
e0c0c3b96f Add missing backtick in E0569 explanation 2020-05-09 13:51:46 +02:00
Guillaume Gomez
b865db0462 Sort "implementations on foreign types" section in the sidebar 2020-05-09 13:50:24 +02:00
Ralf Jung
366c1786e6
Rollup merge of #71555 - cjgillot:nameless, r=matthewjasper
Remove ast::{Ident, Name} reexports.

The reexport of `Symbol` into `Name` confused me.
2020-05-09 13:36:39 +02:00
Ralf Jung
8c0310d18c
Rollup merge of #71508 - oli-obk:alloc_map_unlock, r=RalfJung
Simplify the `tcx.alloc_map` API

This PR changes all functions that require manually locking the `alloc_map` to functions on `TyCtxt` that lock the map internally. In the same step we make the `TyCtxt::alloc_map` field private.

r? @RalfJung
2020-05-09 13:36:37 +02:00
Ralf Jung
ce05553c62
Rollup merge of #71234 - maurer:init-array, r=cuviper
rustllvm: Use .init_array rather than .ctors

LLVM TargetMachines default to using the (now-legacy) .ctors
representation of init functions. Mixing .ctors and .init_array
representations can cause issues when linking with lld.

This happens in practice for:

* Our profiling runtime which is currently implicitly built with
  .init_array since it is built by clang, which sets this field.
* External C/C++ code that may be linked into the same process.

Fixes: #71233
2020-05-09 13:36:32 +02:00
Ralf Jung
1704dca270
Rollup merge of #71185 - JohnTitor:run-fail, r=petrochenkov
Move tests from `test/run-fail` to UI

Fixes #65440
cc #65865 #65506
r? @nikomatsakis
2020-05-09 13:36:30 +02:00
Ralf Jung
2420b42ac6
Rollup merge of #69406 - jackh726:chalk-upgrade, r=nikomatsakis
upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir

Reintegrate chalk into rustc.

r? @nikomatsakis
cc. @rust-lang/wg-traits
2020-05-09 13:36:29 +02:00
Matthew Jasper
b998497bd4 Address review comments 2020-05-09 10:51:39 +01:00
Matthew Jasper
a030c92341 Bless mir-opt tests 2020-05-09 10:51:39 +01:00
Matthew Jasper
1a19c1da73 Add some more comments 2020-05-09 10:51:38 +01:00
bors
7c59a81a5f Auto merge of #72030 - matthiaskrgr:submodule_upd, r=Mark-Simulacrum
submodules: update cargo from f534844c2 to cb06cb269

Changes:
````
more clippy fixes
Document that bench is unstable in the man page.
Update assertions in LTO calculations
Updated comments in resolve.rs to reflect actual data strcture used.
Try to remove secrets from http.debug.
Revert always computing filename Metadata.
clean -p: call `get_many` once.
Implement new `clean -p` using globs.
Rework how Cargo computes the rustc file outputs.
Add CrateType to replace LibKind.
````

I'd like to get the fix for https://github.com/rust-lang/cargo/issues/8223 into nightly asap.

r? @ehuss
2020-05-09 09:50:58 +00:00
Matthew Jasper
54aa418a60 Reduce the number of drop-flag assignments in unwind paths 2020-05-09 10:50:55 +01:00
Matthew Jasper
611988551f Defer creating drop trees in MIR lowering until leaving that scope 2020-05-09 10:50:55 +01:00
bors
34d6b446e5 Auto merge of #71994 - jyn514:path-independent, r=Mark-Simulacrum
x.py: allow configuring the build directory

This allows configuring the directory for build artifacts, instead of having it always be `./build`. This means you can set it to a constant location, letting you reuse the same cache while working in several different directories.

The configuration lives in `config.toml` under `build.build-dir`. By default, it keeps the existing default of `./build`, but it can be configured to any relative or absolute path. Additionally, it allows making outputs relative to the root of the git repository using `$ROOT`.

r? @Mark-Simulacrum
2020-05-09 06:26:57 +00:00
bors
945d110e05 Auto merge of #72036 - Dylan-DPC:rollup-ca8b0ql, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #70834 (Add core::future::{pending,ready})
 - #71839 (Make BTreeMap::new and BTreeSet::new const)
 - #71890 (Simplify the error Registry methods a little)
 - #71942 (Shrink `LocalDecl`)
 - #71947 (Dead-code pass highlights too much of impl functions)
 - #71981 (Fix `strip-priv-imports` pass name in the rustdoc documentation)
 - #72018 (Fix canonicalization links)
 - #72031 (Better documentation for io::Read::read() return value)

Failed merges:

r? @ghost
2020-05-09 03:07:54 +00:00
Dylan DPC
4b337d2bf6
Rollup merge of #72031 - Elinvynia:master, r=Mark-Simulacrum
Better documentation for io::Read::read() return value

Aims to provide the clarity requested in #70360
2020-05-09 03:10:16 +02:00
Dylan DPC
46d97c21cf
Rollup merge of #72018 - mark-i-m:canon-chalk, r=mark-i-m
Fix canonicalization links
2020-05-09 03:10:14 +02:00
Dylan DPC
b86b626b02
Rollup merge of #71981 - DarkEld3r:patch-1, r=ollie27
Fix `strip-priv-imports` pass name in the rustdoc documentation
2020-05-09 03:10:12 +02:00
Dylan DPC
966589edfc
Rollup merge of #71947 - mibac138:dead-code, r=cramertj
Dead-code pass highlights too much of impl functions

Fixes #66627.
Previous diagnostic:
```
error: method is never used: `unused_impl_fn_3`
  --> src/main.rs:28:5
   |
28 | /     fn unused_impl_fn_3(
29 | |         var: i32,
30 | |     ) {
31 | |         println!("bar {}", var);
32 | |     }
   | |_____^
```
New diagnostic:
```
error: associated function is never used: `unused_impl_fn_3`
  --> $DIR/lint-dead-code-6.rs:13:8
   |
LL |     fn unused_impl_fn_3(
   |        ^^^^^^^^^^^^^^^^
```

This makes associated functions in line with free-standing functions.
2020-05-09 03:10:11 +02:00
Dylan DPC
2b3a114633
Rollup merge of #71942 - nnethercote:shrink-LocalDecl, r=matthewjasper
Shrink `LocalDecl`

`LocalDecl` contributes 4-8% of peak heap memory usage on a range of benchmarks. This PR reduces its size from 128 bytes to 56 bytes on 64-bit, and does some clean-ups as well.

r? @matthewjasper
2020-05-09 03:10:09 +02:00
Dylan DPC
d16d02b011
Rollup merge of #71890 - cuviper:simple-error-Registry, r=cramertj
Simplify the error Registry methods a little
2020-05-09 03:10:07 +02:00
Dylan DPC
f16c27f1c4
Rollup merge of #71839 - LG3696:master, r=cramertj
Make BTreeMap::new and BTreeSet::new const
2020-05-09 03:10:05 +02:00
Dylan DPC
62374ee4ad
Rollup merge of #70834 - yoshuawuyts:future-pending-ready, r=sfackler
Add core::future::{pending,ready}

Adds two future constructors to `core`: `future::ready` and `future::pending`. These functions enable constructing futures of any type that either immediately resolve, or never resolve which is an incredible useful tool when writing documentation.

These functions have prior art in both the `futures` and `async-std` crates. This implementation has been adapted from the `futures` crate.

## Examples

In https://github.com/rust-lang/rust/pull/70817 we propose adding the `ready!` macro. In the example we use an `async fn` which does not return a future that implements `Unpin`, which leads to the use of `unsafe`. Instead had we had `future::ready` available, we could've written the same example without using `unsafe`:

```rust
use core::task::{Context, Poll};
use core::future::{self, Future};
use core::pin::Pin;

pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> {
    let mut fut = future::ready(42_u8);
    let num = ready!(Pin::new(fut).poll(cx));
    // ... use num

    Poll::Ready(())
}
```

## Why future::ready?

Arguably `future::ready` and `async {}` can be considered equivalent. The main differences are that `future::ready` returns a future that implements `Unpin`, and the returned future is a concrete type. This is useful for traits that require a future as an associated type that can sometimes be a no-op ([example](https://docs.rs/http-service/0.4.0/http_service/trait.HttpService.html#associatedtype.ConnectionFuture)).

The final, minor argument is that `future::ready` and `future::pending` form a counterpart to the enum members of `Poll`: `Ready` and `Pending`. These functions form a conceptual bridge between `Poll` and `Future`, and can be used as a useful teaching device.

## References
- [`futures::future::ready`](https://docs.rs/futures/0.3.4/futures/future/fn.ready.html)
- [`futures::future::pending`](https://docs.rs/futures/0.3.4/futures/future/fn.pending.html)
- [`async_std::future::pending`](https://docs.rs/async-std/1.5.0/async_std/future/fn.pending.html)
- [`async_std::future::ready`](https://docs.rs/async-std/1.5.0/async_std/future/fn.ready.html)
2020-05-09 03:10:01 +02:00
Joshua Nelson
df36ec0b7e x.py: allow configuring the build directory
This allows configuring the directory for build artifacts, instead of having it always be ./build. This means you can set it to a constant location, letting you reuse the same cache while working in several different directories.

The configuration lives in config.toml under build.build-dir. By default, it keeps the existing default of ./build, but it can be configured to any relative or absolute path. Additionally, it allows making outputs relative to the root of the git repository using $ROOT.
2020-05-08 20:33:50 -04:00
bors
0f9088f961 Auto merge of #71418 - hbina:rename_miri_undef, r=RalfJung
Renamed "undef" -> "uninit"

1. InvalidUndefBytes -> InvalidUninitBytes
2. ScalarMaybeUndef -> ScalarMaybeUninit
3. UndefMask -> InitMask

Related issue #71193
2020-05-08 23:45:57 +00:00
Elinvynia
05fc7faacb Better documentation for io::Read::read() return value 2020-05-09 01:17:20 +02:00
Matthias Krüger
737338e2a5 submodules: update cargo from f534844c2 to cb06cb269
Changes:
````
more clippy fixes
Document that bench is unstable in the man page.
Update assertions in LTO calculations
Updated comments in resolve.rs to reflect actual data strcture used.
Try to remove secrets from http.debug.
Revert always computing filename Metadata.
clean -p: call `get_many` once.
Implement new `clean -p` using globs.
Rework how Cargo computes the rustc file outputs.
Add CrateType to replace LibKind.
````
2020-05-09 00:47:00 +02:00
bors
7ebd87a7a1 Auto merge of #72021 - Dylan-DPC:rollup-1w61ihk, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #71581 (Unify lints handling in rustdoc)
 - #71710 (Test for zero-sized function items not ICEing)
 - #71970 (Improve bitcode generation for Apple platforms)
 - #71975 (Reduce `TypedArena` creations in `check_match`.)
 - #72003 (allow wasm target for rustc-ap-rustc_span)
 - #72017 (Work around ICEs during cross-compilation for target, ast, & attr)

Failed merges:

r? @ghost
2020-05-08 20:03:23 +00:00
Oliver Scherer
b07a44d5c4 Document global_alloc 2020-05-08 21:59:17 +02:00
Dylan DPC
827ec49c23
Rollup merge of #72017 - ctaggart:wasm2, r=ecstatic-morse
Work around ICEs during cross-compilation for target, ast, & attr

This applies the fix for #72003 to work around #56935 to three more libraries. With these additional fixes, I'm able to use rustfmt_lib from wasm (https://github.com/rust-lang/rustfmt/issues/4132#issuecomment-616587989), which was my goal.

To get it working locally and to test, I copied the `.cargo/registry/src` and applied the fix and replaced the reference in my project:
``` toml
[replace]
"rustc-ap-rustc_span:656.0.0" = { path = "../rustc-ap-rustc_span" }
"rustc-ap-rustc_target:656.0.0" = { path = "../rustc-ap-rustc_target" }
"rustc-ap-rustc_ast:656.0.0" = { path = "../rustc-ap-rustc_ast" }
"rustc-ap-rustc_attr:656.0.0" = { path = "../rustc-ap-rustc_attr" }
```
2020-05-08 18:48:33 +02:00
Dylan DPC
b750ee4964
Rollup merge of #72003 - ctaggart:wasm, r=jonas-schievink
allow wasm target for rustc-ap-rustc_span

This fixes #71998 by applying the work-a-round. The root cause is probably #56935, as @petrochenkov pointed out.

I reproduced the bug by:
```
cd ~/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_span-657.0.0/
cargo build --target wasm32-unknown-unknown
```

Adding this line fixes it.
2020-05-08 18:48:31 +02:00
Dylan DPC
0c8ef4772a
Rollup merge of #71975 - nnethercote:reduce-TypedArena-creations-in-check_match, r=oli-obk
Reduce `TypedArena` creations in `check_match`.

`check_match` creates a new `TypedArena` for every call to
`create_and_enter`. DHAT tells me that each `TypedArena` typically is
barely used, with typically a single allocation per arena.

This commit moves the `TypedArena` creation outwards a bit, into
`check_match`, and then passes it into `create_and_enter`. This reduces
the number of arenas created by about 4-5x, for a very small perf win.
(Moving the arena creation further outwards is hard because
`check_match` is a query.)

r? @oli-obk
2020-05-08 18:48:29 +02:00
Dylan DPC
e3a4ff0d76
Rollup merge of #71970 - thombles:ios-bitcode-improvements, r=alexcrichton
Improve bitcode generation for Apple platforms

Some improvements for iOS bitcode support suggested by Alex over at https://github.com/getditto/rust-bitcode/issues/9. r? @alexcrichton

This improves Rust's bitcode generation so that provided you have a compatible LLVM version, Rust targeting iOS should work out of the box when compiled into bitcode-enabled apps, and when submitted to the App Store. I've tested these changes using Xcode 11.4.1 and Apple's vendored LLVM, [tag `swift-5.2.3-RELEASE`](https://github.com/apple/llvm-project/releases/tag/swift-5.2.3-RELEASE).

1. Force `aarch64-apple-ios` and `aarch64-apple-tvos` targets to always emit full bitcode sections, even when cargo is trying to optimise by invoking `rustc` with `-Cembed-bitcode=no`. Since Apple recommends bitcode on iOS and requires it on tvOS it is likely that this is what developers intend. Currently you need to override the codegen options with `RUSTFLAGS`, which is far from obvious.
2. Provide an LLVM cmdline in the target spec. Apple's bitcode verification process looks for some arguments. For Rust modules to be accepted we must pretend they were produced similarly. A suitable default is provided in `TargetOptions` for iOS, copied directly from the a clang equivalent section.

In the context of Apple platforms, the predominant purpose of bitcode is App Store submissions, so simulator and 32-bit targets are not relevant. I'm hoping that the cmdline strings will not be a maintenance burden to keep up-to-date. If the event of any future incompatibilities, hopefully a custom target config would offer enough flexibility to work around it. It's impossible to say for sure.

Due to unrelated build errors I haven't been able to build and test a full tvOS toolchain. I've stopped short of providing a similar `bitcode_llvm_cmdline` until I can actually test it.
2020-05-08 18:48:28 +02:00
Dylan DPC
a9eb01ae03
Rollup merge of #71710 - workingjubilee:jubilee-readd-test, r=nikomatsakis
Test for zero-sized function items not ICEing

Closes #30276.
Again.
Please give rustcake with no icing!
2020-05-08 18:48:23 +02:00
Dylan DPC
807e8b80dc
Rollup merge of #71581 - GuillaumeGomez:unify-lints-handling, r=kinnison
Unify lints handling in rustdoc

This is a small cleanup. The goal is to unify a bit things to make the reading simpler.

r? @kinnison

cc @rust-lang/rustdoc
2020-05-08 18:48:19 +02:00
mark
9dabea1a29 fix canonicalization links 2020-05-08 11:06:25 -05:00