]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoUse more efficient scheme for display u128/i128
kadmin [Fri, 28 Aug 2020 07:11:44 +0000 (07:11 +0000)]
Use more efficient scheme for display u128/i128

Add zero padding

Add benchmarks for fmt u128

This tests both when there is the max amount of work(all characters used)
And least amount of work(1 character used)

3 years agoAuto merge of #76899 - wesleywiser:experimental_unsound_mir_opts_flag, r=oli-obk
bors [Mon, 28 Sep 2020 15:32:27 +0000 (15:32 +0000)]
Auto merge of #76899 - wesleywiser:experimental_unsound_mir_opts_flag, r=oli-obk

[mir-opt] Introduce a new flag to enable experimental/unsound mir opts

This implements part of https://github.com/rust-lang/compiler-team/issues/319. The exact name of this flag was not decided as part of that MCP and some people expressed that it should include "unsound" in some way.

I've chosen to use `enable-experimental-unsound-mir-opts` as the name. While long, I don't think that matters too much as really it will only be used by some mir-opt tests. If you object or have a better name, please leave a comment!

r? `@oli-obk`
cc `@rust-lang/wg-mir-opt` `@RalfJung`

3 years agoAuto merge of #77236 - matthewjasper:defer-typeof-impl-trait, r=davidtwco
bors [Mon, 28 Sep 2020 12:47:23 +0000 (12:47 +0000)]
Auto merge of #77236 - matthewjasper:defer-typeof-impl-trait, r=davidtwco

Compute underlying type of impl trait types later in compilation

Also change a `bug!` to `delay_span_bug`
Closes #74018

3 years agoAuto merge of #77282 - glaubitz:sparc-linux, r=nagisa
bors [Mon, 28 Sep 2020 10:37:41 +0000 (10:37 +0000)]
Auto merge of #77282 - glaubitz:sparc-linux, r=nagisa

Add missing definitions required by the sparc-unknown-linux-gnu target

This PR adds a few missing definitions required by sparc-unknown-linux-target which were discovered during build tests.

3 years agoAuto merge of #77261 - oli-obk:const_generic_array_serializer, r=matthewjasper
bors [Mon, 28 Sep 2020 08:33:00 +0000 (08:33 +0000)]
Auto merge of #77261 - oli-obk:const_generic_array_serializer, r=matthewjasper

Deduplicate and generalize some (de/)serializer impls

I noticed this while implementing #77227 and getting a "not implemented for [T; 16]" error. There's likely more things we can deduplicate in this file, but I didn't need any additional changes.

3 years agoAuto merge of #77265 - vandenheuvel:chalkup, r=Dylan-DPC
bors [Mon, 28 Sep 2020 06:20:02 +0000 (06:20 +0000)]
Auto merge of #77265 - vandenheuvel:chalkup, r=Dylan-DPC

Update chalk to 0.29.0

3 years agoAuto merge of #77008 - fortanix:raoul/lvi-tests, r=Mark-Simulacrum
bors [Mon, 28 Sep 2020 03:28:04 +0000 (03:28 +0000)]
Auto merge of #77008 - fortanix:raoul/lvi-tests, r=Mark-Simulacrum

LVI hardening tests

Mitigating the speculative execution LVI attack against SGX enclaves requires compiler changes (i.e., adding lfences). This pull requests adds various tests to check if this happens correctly.

3 years agoAuto merge of #75295 - tmiasko:fds, r=Amanieu
bors [Mon, 28 Sep 2020 00:58:40 +0000 (00:58 +0000)]
Auto merge of #75295 - tmiasko:fds, r=Amanieu

Reopen standard file descriptors when they are missing on Unix

The syscalls returning a new file descriptors generally return lowest-numbered
file descriptor not currently opened, without any exceptions for those
corresponding to stdin, sdout, or stderr.

Previously when any of standard file descriptors has been closed before starting
the application, operations on std::io::{stderr,stdin,stdout} were likely to
either succeed while being performed on unrelated file descriptor, or fail with
EBADF which is silently ignored.

Avoid the issue by using /dev/null as a replacement when the standard file
descriptors are missing.

The implementation is based on the one found in musl. It was selected among a
few others on the basis of the lowest overhead in the case when all descriptors
are already present (measured on GNU/Linux).

Closes #57728.
Closes #46981.
Closes #60447.

Benefits:
* Makes applications robust in the absence of standard file descriptors.
* Upholds IntoRawFd / FromRawFd safety contract (which was broken previously).

Drawbacks:
* Additional syscall during startup.
* The standard descriptors might have been closed intentionally.
* Requires /dev/null.

Alternatives:
* Check if stdin, stdout, stderr are opened and provide no-op substitutes in std::io::{stdin,stdout,stderr} without reopening them directly.
* Leave the status quo, expect robust applications to reopen them manually.

3 years agoRemove unnecessary -Zunsound-mir-opts uses in tests
Wesley Wiser [Sat, 19 Sep 2020 13:58:13 +0000 (09:58 -0400)]
Remove unnecessary -Zunsound-mir-opts uses in tests

3 years ago[mir-opt] Introduce a new flag to enable experimental/unsound mir opts
Wesley Wiser [Sat, 19 Sep 2020 00:14:27 +0000 (20:14 -0400)]
[mir-opt] Introduce a new flag to enable experimental/unsound mir opts

3 years agolibrary/std: Set OS raw type definitions for sparc-unknown-linux-gnu
John Paul Adrian Glaubitz [Sun, 27 Sep 2020 22:14:59 +0000 (00:14 +0200)]
library/std: Set OS raw type definitions for sparc-unknown-linux-gnu

