Commit graph

128376 commits

Author SHA1 Message Date
Tyson Nottingham
d061fee177 Stable hashing: add comments and tests concerning platform-independence
SipHasher128 implements short_write in an endian-independent way, yet
its write_xxx Hasher trait methods undo this endian-independence by byte
swapping the integer inputs on big-endian hardware. StableHasher then
adds endian-independence back by also byte-swapping on big-endian
hardware prior to invoking SipHasher128.

This double swap may have the appearance of being a no-op, but is in
fact by design. In particular, we really do want SipHasher128 to be
platform-dependent, in order to be consistent with the libstd SipHasher.
Try to clarify this intent. Also, add and update a couple of unit tests.
2020-09-30 00:57:35 -07:00
bors
fc2daaae61 Auto merge of #77302 - RalfJung:rollup-n8gg3v6, r=RalfJung
Rollup of 7 pull requests

Successful merges:

 - #76454 (UI to unit test for those using Cell/RefCell/UnsafeCell)
 - #76474 (Add option to pass a custom codegen backend from a driver)
 - #76711 (diag: improve closure/generic parameter mismatch)
 - #77170 (Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]`)
 - #77194 (Add doc alias for iterator fold)
 - #77288 (fix building libstd for Miri on macOS)
 - #77295 (Update unstable-book: Fix ABNF in inline assembly docs)

Failed merges:

r? `@ghost`
2020-09-28 18:02:45 +00:00
Ralf Jung
d9c11929a5
Rollup merge of #77295 - jethrogb:jb/unstable-book-asm, r=Amanieu
Update unstable-book: Fix ABNF in inline assembly docs

r? @Amanieu
2020-09-28 18:39:49 +02:00
Ralf Jung
a966f54bbb
Rollup merge of #77288 - RalfJung:miri-macos, r=Amanieu
fix building libstd for Miri on macOS

Fixes a Miri regression introduced by https://github.com/rust-lang/rust/pull/75295
Cc @tmiasko @Amanieu
2020-09-28 18:39:47 +02:00
Ralf Jung
aba966a592
Rollup merge of #77194 - pickfire:patch-7, r=withoutboats
Add doc alias for iterator fold

fold is known in python and javascript as reduce,
not sure about inject but it was written in doc there.

This was my first confusion when coming into rust, I somehow cannot find where is reduce, sometimes I still forget that it is known as `fold`.
2020-09-28 18:39:46 +02:00
Ralf Jung
85a59d40f1
Rollup merge of #77170 - ecstatic-morse:const-fn-ptr, r=oli-obk
Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]`

`rustc_allow_const_fn_ptr` was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need a bespoke attribute.

Now this functionality is gated under `const_fn_fn_ptr_basics` (how concise!), and `#[allow_internal_unstable(const_fn_fn_ptr_basics)]` replaces `#[rustc_allow_const_fn_ptr]`. `const_fn_fn_ptr_basics` allows function pointer types to appear in the arguments and locals of a `const fn` as well as function pointer casts to be performed inside a `const fn`. Both of these were allowed in constants and statics already. Notably, this does **not** allow users to invoke function pointers in a const context. Presumably, we will use a nicer name for that (`const_fn_ptr`?).

r? @oli-obk
2020-09-28 18:39:44 +02:00
Ralf Jung
88ae20d8aa
Rollup merge of #76711 - davidtwco:issue-51154-param-closure, r=estebank
diag: improve closure/generic parameter mismatch

Fixes #51154.

This PR improves the diagnostic when a type parameter is expected and a closure is found, noting that each closure has a distinct type and therefore could not always match the caller-chosen type of the parameter.

r? @estebank
2020-09-28 18:39:42 +02:00
Ralf Jung
6a8cdbd285
Rollup merge of #76474 - bjorn3:driver_selected_codegen, r=oli-obk
Add option to pass a custom codegen backend from a driver

This allows the driver to pass information to the codegen backend. For example the headcrab debugger may in the future want to use cg_clif to JIT code to be injected in the debuggee. This would PR make it possible to tell cg_clif which symbol can be found at which address and to tell it to inject the JITed code into the right process.

This PR may also help with https://github.com/rust-lang/miri/pull/1540 by allowing miri to provide a codegen backend that only emits metadata and doesn't perform any codegen.

cc @nbaksalyar (headcrab)
cc @RalfJung (miri)
2020-09-28 18:39:40 +02:00
Ralf Jung
734c57d45c
Rollup merge of #76454 - poliorcetics:ui-to-unit-test-1, r=matklad
UI to unit test for those using Cell/RefCell/UnsafeCell

Helps with #76268.

I'm working on all files using `Cell` and moving them to unit tests when possible.

