Commit graph

125266 commits

Author SHA1 Message Date
Tyler Mandry
33fca5ab8a
Rollup merge of #75477 - RalfJung:fn-ptrs, r=Mark-Simulacrum
Expand function pointer docs

Be more explicit in the ABI section, and add a section on how to obtain a function pointer, which can be somewhat confusing.

Cc https://github.com/rust-lang/rust/issues/75239
2020-08-13 18:00:21 -07:00
Tyler Mandry
d000fb1ca8
Rollup merge of #75471 - richkadel:llvm-program-name, r=wesleywiser
Change registered "program name" for -Cllvm-args usage messages

While debugging a codegen issue, I tried adding LLVM options with
the rustc -Cllvm-args option, and was confused by the error and usage
messaging.

The LLVM "program name" argument is set to "rustc", and command line
error messages make it look like invalid arguments are "rustc"
arguments, not LLVM.

I changed this argument so error messages and the "-help" usage feedback
is easier to understand and react to. (Clang does something similar.)

r? @wesleywiser
2020-08-13 18:00:19 -07:00
Tyler Mandry
b4966a8936
Rollup merge of #75467 - rubenrua:rubenrua-patch-E0477, r=oli-obk
Fix E0741 error code explanation

Using `ok !` into fixed SRC like in other explanations.
2020-08-13 18:00:17 -07:00
Tyler Mandry
84f7991bf4
Rollup merge of #75462 - Mark-Simulacrum:clean-queries, r=petrochenkov
Remove unused tcx parameter

We shouldn't need access to a query context when storing already computed values.
2020-08-13 18:00:15 -07:00
Tyler Mandry
c76259a937
Rollup merge of #75459 - RalfJung:local-info, r=oli-obk
fix LocalInfo doc comment

The doc comment makes it sound like this is diagnostics-only, but that is not true -- even [unsafety checking uses this information](ded20c98be/src/librustc_mir/transform/check_unsafety.rs (L206)), so it is crucial for soundness, not just "nice to have".

Cc @oli-obk
2020-08-13 18:00:13 -07:00
Tyler Mandry
6f964f0a07
Rollup merge of #75452 - michaelwoerister:sp-cache-more-query-keys, r=lcnr
self-profile: Cache more query key strings when doing self-profiling.

This PR adds optimized `SpecIntoSelfProfilingString` implementations for two common query key types (`LocalDefId` and `WithOptConstParam`). This makes raw self-profiling data on disk 8-9% smaller for my two test cases (`regex` and `cargo`).

The on-disk format is not affected, so no tooling updates need to happen.

I also tried adding an impl for `Ty<'tcx>` (which should reduce size quite a bit) but the compiler did not allow me to add a specialized impl parameterized with `'tcx`. I don't know if there is an actual problem with that or if the implementation of specialization just doesn't support it yet.

cc @wesleywiser @Mark-Simulacrum
2020-08-13 18:00:11 -07:00
Tyler Mandry
1f73e898ee
Rollup merge of #75417 - npmccallum:naked, r=matthewjasper
Don't spill operands onto the stack in naked functions

Currently, the code spills operands onto the stack for the purpose of
debuginfo. However, naked functions can only contain an asm block. Therefore,
attempting to spill the operands on the stack is undefined behavior.

Fixes https://github.com/rust-lang/rust/issues/42779
cc https://github.com/rust-lang/rust/issues/32408

Note that this PR reverts https://github.com/rust-lang/rust/pull/74105 which ultimately didn't fix the problem.

cc @haraldh @Amanieu @matthewjasper
2020-08-13 18:00:10 -07:00
Tyler Mandry
8c361aa28d
Rollup merge of #75319 - estebank:format-ice, r=eddyb
Fix ICE #75307 in `format`

Remove usages of `unwrap` (even when some are safe today).

Fix #75307.
2020-08-13 18:00:08 -07:00
Tyler Mandry
5b5eec7256
Rollup merge of #74650 - estebank:ambiguous-expr-binop, r=eddyb
Correctly parse `{} && false` in tail expression