3 years agolibrary/std/sys_common: Define MIN_ALIGN for sparc-unknown-linux-gnu
John Paul Adrian Glaubitz [Sun, 27 Sep 2020 22:08:42 +0000 (00:08 +0200)]
library/std/sys_common: Define MIN_ALIGN for sparc-unknown-linux-gnu

3 years agolibrary/{panic_,}unwind: Add definitions for sparc-unknow-linux-gnu
John Paul Adrian Glaubitz [Sun, 27 Sep 2020 22:05:40 +0000 (00:05 +0200)]
library/{panic_,}unwind: Add definitions for sparc-unknow-linux-gnu

3 years agoAuto merge of #77242 - ecstatic-morse:dataflow-switch-int, r=jonas-schievink
bors [Sun, 27 Sep 2020 21:54:49 +0000 (21:54 +0000)]
Auto merge of #77242 - ecstatic-morse:dataflow-switch-int, r=jonas-schievink

Replace `discriminant_switch_effect` with more general version

#68528 added a new edge-specific effect for `SwitchInt` terminators, `discriminant_switch_effect`, to the dataflow framework. While this accomplished the short-term goal of making drop elaboration more precise, it wasn't really useful in other contexts: It only supported `SwitchInt`s on the discriminant of an `enum` and did not allow effects to be applied along the "otherwise" branch. In const-propagation, for example, arbitrary edge-specific effects for the targets of a `SwitchInt` can be used to remember the value a `match` scrutinee must have in each arm.

This PR replaces `discriminant_switch_effect` with a more general `switch_int_edge_effects` method. The new method has a slightly different interface from the other edge-specific effect methods (e.g. `call_return_effect`). This divergence is explained in the new method's documentation, and reading the changes to the various dataflow impls as well as `direction.rs` should further clarify things. This PR should not change behavior.

3 years agoReopen standard streams when they are closed on Unix
Tomasz Miąsko [Sun, 27 Sep 2020 00:00:00 +0000 (00:00 +0000)]
Reopen standard streams when they are closed on Unix

The syscalls returning a new file descriptors generally use
lowest-numbered file descriptor not currently opened, without any
exceptions for those corresponding to the standard streams.

Previously when any of standard streams has been closed before starting
the application, operations on std::io::{stderr,stdin,stdout} objects
were likely to operate on other logically unrelated file resources
opened afterwards.

Avoid the issue by reopening the standard streams when they are closed.

3 years agoAuto merge of #77229 - tmiasko:liveness, r=lcnr
bors [Sun, 27 Sep 2020 19:38:01 +0000 (19:38 +0000)]
Auto merge of #77229 - tmiasko:liveness, r=lcnr

Small improvements in liveness pass

* Remove redundant debug logging (`add_variable` already contains logging).
* Remove redundant fields for a number of live nodes and variables.
* Delay conversion from a symbol to a string until linting.
* Inline contents of specials struct.
* Remove unnecessary local variable exit_ln.
* Use newtype_index for Variable and LiveNode.
* Access live nodes directly through self.lnks[ln].

No functional changes intended (except those related to the logging).

3 years agoAuto merge of #77272 - jonas-schievink:rollup-dydo5kn, r=jonas-schievink
bors [Sun, 27 Sep 2020 17:27:26 +0000 (17:27 +0000)]
Auto merge of #77272 - jonas-schievink:rollup-dydo5kn, r=jonas-schievink

Rollup of 7 pull requests

Successful merges:

 - #76839 (Add asm! support for MIPS)
 - #77203 (Check for missing const-stability attributes in `rustc_passes`)
 - #77249 (Separate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints)
 - #77252 (reduce overlong line)
 - #77256 (Fix typo in ExpnData documentation)
 - #77262 (Remove duplicate comment)
 - #77263 (Clean up trivial if let)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #77263 - bugadani:cleanup, r=lcnr
Jonas Schievink [Sun, 27 Sep 2020 16:37:29 +0000 (18:37 +0200)]
Rollup merge of #77263 - bugadani:cleanup, r=lcnr

Clean up trivial if let

3 years agoRollup merge of #77262 - bugadani:redundant-comment, r=Dylan-DPC
Jonas Schievink [Sun, 27 Sep 2020 16:37:28 +0000 (18:37 +0200)]
Rollup merge of #77262 - bugadani:redundant-comment, r=Dylan-DPC

Remove duplicate comment

3 years agoRollup merge of #77256 - jyn514:typo, r=Aaron1011
Jonas Schievink [Sun, 27 Sep 2020 16:37:26 +0000 (18:37 +0200)]
Rollup merge of #77256 - jyn514:typo, r=Aaron1011

Fix typo in ExpnData documentation

This mis-highlighted the entire documentation as code: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/hygiene/struct.ExpnData.html#structfield.krate

3 years agoRollup merge of #77252 - tshepang:overlong, r=jyn514
Jonas Schievink [Sun, 27 Sep 2020 16:37:24 +0000 (18:37 +0200)]
Rollup merge of #77252 - tshepang:overlong, r=jyn514

reduce overlong line

3 years agoRollup merge of #77249 - jyn514:private-links, r=Manishearth
Jonas Schievink [Sun, 27 Sep 2020 16:37:23 +0000 (18:37 +0200)]
Rollup merge of #77249 - jyn514:private-links, r=Manishearth

Separate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints

This is not ideal because it means `deny(broken_intra_doc_links)` will
no longer `deny(private_intra_doc_links)`. However, it can't be fixed
with a new lint group, because `broken` is already in the `rustdoc` lint
group; there would need to be a way to nest groups somehow.