r? @matklad
2020-09-28 18:39:39 +02:00
bors
d62d3f7fa9 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`
2020-09-28 15:32:27 +00:00
Jethro Beekman
6817b6238d Update unstable-book: Fix ABNF in inline assembly docs 2020-09-28 15:57:21 +02:00
bors
535d27ac9a 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
2020-09-28 12:47:23 +00:00
bors
1d5a865b2f 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.
2020-09-28 10:37:41 +00:00
bors
96555ba608 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.
2020-09-28 08:33:00 +00:00
Ralf Jung
dc8414b607 fix building libstd for Miri on macOS 2020-09-28 10:32:05 +02:00
bors
4e3eb52493 Auto merge of #77265 - vandenheuvel:chalkup, r=Dylan-DPC
Update chalk to 0.29.0
2020-09-28 06:20:02 +00:00
bors
6369a98ebd 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.
2020-09-28 03:28:04 +00:00
bors
db7ee7cc0d 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.
2020-09-28 00:58:40 +00:00
Wesley Wiser
c653af81b1 Remove unnecessary -Zunsound-mir-opts uses in tests 2020-09-27 19:29:15 -04:00
Wesley Wiser
b9d0ea95c8 [mir-opt] Introduce a new flag to enable experimental/unsound mir opts 2020-09-27 19:21:01 -04:00
John Paul Adrian Glaubitz
d25b0364e1 library/std: Set OS raw type definitions for sparc-unknown-linux-gnu 2020-09-28 00:39:57 +02:00
John Paul Adrian Glaubitz
d9de08d65c library/std/sys_common: Define MIN_ALIGN for sparc-unknown-linux-gnu 2020-09-28 00:39:57 +02:00
John Paul Adrian Glaubitz
1fefba5e0b library/{panic_,}unwind: Add definitions for sparc-unknow-linux-gnu 2020-09-28 00:39:57 +02:00
bors
c0b15cc6ed 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.
2020-09-27 21:54:49 +00:00
Tomasz Miąsko
7d98d2207a 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.
2020-09-27 22:55:43 +02:00
bors
7f7a1cbfd3 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).
2020-09-27 19:38:01 +00:00
Dylan MacKenzie
807260be9f Remove feature gate test for rustc_allow_const_fn_ptr 2020-09-27 11:51:40 -07:00
Dylan MacKenzie
368502cc1d Mark min_const_fn_fn_ptr test as gate test 2020-09-27 10:46:41 -07:00
Dylan MacKenzie
54d3329c95 Bless tests 2020-09-27 10:46:41 -07:00
Dylan MacKenzie
e2622b915a Update tests with new feature gate 2020-09-27 10:46:41 -07:00
Dylan MacKenzie
3cbd17fcc6 Remove rustc_allow_const_fn_ptr
This was a hack to work around the lack of an escape hatch for the "min
`const fn`" checks in const-stable functions. Now that we have co-opted
`allow_internal_unstable` for this purpose, we no longer need the
bespoke attribute.
2020-09-27 10:46:41 -07:00
Dylan MacKenzie
1ff143191c Add a feature gate for basic function pointer use in const fn 2020-09-27 10:46:41 -07:00
bors
4529af972e 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`
2020-09-27 17:27:26 +00:00
Jonas Schievink
344ab3fb7b
Rollup merge of #77263 - bugadani:cleanup, r=lcnr
Clean up trivial if let
2020-09-27 18:37:29 +02:00
Jonas Schievink
65298ee49c
Rollup merge of #77262 - bugadani:redundant-comment, r=Dylan-DPC
Remove duplicate comment
2020-09-27 18:37:28 +02:00
Jonas Schievink
06677cbcfc
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
2020-09-27 18:37:26 +02:00
Jonas Schievink
e687dac992
Rollup merge of #77252 - tshepang:overlong, r=jyn514
reduce overlong line
2020-09-27 18:37:24 +02:00
Jonas Schievink
2a90d31423
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)
2020-09-27 18:37:23 +02:00
Jonas Schievink
9f086fcb00
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.
2020-09-27 18:37:21 +02:00
Jonas Schievink
ec1766c5b6
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.
2020-09-27 18:37:20 +02:00
bors
1d216fef3e 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.
2020-09-27 15:14:55 +00:00
Joshua Nelson
80ffaed809 Add documentation for private_intra_doc_links 2020-09-27 10:44:41 -04:00
Joshua Nelson
03d8be0896 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.
2020-09-27 09:58:29 -04:00
Bram van den Heuvel
ef7377eb05 Update chalk to 0.29.0 2020-09-27 15:54:07 +02:00
bors
d902752866 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.
2020-09-27 12:51:21 +00:00
bjorn3
71bc62b9f6 Add option to pass a custom codegen backend from a driver 2020-09-27 14:16:42 +02:00
bors
b8363295d5 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.
2020-09-27 10:17:09 +00:00
Dániel Buga
e4200512ff Clean up trivial if let 2020-09-27 11:54:50 +02:00
Dániel Buga
3d4a2e6bb9 Remove duplicate comment 2020-09-27 11:00:46 +02:00
Ralf Jung
3009c5260f update tokei and ripgrep in cargotest 2020-09-27 10:58:42 +02:00