Fix #74233, fix #54186.
2020-08-13 18:00:00 -07:00
bors
81dc88f88f Auto merge of #75105 - ssomers:btree_respect_min_len_hard, r=Mark-Simulacrum
Hard way to respect BTreeMap's minimum node length

Resolves #74834 the hard way (though not the hardest imaginable).

Benchmarks (which are all biased/realistic, inserting keys in ascending order) say:
```
benchcmp r0 r1 --threshold 10
 name                                        r0 ns/iter  r1 ns/iter  diff ns/iter   diff %  speedup
 btree::map::clone_slim_100_and_clear        2,183       2,723                540   24.74%   x 0.80
 btree::map::clone_slim_100_and_drain_all    3,652       4,173                521   14.27%   x 0.88
 btree::map::clone_slim_100_and_drain_half   3,320       3,940                620   18.67%   x 0.84
 btree::map::clone_slim_100_and_into_iter    2,154       2,717                563   26.14%   x 0.79
 btree::map::clone_slim_100_and_pop_all      3,372       3,870                498   14.77%   x 0.87
 btree::map::clone_slim_100_and_remove_all   5,111       5,647                536   10.49%   x 0.91
 btree::map::clone_slim_100_and_remove_half  3,259       3,821                562   17.24%   x 0.85
 btree::map::iter_0                          1,733       1,509               -224  -12.93%   x 1.15
 btree::map::iter_100                        2,714       3,739              1,025   37.77%   x 0.73
 btree::map::iter_10k                        3,728       4,269                541   14.51%   x 0.87
 btree::map::range_unbounded_unbounded       28,426      36,631             8,205   28.86%   x 0.78
 btree::map::range_unbounded_vs_iter         28,808      34,056             5,248   18.22%   x 0.85
```
This difference is not caused by the `debug_assert`-related code in the function `splitpoint`, it's the same without.
2020-08-13 21:36:02 +00:00
bors
5e3f1b148d Auto merge of #75382 - JulianKnodt:match_branches, r=oli-obk
First iteration of simplify match branches

This is a simple MIR pass that attempts to convert
```
   bb0: {
        StorageLive(_2);
        _3 = discriminant(_1);
        switchInt(move _3) -> [0isize: bb2, otherwise: bb1];
    }

    bb1: {
        _2 = const false;
        goto -> bb3;
    }

    bb2: {
        _2 = const true;
        goto -> bb3;
    }
```
into
```
    bb0: {
        StorageLive(_2);
        _3 = discriminant(_1);
        _2 = _3 == 0;
        goto -> bb3;
    }
```
There are still missing components(like checking if the assignments are bools).
Was hoping that this could get some review though.

Handles #75141

r? @oli-obk
2020-08-13 19:26:35 +00:00
Ralf Jung
2338903260 fn type: structure, and talk a bit more about ABIs and how to create them 2020-08-13 20:18:00 +02:00
bors
b6396b75e7 Auto merge of #74793 - tmiasko:san-macos, r=Mark-Simulacrum
Link sanitizers when creating dynamic libraries on macOS

Link sanitizer runtime when creating dynamic libraries on macOS
to resolve sanitizer runtime symbols and avoid failure at link time.

Closes #74571.
2020-08-13 17:22:36 +00:00
bors
0a49057dd3 Auto merge of #75443 - lcnr:opaque-normalize, r=nikomatsakis
allow escaping bound vars when normalizing `ty::Opaque`

implements https://github.com/rust-lang/rust/issues/75313#issuecomment-672216146 and fixes #75313

cc @eddyb @RalfJung

r? @nikomatsakis
2020-08-13 15:03:40 +00:00
bors
a0c290f951 Auto merge of #75212 - JulianKnodt:array_map, r=LukasKalbertodt
Add `array` lang item and `[T; N]::map(f: FnMut(T) -> S)`

This introduces an `array` lang item so functions can be defined on top of `[T; N]`. This was previously not done because const-generics was not complete enough to allow for this. Now it is in a state that is usable enough to start adding functions.

The function added is a monadic (I think?) map from `[T; N] -> [S; N]`. Until transmute can function on arrays, it also allocates an extra temporary array, but this can be removed at some point.