This also removes the early `return` so that the link will be generated
even though it gives a warning.

r? @Manishearth
cc @ecstatic-morse (https://github.com/rust-lang/rust/pull/77242#issuecomment-699565095)

3 years agoRollup merge of #77203 - ecstatic-morse:const-stability-attr-checks, r=oli-obk
Jonas Schievink [Sun, 27 Sep 2020 16:37:21 +0000 (18:37 +0200)]
Rollup merge of #77203 - ecstatic-morse:const-stability-attr-checks, r=oli-obk

Check for missing const-stability attributes in `rustc_passes`

Currently, this happens as a side effect of `is_min_const_fn`, which is non-obvious. Also adds a test for this case, since we didn't seem to have one before.

3 years agoRollup merge of #76839 - lzutao:mips-asm, r=Amanieu
Jonas Schievink [Sun, 27 Sep 2020 16:37:20 +0000 (18:37 +0200)]
Rollup merge of #76839 - lzutao:mips-asm, r=Amanieu

Add asm! support for MIPS

For now, I only add support for mips32.
mips64 may come in future PRs if I could learn more about the target.

3 years agoAuto merge of #77259 - dgbo:master, r=kennytm
bors [Sun, 27 Sep 2020 15:14:55 +0000 (15:14 +0000)]
Auto merge of #77259 - dgbo:master, r=kennytm

update stdarch submodule

This commit update the src/stdarch submodule, we primarily want to include [https://github.com/rust-lang/stdarch/pull/918](url) which provides prefetch hints for aarch64. This PR could deliver ~20% performance gain on our aarch64 server in Filecoin. Wish this could be used as soon as possible.

Thanks.

3 years agoAdd documentation for `private_intra_doc_links`
Joshua Nelson [Sun, 27 Sep 2020 14:07:00 +0000 (10:07 -0400)]
Add documentation for `private_intra_doc_links`

3 years agoSeparate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints
Joshua Nelson [Sun, 27 Sep 2020 01:27:55 +0000 (21:27 -0400)]
Separate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints

This is not ideal because it means `deny(broken_intra_doc_links)` will
no longer `deny(private_intra_doc_links)`. However, it can't be fixed
with a new lint group, because `broken` is already in the `rustdoc` lint
group; there would need to be a way to nest groups somehow.

This also removes the early `return` so that the link will be generated
even though it gives a warning.

3 years agoUpdate chalk to 0.29.0
Bram van den Heuvel [Sun, 27 Sep 2020 13:54:07 +0000 (15:54 +0200)]
Update chalk to 0.29.0

3 years agoAuto merge of #77118 - exrook:stability-generic-parameters-2, r=varkor
bors [Sun, 27 Sep 2020 12:51:21 +0000 (12:51 +0000)]
Auto merge of #77118 - exrook:stability-generic-parameters-2, r=varkor

 Stability annotations on generic parameters (take 2.5)

Rebase of #72314 + more tests

Implements rust-lang/wg-allocators#2.

3 years agoAuto merge of #71274 - RalfJung:raw-init-check-aggregate, r=petrochenkov
bors [Sun, 27 Sep 2020 10:17:09 +0000 (10:17 +0000)]
Auto merge of #71274 - RalfJung:raw-init-check-aggregate, r=petrochenkov

might_permit_raw_init: also check aggregate fields

This is the next step for https://github.com/rust-lang/rust/issues/66151: when doing `mem::zeroed`/`mem::uninitialized`, also recursively check fields of aggregates (except for arrays) for whether they permit zero/uninit initialization.

3 years agoClean up trivial if let
Dániel Buga [Sun, 27 Sep 2020 09:54:50 +0000 (11:54 +0200)]
Clean up trivial if let

3 years agoRemove duplicate comment
Dániel Buga [Sun, 27 Sep 2020 09:00:46 +0000 (11:00 +0200)]
Remove duplicate comment

3 years agoupdate tokei and ripgrep in cargotest
Ralf Jung [Sun, 27 Sep 2020 08:58:42 +0000 (10:58 +0200)]
update tokei and ripgrep in cargotest

3 years agoAuto merge of #76955 - jyn514:refactor-diagnostics, r=euclio
bors [Sun, 27 Sep 2020 08:12:29 +0000 (08:12 +0000)]
Auto merge of #76955 - jyn514:refactor-diagnostics, r=euclio

Refactor and fix intra-doc link diagnostics, and fix links to primitives

Closes https://github.com/rust-lang/rust/issues/76925, closes https://github.com/rust-lang/rust/issues/76693, closes https://github.com/rust-lang/rust/issues/76692.

Originally I only meant to fix #76925. But the hack with `has_primitive` was so bad it was easier to fix the primitive issues than to try and work around it.

Note that this still has one bug: `std::primitive::i32::MAX` does not resolve. However, this fixes the ICE so I'm fine with fixing the link in a later PR.

This is part of a series of refactors to make #76467 possible.

This is best reviewed commit-by-commit; it has detailed commit messages.

r? `@euclio`

3 years agofix redundant delarations of const_fn_transmute
Dong Bo [Sun, 27 Sep 2020 07:13:32 +0000 (15:13 +0800)]
fix redundant delarations of const_fn_transmute

3 years agoupdate stdarch submodule
Dong Bo [Sun, 27 Sep 2020 05:41:08 +0000 (13:41 +0800)]
update stdarch submodule

3 years agoAuto merge of #77154 - fusion-engineering-forks:lazy-stdio, r=dtolnay
bors [Sun, 27 Sep 2020 04:50:46 +0000 (04:50 +0000)]
Auto merge of #77154 - fusion-engineering-forks:lazy-stdio, r=dtolnay

Remove std::io::lazy::Lazy in favour of SyncOnceCell

The (internal) std::io::lazy::Lazy was used to lazily initialize the stdout and stdin buffers (and mutexes). It uses atexit() to register a destructor to flush the streams on exit, and mark the streams as 'closed'. Using the stream afterwards would result in a panic.

Stdout uses a LineWriter which contains a BufWriter that will flush the buffer on drop. This one is important to be executed during shutdown, to make sure no buffered output is lost. It also forbids access to stdout afterwards, since the buffer is already flushed and gone.

Stdin uses a BufReader, which does not implement Drop. It simply forgets any previously read data that was not read from the buffer yet. This means that in the case of stdin, the atexit() function's only effect is making stdin inaccessible to the program, such that later accesses result in a panic. This is uncessary, as it'd have been safe to access stdin during shutdown of the program.

---

This change removes the entire io::lazy module in favour of SyncOnceCell. SyncOnceCell's fast path is much faster (a single atomic operation) than locking a sys_common::Mutex on every access like Lazy did.

However, SyncOnceCell does not use atexit() to drop the contained object during shutdown.

As noted above, this is not a problem for stdin. It simply means stdin is now usable during shutdown.

The atexit() call for stdout is moved to the stdio module. Unlike the now-removed Lazy struct, SyncOnceCell does not have a 'gone and unusable' state that panics. Instead of adding this again, this simply replaces the buffer with one with zero capacity. This effectively flushes the old buffer *and* makes any writes afterwards pass through directly without touching a buffer, making print!() available during shutdown without panicking.

---

In addition, because the contents of the SyncOnceCell are no longer dropped, we can now use `&'static` instead of `Arc` in `Stdout` and `Stdin`. This also saves two levels of indirection in `stdin()` and `stdout()`, since Lazy effectively stored a `Box<Arc<T>>`, and SyncOnceCell stores the `T` directly.

3 years agoFix typo in ExpnData documentation
Joshua Nelson [Sun, 27 Sep 2020 04:09:45 +0000 (00:09 -0400)]
Fix typo in ExpnData documentation

This mis-highlighted the entire documentation as code.

3 years agoAdd MIPS asm! support
Lzu Tao [Wed, 16 Sep 2020 15:35:58 +0000 (15:35 +0000)]
Add MIPS asm! support

This patch also:
* Add soft-float supports: only f32
* zero-extend i8/i16 to i32 because MIPS only supports register-length
  arithmetic.
* Update table in asm! chapter in unstable book.

3 years agoAuto merge of #76986 - jonas-schievink:ret-in-reg, r=nagisa
bors [Sun, 27 Sep 2020 02:35:11 +0000 (02:35 +0000)]
Auto merge of #76986 - jonas-schievink:ret-in-reg, r=nagisa

Return values up to 128 bits in registers

This fixes https://github.com/rust-lang/rust/issues/26494#issuecomment-619506345 by making Rust's default ABI pass return values up to 128 bits in size in registers, just like the System V ABI.

The result is that these methods from the comment linked above now generate the same code, making the Rust ABI as efficient as the `"C"` ABI:

```rust
pub struct Stats { x: u32, y: u32, z: u32, }

pub extern "C" fn sum_c(a: &Stats, b: &Stats) -> Stats {
    return Stats {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
}

pub fn sum_rust(a: &Stats, b: &Stats) -> Stats {
    return Stats {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
}
```

```asm
sum_rust:
movl (%rsi), %eax
addl (%rdi), %eax
movl 4(%rsi), %ecx
addl 4(%rdi), %ecx
movl 8(%rsi), %edx
addl 8(%rdi), %edx
shlq $32, %rcx
orq %rcx, %rax
retq
```

3 years agoreduce overlong line
Tshepang Lekhonkhobe [Sun, 27 Sep 2020 02:22:55 +0000 (04:22 +0200)]
reduce overlong line

3 years agoRemove intra-doc link
Dylan MacKenzie [Sun, 27 Sep 2020 00:29:55 +0000 (17:29 -0700)]
Remove intra-doc link

3 years agoAuto merge of #77247 - jonas-schievink:rollup-r6ehh8h, r=jonas-schievink
bors [Sun, 27 Sep 2020 00:16:45 +0000 (00:16 +0000)]
Auto merge of #77247 - jonas-schievink:rollup-r6ehh8h, r=jonas-schievink

Rollup of 10 pull requests

Successful merges:

 - #76917 (Add missing code examples on HashMap types)
 - #77107 (Enable const propagation into operands at mir_opt_level=2)
 - #77129 (Update cargo)
 - #77167 (Fix FIXME in core::num test: Check sign of zero in min/max tests.)
 - #77184 (Rust vec bench import specific rand::RngCore)
 - #77208 (Late link args order)
 - #77209 (Fix documentation highlighting in ty::BorrowKind)
 - #77231 (Move helper function for `missing_const_for_fn` out of rustc to clippy)
 - #77235 (pretty-print-reparse hack: Rename some variables for clarity)
 - #77243 (Test more attributes in test issue-75930-derive-cfg.rs)

Failed merges:

r? `@ghost`

3 years agoliveness: Access live nodes directly through self.lnks[ln]
Tomasz Miąsko [Sun, 27 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Access live nodes directly through self.lnks[ln]

3 years agoRollup merge of #77243 - Aaron1011:more-derive-test, r=petrochenkov
Jonas Schievink [Sat, 26 Sep 2020 23:53:33 +0000 (01:53 +0200)]
Rollup merge of #77243 - Aaron1011:more-derive-test, r=petrochenkov

Test more attributes in test issue-75930-derive-cfg.rs

Split out from #76130

This tests our handling of combining derives, derive helper
attributes, attribute macros, and `cfg`/`cfg_attr`

3 years agoRollup merge of #77235 - petrochenkov:reparse, r=Aaron1011
Jonas Schievink [Sat, 26 Sep 2020 23:53:29 +0000 (01:53 +0200)]
Rollup merge of #77235 - petrochenkov:reparse, r=Aaron1011

pretty-print-reparse hack: Rename some variables for clarity

This will also make it easier to make the comparisons asymmetric.

Also one impossible case is removed.

r? @Aaron1011

3 years agoRollup merge of #77231 - oli-obk:clippy_const_fn, r=Manishearth
Jonas Schievink [Sat, 26 Sep 2020 23:53:27 +0000 (01:53 +0200)]
Rollup merge of #77231 - oli-obk:clippy_const_fn, r=Manishearth

Move helper function for `missing_const_for_fn` out of rustc to clippy

cc @rust-lang/clippy @ecstatic-morse #76618

r? @Manishearth

I also removed all support for suggesting a function could be `const fn` when that would require feature gates to actually work.

This means we'll now have to maintain this ourselves in clippy, but that's how most lints work anyway, so...

3 years agoRollup merge of #77209 - jyn514:fix-docs, r=petrochenkov
Jonas Schievink [Sat, 26 Sep 2020 23:53:25 +0000 (01:53 +0200)]
Rollup merge of #77209 - jyn514:fix-docs, r=petrochenkov

Fix documentation highlighting in ty::BorrowKind

Previously it looked a little odd: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.BorrowKind.html#variant.UniqueImmBorrow

Noticed this while reviewing https://github.com/rust-lang/rustc-dev-guide/pull/894.

3 years agoRollup merge of #77208 - mati865:late-link-args-order, r=petrochenkov
Jonas Schievink [Sat, 26 Sep 2020 23:53:23 +0000 (01:53 +0200)]
Rollup merge of #77208 - mati865:late-link-args-order, r=petrochenkov

Late link args order

MSYS2 changed how winpthreads is built and as the result it now depends on more mingw-w64 libraries.

This PR affects only MinGW targets since nobody else is using `late_link_args_{dynamic,static}`. Now the order is similar to how it used to be before https://github.com/rust-lang/rust/pull/67502.

3 years agoRollup merge of #77184 - pickfire:patch-4, r=kennytm
Jonas Schievink [Sat, 26 Sep 2020 23:53:22 +0000 (01:53 +0200)]
Rollup merge of #77184 - pickfire:patch-4, r=kennytm

Rust vec bench import specific rand::RngCore

Using `RngCore` import for side effects is clearer than `*` which may bring it unnecessary more stuff than needed, it is also more explicit doing so.

@pickfire change `LEN = 16384` (and pos) and `once` instead of `[0].iter()` after this.

@rustbot modify labels: +C-cleanup +A-testsuite

3 years agoRollup merge of #77167 - fusion-engineering-forks:fix-fixme-min-max-sign-test, r...
Jonas Schievink [Sat, 26 Sep 2020 23:53:20 +0000 (01:53 +0200)]
Rollup merge of #77167 - fusion-engineering-forks:fix-fixme-min-max-sign-test, r=nagisa

Fix FIXME in core::num test: Check sign of zero in min/max tests.

r? nagisa

@rustbot modify labels: +C-cleanup

3 years agoRollup merge of #77129 - ehuss:update-cargo, r=ehuss
Jonas Schievink [Sat, 26 Sep 2020 23:53:18 +0000 (01:53 +0200)]
Rollup merge of #77129 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in 8777a6b1e8834899f51b7e09cc9b8d85b2417110..05c611ae3c4255b7a2bcf4fcfa65b20286a07839
2020-09-15 19:11:03 +0000 to 2020-09-23 23:10:38 +0000
- --workspace flag for locate-project to find the workspace root (rust-lang/cargo#8712)
- Remove some badges documentation. (rust-lang/cargo#8727)
- Add plain message format for locate-project (rust-lang/cargo#8707)
- Add a term option to configure the progress bar (rust-lang/cargo#8165)
- Replace d_as_f64 with as_secs_f64 (rust-lang/cargo#8721)
- Add cross check to filters_target test. (rust-lang/cargo#8713)
- Add test for whitespace behavior in env flags. (rust-lang/cargo#8706)

3 years agoRollup merge of #77107 - bugadani:perf, r=oli-obk
Jonas Schievink [Sat, 26 Sep 2020 23:53:16 +0000 (01:53 +0200)]
Rollup merge of #77107 - bugadani:perf, r=oli-obk

Enable const propagation into operands at mir_opt_level=2

Feature was added in #74507 but gated with `mir_opt_level>=3` because of compile time regressions. Let's see whether the LLVM 11 update solves that.

As the [perf results](https://github.com/rust-lang/rust/pull/77107#issuecomment-697668154) show, enabling this optimization results in a lot less regression as before.

cc @oli-obk

r? @ghost

3 years agoRollup merge of #76917 - GuillaumeGomez:map-missing-code-examples, r=Dylan-DPC
Jonas Schievink [Sat, 26 Sep 2020 23:53:13 +0000 (01:53 +0200)]
Rollup merge of #76917 - GuillaumeGomez:map-missing-code-examples, r=Dylan-DPC

Add missing code examples on HashMap types

r? @Dylan-DPC

3 years agoUpdate dataflow impls to reflect new interface
Dylan MacKenzie [Sat, 26 Sep 2020 20:13:37 +0000 (13:13 -0700)]
Update dataflow impls to reflect new interface

3 years agoUpdate engine to use new interface
Dylan MacKenzie [Sat, 26 Sep 2020 20:12:51 +0000 (13:12 -0700)]
Update engine to use new interface

3 years agoReplace `discriminant_switch_effect` with more general version
Dylan MacKenzie [Sat, 26 Sep 2020 19:34:37 +0000 (12:34 -0700)]
Replace `discriminant_switch_effect` with more general version

...that allows arbitrary effects on each edge of a `SwitchInt`
terminator.

3 years agoTest more attributes in test issue-75930-derive-cfg.rs
Aaron Hill [Sat, 26 Sep 2020 21:29:37 +0000 (17:29 -0400)]
Test more attributes in test issue-75930-derive-cfg.rs

Split out from #76130

This tests our handling of combining derives, derive helper
attributes, attribute macros, and `cfg`/`cfg_attr`

3 years agoAuto merge of #76897 - Aaron1011:feature/min-proc-macro-metadata, r=petrochenkov
bors [Sat, 26 Sep 2020 20:57:31 +0000 (20:57 +0000)]
Auto merge of #76897 - Aaron1011:feature/min-proc-macro-metadata, r=petrochenkov

Encode less metadata for proc-macro crates

Currently, we serialize the same crate metadata for proc-macro crates as
we do for normal crates. This is quite wasteful - almost none of this
metadata is ever used, and much of it can't even be deserialized (if it
contains a foreign `CrateNum`).

This PR changes metadata encoding to skip encoding the majority of crate
metadata for proc-macro crates. Most of the `Lazy<[T]>` fields are left
completetly empty, while the non-lazy fields are left as-is.

Additionally, proc-macros now have a def span that does not include
their body. This was done for normal functions in #75465, but was missed
for proc-macros.

As a result of this PR, we should only ever encode local `CrateNum`s
when encoding proc-macro crates. I've added a specialized serialization
impl for `CrateNum` to assert this.

3 years agoAuto merge of #77224 - RalfJung:rollup-hdvb96c, r=RalfJung
bors [Sat, 26 Sep 2020 17:50:26 +0000 (17:50 +0000)]
Auto merge of #77224 - RalfJung:rollup-hdvb96c, r=RalfJung

Rollup of 12 pull requests

Successful merges:

 - #75454 (Explicitly document the size guarantees that Option makes.)
 - #76631 (Add `x.py setup`)
 - #77076 (Add missing code examples on slice iter types)
 - #77093 (merge `need_type_info_err(_const)`)
 - #77122 (Add `#![feature(const_fn_floating_point_arithmetic)]`)
 - #77127 (Update mdBook)
 - #77161 (Remove TrustedLen requirement from BuilderMethods::switch)
 - #77166 (update Miri)
 - #77181 (Add doc alias for pointer primitive)
 - #77204 (Remove stray word from `ClosureKind::extends` docs)
 - #77207 (Rename `whence` to `span`)
 - #77211 (Remove unused #[allow(...)] statements from compiler/)

Failed merges:

 - #77170 (Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]`)

r? `@ghost`

3 years agopretty-print-reparse hack: Remove an impossible case
Vadim Petrochenkov [Sat, 26 Sep 2020 17:27:14 +0000 (20:27 +0300)]
pretty-print-reparse hack: Remove an impossible case

Delimiters cannot appear as isolated tokens in a token stream

3 years agopretty-print-reparse hack: Rename some variables for clarity
Vadim Petrochenkov [Sat, 26 Sep 2020 15:46:19 +0000 (18:46 +0300)]
pretty-print-reparse hack: Rename some variables for clarity

3 years agoCall `type_of` for opaque types later in compilation
Matthew Jasper [Sat, 26 Sep 2020 16:56:03 +0000 (17:56 +0100)]
Call `type_of` for opaque types later in compilation

This ensures that various wf checks have already been done before we
typeck item bodies.

3 years agoEncode less metadata for proc-macro crates
Aaron Hill [Fri, 18 Sep 2020 20:18:10 +0000 (16:18 -0400)]
Encode less metadata for proc-macro crates

Currently, we serialize the same crate metadata for proc-macro crates as
we do for normal crates. This is quite wasteful - almost none of this
metadata is ever used, and much of it can't even be deserialized (if it
contains a foreign `CrateNum`).

This PR changes metadata encoding to skip encoding the majority of crate
metadata for proc-macro crates. Most of the `Lazy<[T]>` fields are left
completetly empty, while the non-lazy fields are left as-is.

Additionally, proc-macros now have a def span that does not include
their body. This was done for normal functions in #75465, but was missed
for proc-macros.

As a result of this PR, we should only ever encode local `CrateNum`s
when encoding proc-macro crates. I've added a specialized serialization
impl for `CrateNum` to assert this.

3 years agoDelay bug for non-universal regions in member constraints
Matthew Jasper [Sat, 22 Aug 2020 17:25:09 +0000 (18:25 +0100)]
Delay bug for non-universal regions in member constraints

3 years agoAdd a test for 128-bit return values
Jonas Schievink [Sat, 26 Sep 2020 14:37:13 +0000 (16:37 +0200)]
Add a test for 128-bit return values

3 years agoliveness: Use newtype_index for Variable and LiveNode
Tomasz Miąsko [Sat, 26 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Use newtype_index for Variable and LiveNode

3 years agoliveness: Remove unnecessary local variable exit_ln
Tomasz Miąsko [Sat, 26 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Remove unnecessary local variable exit_ln

3 years agoRemove all unstable feature support in the `missing_const_for_fn` lint
Oliver Scherer [Sat, 26 Sep 2020 14:23:56 +0000 (16:23 +0200)]
Remove all unstable feature support in the `missing_const_for_fn` lint

3 years agoMove `qualify_min_const_fn` out of rustc into clippy
Oliver Scherer [Sat, 26 Sep 2020 14:08:24 +0000 (16:08 +0200)]
Move `qualify_min_const_fn` out of rustc into clippy

3 years agoliveness: Inline contents of specials struct
Tomasz Miąsko [Sat, 26 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Inline contents of specials struct

3 years agoliveness: Delay conversion from a symbol to a string until linting
Tomasz Miąsko [Sat, 26 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Delay conversion from a symbol to a string until linting

3 years agoliveness: Remove redundant fields for a number of live nodes and variables
Tomasz Miąsko [Sat, 26 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Remove redundant fields for a number of live nodes and variables

3 years agoliveness: Remove redundant debug logging
Tomasz Miąsko [Sat, 26 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Remove redundant debug logging

The IrMaps::add_variable already contains debug logging. Don't duplicate it.

3 years agoReturn values up to 128 bits in registers
Jonas Schievink [Mon, 21 Sep 2020 21:01:31 +0000 (23:01 +0200)]
Return values up to 128 bits in registers

3 years agoDeduplicate and generalize some (de/)serializer impls
Oliver Scherer [Sat, 26 Sep 2020 12:55:42 +0000 (14:55 +0200)]
Deduplicate and generalize some (de/)serializer impls

3 years agoRollup merge of #77211 - est31:remove_unused_allow, r=oli-obk
Ralf Jung [Sat, 26 Sep 2020 10:58:34 +0000 (12:58 +0200)]
Rollup merge of #77211 - est31:remove_unused_allow, r=oli-obk

Remove unused #[allow(...)] statements from compiler/

3 years agoRollup merge of #77207 - camelid:whence-to-span, r=jyn514
Ralf Jung [Sat, 26 Sep 2020 10:58:32 +0000 (12:58 +0200)]
Rollup merge of #77207 - camelid:whence-to-span, r=jyn514

Rename `whence` to `span`

It's called `span` elsewhere in the compiler and `span` is also less
surprising. `whence` is whimsical, but not super clear :)

See [this Discord conversation](https://discord.com/channels/442252698964721669/459149231702278154/758731658689511444) for more.

r? @jyn514

3 years agoRollup merge of #77204 - LingMan:patch-3, r=jonas-schievink
Ralf Jung [Sat, 26 Sep 2020 10:58:30 +0000 (12:58 +0200)]
Rollup merge of #77204 - LingMan:patch-3, r=jonas-schievink

Remove stray word from `ClosureKind::extends` docs

3 years agoRollup merge of #77181 - GuillaumeGomez:add-pointer-alias, r=jyn514,pickfire
Ralf Jung [Sat, 26 Sep 2020 10:58:28 +0000 (12:58 +0200)]
Rollup merge of #77181 - GuillaumeGomez:add-pointer-alias, r=jyn514,pickfire

Add doc alias for pointer primitive

3 years agoRollup merge of #77166 - RalfJung:miri, r=RalfJung
Ralf Jung [Sat, 26 Sep 2020 10:58:26 +0000 (12:58 +0200)]
Rollup merge of #77166 - RalfJung:miri, r=RalfJung

update Miri

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

3 years agoRollup merge of #77161 - est31:swich_len_already_trusted, r=petrochenkov
Ralf Jung [Sat, 26 Sep 2020 10:58:24 +0000 (12:58 +0200)]
Rollup merge of #77161 - est31:swich_len_already_trusted, r=petrochenkov

Remove TrustedLen requirement from BuilderMethods::switch

The main use case of TrustedLen is allowing APIs to specialize on it,
but no use of it uses that specialization. Instead, only the .len()
function provided by ExactSizeIterator is used, which is already
required to be accurate.

Thus, the TrustedLen requirement on BuilderMethods::switch is redundant.

3 years agoRollup merge of #77127 - camelid:update-mdbook, r=Dylan-DPC
Ralf Jung [Sat, 26 Sep 2020 10:58:22 +0000 (12:58 +0200)]
Rollup merge of #77127 - camelid:update-mdbook, r=Dylan-DPC

Update mdBook

0.4.2 -> 0.4.3

Also updated version requirement in `Cargo.toml` from 0.4.0 to 0.4.3.

3 years agoRollup merge of #77122 - ecstatic-morse:const-fn-arithmetic, r=RalfJung,oli-obk
Ralf Jung [Sat, 26 Sep 2020 10:58:20 +0000 (12:58 +0200)]
Rollup merge of #77122 - ecstatic-morse:const-fn-arithmetic, r=RalfJung,oli-obk

Add `#![feature(const_fn_floating_point_arithmetic)]`

cc #76618

This is a template for splitting up `const_fn` into granular feature gates. I think this will make it easier, both for us and for users, to track stabilization of each individual feature. We don't *have* to do this, however. We could also keep stabilizing things out from under `const_fn`.

cc @rust-lang/wg-const-eval
r? @oli-obk

3 years agoRollup merge of #77093 - lcnr:const-generics-infer-warning, r=varkor
Ralf Jung [Sat, 26 Sep 2020 10:58:17 +0000 (12:58 +0200)]
Rollup merge of #77093 - lcnr:const-generics-infer-warning, r=varkor

merge `need_type_info_err(_const)`

I hoped that this would automatically solve #76737 but it doesn't quite seem like it

fixes #77092

r? @varkor

3 years agoRollup merge of #77076 - GuillaumeGomez:missing-code-examples-slice-iter, r=Dylan-DPC
Ralf Jung [Sat, 26 Sep 2020 10:58:15 +0000 (12:58 +0200)]
Rollup merge of #77076 - GuillaumeGomez:missing-code-examples-slice-iter, r=Dylan-DPC

Add missing code examples on slice iter types

r? @Dylan-DPC

3 years agoRollup merge of #76631 - jyn514:x.py-setup, r=Mark-Simulacrum
Ralf Jung [Sat, 26 Sep 2020 10:58:13 +0000 (12:58 +0200)]
Rollup merge of #76631 - jyn514:x.py-setup, r=Mark-Simulacrum

Add `x.py setup`

Closes #76503.

- Suggest `x.py setup` if config.toml doesn't exist yet
- Prompt for a profile if not given on the command line
- Print the configuration that will be used
- Print helpful starting commands after setup
- Link to the dev-guide after finishing

3 years agoRollup merge of #75454 - ltratt:option_optimisation_guarantees, r=dtolnay
Ralf Jung [Sat, 26 Sep 2020 10:58:12 +0000 (12:58 +0200)]
Rollup merge of #75454 - ltratt:option_optimisation_guarantees, r=dtolnay

Explicitly document the size guarantees that Option makes.

Triggered by a discussion on wg-unsafe-code-guidelines about which layouts of `Option<T>` one can guarantee are optimised to a single pointer.

CC @RalfJung

3 years agomight_permit_raw_init: also check aggregate fields
Ralf Jung [Sat, 18 Apr 2020 07:54:05 +0000 (09:54 +0200)]
might_permit_raw_init: also check aggregate fields

3 years agoDisable stdout-during-shutdown test on emscripten.
Mara Bos [Sat, 26 Sep 2020 09:47:26 +0000 (11:47 +0200)]
Disable stdout-during-shutdown test on emscripten.

3 years agoAuto merge of #76485 - estebank:format_arg_capture_spans, r=davidtwco
bors [Sat, 26 Sep 2020 10:05:49 +0000 (10:05 +0000)]
Auto merge of #76485 - estebank:format_arg_capture_spans, r=davidtwco

Point at named argument not found when using `format_args_capture` instead of whole format string

3 years agoAdd doc alias for pointer primitive
Guillaume Gomez [Fri, 25 Sep 2020 12:08:38 +0000 (14:08 +0200)]
Add doc alias for pointer primitive

3 years agounused into
Bastian Kauschke [Sat, 26 Sep 2020 08:31:34 +0000 (10:31 +0200)]
unused into

3 years agorename functions
Bastian Kauschke [Sat, 26 Sep 2020 08:28:15 +0000 (10:28 +0200)]
rename functions

3 years agoAuto merge of #70743 - oli-obk:eager_const_to_pat_conversion, r=eddyb
bors [Sat, 26 Sep 2020 06:44:28 +0000 (06:44 +0000)]
Auto merge of #70743 - oli-obk:eager_const_to_pat_conversion, r=eddyb

Fully destructure constants into patterns

r? `@varkor`

as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/constants.20in.20patterns/near/192789924

we should probably crater it once reviewed

3 years agoAuto merge of #74225 - poliorcetics:std-thread-unsafe-op-in-unsafe-fn, r=joshtriplett
bors [Sat, 26 Sep 2020 03:54:00 +0000 (03:54 +0000)]
Auto merge of #74225 - poliorcetics:std-thread-unsafe-op-in-unsafe-fn, r=joshtriplett

Std/thread: deny unsafe op in unsafe fn

Partial fix of #73904.

This encloses `unsafe` operations in `unsafe fn` in `libstd/thread`.
`@rustbot` modify labels: F-unsafe-block-in-unsafe-fn

3 years agoAuto merge of #76176 - marmeladema:fix-closure-path-printing, r=eddyb
bors [Sat, 26 Sep 2020 01:36:50 +0000 (01:36 +0000)]
Auto merge of #76176 - marmeladema:fix-closure-path-printing, r=eddyb

Move from {{closure}}#0 syntax to {closure#0} for (def) path components

Part of #70334

I followed the approach described by `@eddyb` and introduced a `DefPathDataName` enum.
To preserve compatibility, in various places, I had to rely on formatting manually by calling `format!("{{{{{}}}}}", namespace)`.

My questions are:
* Do we want to convert for places to use the new naming scheme? Or shall I re-add `DefPathData::as_symbol` but renamed as `DefPathData::as_legacy_symbol` to avoid manually allocating the legacy symbols?
* Do we want to `impl Display for DisambiguatedDefPathData` to avoid manually calling `write!(s, "{{{}#{}}}", namespace, component.disambiguator)`?
* We might also want to improve naming for `DefPathDataName` and `DefPathData::get_name`

r? `@eddyb`

3 years agoRemove unused #[allow(...)] statements from compiler/
est31 [Fri, 25 Sep 2020 23:17:54 +0000 (01:17 +0200)]
Remove unused #[allow(...)] statements from compiler/

3 years agoFix documentation highlighting in ty::BorrowKind
Joshua Nelson [Fri, 25 Sep 2020 22:54:05 +0000 (18:54 -0400)]
Fix documentation highlighting in ty::BorrowKind

Previously it looked a little odd: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.BorrowKind.html#variant.UniqueImmBorrow

3 years agoRename `whence` to `span`
Camelid [Fri, 25 Sep 2020 21:59:00 +0000 (14:59 -0700)]
Rename `whence` to `span`

It's called `span` elsewhere in the compiler and `span` is also less
surprising. `whence` is whimsical, but not super clear :)