r? @lcnr
2020-08-13 12:43:12 +00:00
Michael Woerister
08d951768f self-profile: Cache more query key strings when doing self-profiling. 2020-08-13 14:14:33 +02:00
bors
1a7d9f52bc Auto merge of #75322 - JulianKnodt:revisions, r=lcnr
Add a bunch of const-generic revisions for `min_const_generics`

This adds a bunch of revisions to `const-generic` tests which is part of #75279, but doesn't cover everything.

r? @lcnr
2020-08-13 10:31:57 +00:00
bors
3fbed1739c Auto merge of #75478 - RalfJung:miri, r=RalfJung
update miri

Fixes https://github.com/rust-lang/rust/issues/75441
2020-08-13 08:24:00 +00:00
kadmin
46e5699af9 Add 64bit / 32bit files 2020-08-13 08:20:26 +00:00
Tomasz Miąsko
4fbbc81e5f Link sanitizers when creating dynamic libraries on macOS 2020-08-13 09:45:55 +02:00
Ralf Jung
7e4456f92f update miri 2020-08-13 09:18:46 +02:00
kadmin
9ef5b884b2 bless diff
Just output the current bless'd MIR diff
The tests are still fairly broken rn
2020-08-13 06:59:57 +00:00
kadmin
f51422b474 Update to pick Eq or Ne 2020-08-13 06:59:57 +00:00
kadmin
bce5eb0c08 Update w/ comments from oli
This also updates a check to ensure that this is only applied to bools
2020-08-13 06:59:57 +00:00
kadmin
6c0f2a9446 Update to actually use transform 2020-08-13 06:59:57 +00:00
kadmin
a6c2cb42d0 First iteration of simplify match branches 2020-08-13 06:59:57 +00:00
bors
d69b0997d7 Auto merge of #75431 - ehuss:platform-support, r=Mark-Simulacrum
Move platform support to the rustc book.

This moves the [Platform Support](https://forge.rust-lang.org/release/platform-support.html) page from the forge to the rustc book. There are several reasons for doing this:

* The forge is not really oriented towards end-users (it mostly contains infrastructure, governance and policy, internal team pages, etc.). This platform support page is useful to user to know which targets are supported.
* This page can now be updated in-sync with any PRs that add or remove a target, or change its status.
* This is now automatically checked on CI to verify the list does not get out of sync. Currently it only checks the presence/absence of an entry, but more sophisticated checks could be added in the future.

I'm not 100% certain this is the best location, but I think it fits. I'd like to see the rustc guide continue to grow, including things like linking information and more platform-specific details.
2020-08-13 06:17:25 +00:00
bors
814bc4fe93 Auto merge of #75426 - ehuss:update-cargo, r=ehuss
Update cargo

7 commits in 1653f354644834073d6d2541e27fae94588e685e..ab32ee88dade1b50c77347599e82ca2de3fb8a51
2020-08-04 23:14:37 +0000 to 2020-08-10 17:44:43 +0000
- Build manpage archive deterministically (rust-lang/cargo#8600)
- doc: Qualify GNU licenses in example license field (rust-lang/cargo#8604)
- Fix jobserver_exists test on single-cpu systems (rust-lang/cargo#8598)
- Fix small typo in reference/profiles.md (rust-lang/cargo#8605)
- Default cargo publish to the alt registry if it's the only allowed one (rust-lang/cargo#8571)
- cargo install with specific yanked version gives confusing "not found" error (rust-lang/cargo#8565)
- Fix typo (rust-lang/cargo#8589)
2020-08-13 04:20:51 +00:00
kadmin
af32db21c8 Add drop check test & MaybeUninit::first_ptr_mut
Also in drop check test add hacky workaround for platforms that don't support
panic=unwind
2020-08-13 03:51:08 +00:00
kadmin
412417d807 Rm hiding feature gate & add 1 more example
Update order docs for `map`
2020-08-13 03:51:05 +00:00
kadmin
54b821ebc0 Add tracking issue #75243
Add note & example about iter order

Add doc changes

Update doc comments
2020-08-13 03:51:01 +00:00
kadmin
56a651ca15 Add recommend changes to array
Switch from indexing to zip, and also use `write` on `MaybeUninit`.

Add array_map feature to core/src/lib

Attempt to fix issue of no such feature

Update w/ pickfire's review

This changes a couple of names around, adds another small test of variable size,
and hides the rustdoc #![feature(..)].

Fmt doctest

Add suggestions from lcnr
2020-08-13 03:50:59 +00:00
kadmin
f6411e4c66 Add Array Impl Lang Item in various places
Add basic test

And also run fmt which is where the other changes are from

Fix mut issues

These only appear when running tests, so resolved by adding mut

Swap order of forget

Add pub and rm guard impl

Add explicit type to guard

Add safety note

Change guard type from T to S

It should never have been T, as it guards over [MaybeUninit<S>; N]
Also add feature to test
2020-08-13 03:50:57 +00:00
kadmin
d8718183b2 Create lang item array and add map fn
This creates the language item for arrays, and adds the map fn which is like map in options or
iterators. It currently allocates an extra array, unfortunately.

Added fixme for transmuting

Fix typo

Add drop guard
2020-08-13 03:50:54 +00:00
bors
9aa6cc025d Auto merge of #75476 - JohnTitor:rollup-ap1rqf1, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #75189 (Fix wasi::fs::OpenOptions to imply write when append is on)
 - #75201 (Fix some Clippy warnings in librustc_serialize)
 - #75372 (Fix suggestion to use lifetime in type and in assoc const)
 - #75400 (Fix minor things in the `f32` primitive docs)
 - #75449 (add regression test for #74739 (mir const-prop bug))
 - #75451 (Clean up E0751 explanation)
 - #75455 (Use explicit path link in place for doc in time)
 - #75457 (Remove some dead variants in LLVM FFI)
 - #75466 (Move to intra doc links whenever possible within std/src/lib.rs)
 - #75469 (Switch to intra-doc links in `std/io/mod.rs`)
 - #75473 (Flip order of const & type)

Failed merges:

r? @ghost
2020-08-13 02:26:20 +00:00
Yuki Okushi
76ac5d61e4
Rollup merge of #75473 - JulianKnodt:swap_order_oops, r=varkor
Flip order of const & type

Fix swapped order of consts & types in error message introduced in #74953

r? @varkor cc @lcnr
2020-08-13 11:05:48 +09:00
Yuki Okushi
5526c1a8cd
Rollup merge of #75469 - camelid:intra-doc-links-std-io-mod, r=KodrAus
Switch to intra-doc links in `std/io/mod.rs`

Part of #75080.
2020-08-13 11:05:47 +09:00
Yuki Okushi
e94f7437bd
Rollup merge of #75466 - poliorcetics:intra-links-std-lib, r=KodrAus
Move to intra doc links whenever possible within std/src/lib.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

There are some things like

```rust
`//! [`Option<T>`]: option::Option`
```

that will either be fixed in the future or have open issues about them.
2020-08-13 11:05:45 +09:00
Yuki Okushi
4cf55a67dd
Rollup merge of #75457 - Mark-Simulacrum:llvm-clean, r=cuviper
Remove some dead variants in LLVM FFI

r? @nikic or @cuviper
2020-08-13 11:05:44 +09:00
Yuki Okushi
9ea03ddd0b
Rollup merge of #75455 - pickfire:patch-3, r=jyn514
Use explicit path link in place for doc in time

r? @jyn514

More worth for your time. :P
2020-08-13 11:05:42 +09:00
Yuki Okushi
a62dd23c5c
Rollup merge of #75451 - GuillaumeGomez:cleanup-e0751, r=pickfire
Clean up E0751 explanation

r? @Dylan-DPC

cc @pickfire
2020-08-13 11:05:40 +09:00
Yuki Okushi
845fb94da4
Rollup merge of #75449 - RalfJung:const-prop-test, r=wesleywiser
add regression test for #74739 (mir const-prop bug)

Fixes https://github.com/rust-lang/rust/issues/74739
2020-08-13 11:05:38 +09:00
Yuki Okushi
66157e27e2
Rollup merge of #75400 - LukasKalbertodt:fix-f32-docs, r=KodrAus
Fix minor things in the `f32` primitive docs

All of these were review comments in #74621 that I first fixed in that PR, but later accidentally overwrote by a force push.

Thanks @the8472 for noticing.

r? @KodrAus
2020-08-13 11:05:37 +09:00
Yuki Okushi
d90a4b8ae9
Rollup merge of #75372 - estebank:lt-sugg-in-type, r=lcnr
Fix suggestion to use lifetime in type and in assoc const

_Do not merge until #75363 has landed, as it has the test case for this._

* Account for associated types
* Associated `const`s can't have generics (fix #74264)
* Do not suggest duplicate lifetimes and suggest `for<'a>` more (fix #72404)
2020-08-13 11:05:35 +09:00
Yuki Okushi
d0414b57b4
Rollup merge of #75201 - Hirrolot:hirrolot/fix-clippy-warnings, r=varkor
Fix some Clippy warnings in librustc_serialize
2020-08-13 11:05:33 +09:00
Yuki Okushi
ed543ae2f6
Rollup merge of #75189 - kawamuray:bugfix-wasi-append, r=KodrAus
Fix wasi::fs::OpenOptions to imply write when append is on

This PR fixes a bug in `OpenOptions` of `wasi` platform that it currently doesn't imply write mode when only `append` is enabled.
As explained in the [doc of OpenOptions#append](https://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.append), calling `.append(true)` should imply `.write(true)` as well.

## Reproduce

Given below simple Rust program:

```rust
use std::fs::OpenOptions;
use std::io::Write;

fn main() {
    let mut file = OpenOptions::new()
        .write(true)
        .create(true)
        .open("foo.txt")
        .unwrap();
    writeln!(file, "abc").unwrap();
}
```

it can successfully compiled into wasm and execute by `wasmtime` runtime:

```sh
$ rustc --target wasm32-wasi write.rs
$ ~/wasmtime/target/debug/wasmtime run --dir=. write.wasm
$ cat foo.txt
abc
```

However when I change `.write(true)` to `.append(true)`, it fails to execute by the error "Capabilities insufficient":

```sh
$ ~/wasmtime/target/debug/wasmtime run --dir=. append.wasm
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 76, kind: Other, message: "Capabilities insufficient" }', append.rs:10:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `append.wasm`
...
```

This is because of lacking "rights" on the opened file:

```sh
$ RUST_LOG=trace ~/wasmtime/target/debug/wasmtime run --dir=. append.wasm 2>&1 | grep validate_rights
 TRACE wasi_common::entry                                  >      | validate_rights failed: required rights = HandleRights { base: fd_write (0x40), inheriting: empty (0x0) }; actual rights = HandleRights { base: fd_seek|fd_fdstat_set_flags|fd_sync|fd_tell|fd_advise|fd_filestat_set_times|poll_fd_readwrite (0x88000bc), inheriting: empty (0x0) }
```
2020-08-13 11:05:31 +09:00
kadmin
c48d45bf6b Flip order of const & type 2020-08-12 23:19:07 +00:00
Rich Kadel
d4593af78f Change registered "program name" for -Cllvm-args usage messages
While debugging a codegen issue, I tried adding LLVM options with
the rustc -Cllvm-args option, and was confused by the error and usage
messaging.

The LLVM "program name" argument is set to "rustc", and command line
error messages make it look like invalid arguments are "rustc"
arguments, not LLVM.

I changed this argument so error messages and the "-help" usage feedback
is easier to understand and react to. (Clang does something similar.)
2020-08-12 16:11:17 -07:00
bors
847ba835ce Auto merge of #74512 - LukasKalbertodt:debloat-copy-from-slice, r=KodrAus
Put panic code path from `copy_from_slice` into cold function

The previous `assert_eq` generated quite some code, which is especially problematic when this call is inlined. This commit also slightly improves the panic message from:

    assertion failed: `(left == right)`
      left: `3`,
     right: `2`: destination and source slices have different lengths

...to:

    source slice length (2) does not match destination slice length (3)

You can see the code bloat in assembly [here](https://rust.godbolt.org/z/74a3qo).
2020-08-12 23:03:28 +00:00
Camelid
a7749fe451 Fix intra-doc link 2020-08-12 15:30:15 -07:00