]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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 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 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 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 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 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 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 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 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 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 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 :)

3 years agoMove `is_raw_guess` check in `ty::print::pretty`
marmeladema [Thu, 24 Sep 2020 09:23:01 +0000 (10:23 +0100)]
Move `is_raw_guess` check in `ty::print::pretty`

3 years agoAddress review comment
marmeladema [Wed, 23 Sep 2020 22:38:38 +0000 (23:38 +0100)]
Address review comment

3 years agoFix tests
marmeladema [Mon, 21 Sep 2020 21:19:44 +0000 (22:19 +0100)]
Fix tests

3 years agoRemove now unused `double_braced_*` symbols
marmeladema [Tue, 1 Sep 2020 18:37:12 +0000 (19:37 +0100)]
Remove now unused `double_braced_*` symbols

3 years agoFix profiling query key creation
marmeladema [Tue, 1 Sep 2020 18:34:46 +0000 (19:34 +0100)]
Fix profiling query key creation

3 years agoSimplify some match statements on `DefPathDataName'
marmeladema [Tue, 1 Sep 2020 12:11:28 +0000 (13:11 +0100)]
Simplify some match statements on `DefPathDataName'

3 years agoAvoid calling `Symbol::interner` in `compute_codegen_unit_name`
marmeladema [Tue, 1 Sep 2020 08:31:02 +0000 (09:31 +0100)]
Avoid calling `Symbol::interner` in `compute_codegen_unit_name`

3 years agoRename `DefPathData::get_name()` to `DefPathData::name()`
marmeladema [Mon, 31 Aug 2020 23:42:30 +0000 (00:42 +0100)]
Rename `DefPathData::get_name()` to `DefPathData::name()`

3 years agoFix pretty-printing of `DisambiguatedDefPathData`
marmeladema [Mon, 31 Aug 2020 22:26:15 +0000 (23:26 +0100)]
Fix pretty-printing of `DisambiguatedDefPathData`

3 years agoImplement `Display` for `DisambiguatedDefPathData` and `DefPathData`
marmeladema [Mon, 31 Aug 2020 21:57:48 +0000 (22:57 +0100)]
Implement `Display` for `DisambiguatedDefPathData` and `DefPathData`

3 years agoMove from {{closure}}#0 syntax to {closure#0} for (def) path components
marmeladema [Mon, 31 Aug 2020 17:11:44 +0000 (18:11 +0100)]
Move from {{closure}}#0 syntax to {closure#0} for (def) path components

3 years agoAuto merge of #77201 - matthewjasper:rename-get-unchecked, r=spastorino
bors [Fri, 25 Sep 2020 21:44:26 +0000 (21:44 +0000)]
Auto merge of #77201 - matthewjasper:rename-get-unchecked, r=spastorino

Rename Iterator::get_unchecked

Closes #76479

r? `@pnkfelix`

3 years agoRemove stray word from `ClosureKind::extends` docs
LingMan [Fri, 25 Sep 2020 21:35:07 +0000 (23:35 +0200)]
Remove stray word from `ClosureKind::extends` docs

3 years agoAuto merge of #77198 - jonas-schievink:rollup-i59i41h, r=jonas-schievink
bors [Fri, 25 Sep 2020 19:35:33 +0000 (19:35 +0000)]
Auto merge of #77198 - jonas-schievink:rollup-i59i41h, r=jonas-schievink

Rollup of 15 pull requests

Successful merges:

 - #76932 (Relax promises about condition variable.)
 - #76973 (Unstably allow assume intrinsic in const contexts)
 - #77005 (BtreeMap: refactoring around edges)
 - #77066 (Fix dest prop miscompilation around references)
 - #77073 (dead_code: look at trait impls even if they don't contain items)
 - #77086 (Include libunwind in the rust-src component.)
 - #77097 (Make [].as_[mut_]ptr_range() (unstably) const.)
 - #77106 (clarify that `changelog-seen = 1` goes to the beginning of config.toml)
 - #77120 (Add `--keep-stage-std` to `x.py` for keeping only standard library artifacts)
 - #77126 (Invalidate local LLVM cache less often)
 - #77146 (Install std for non-host targets)
 - #77155 (remove enum name from ImplSource variants)
 - #77176 (Removing erroneous semicolon in transmute documentation)
 - #77183 (Allow multiple allow_internal_unstable attributes)
 - #77189 (Remove extra space from vec drawing)

Failed merges:

r? `@ghost`

3 years agoAdd missing code examples on slice iter types
Guillaume Gomez [Tue, 22 Sep 2020 20:27:18 +0000 (22:27 +0200)]
Add missing code examples on slice iter types

3 years agoRename Iterator::get_unchecked
Matthew Jasper [Fri, 25 Sep 2020 18:48:24 +0000 (19:48 +0100)]
Rename Iterator::get_unchecked

It's possible for method resolution to pick this method over a lower
priority stable method,  causing compilation errors. Since this method
is permanently unstable, give it a name that is very unlikely to be used
in user code.

3 years agoImprove <vec::IntoIter>::get_unchecked` safety comment
Matthew Jasper [Fri, 25 Sep 2020 18:46:06 +0000 (19:46 +0100)]
Improve <vec::IntoIter>::get_unchecked` safety comment

3 years agoRollup merge of #77189 - pickfire:patch-5, r=Mark-Simulacrum
Jonas Schievink [Fri, 25 Sep 2020 17:42:54 +0000 (19:42 +0200)]
Rollup merge of #77189 - pickfire:patch-5, r=Mark-Simulacrum

Remove extra space from vec drawing

3 years agoRollup merge of #77183 - bugadani:issue-77088, r=varkor
Jonas Schievink [Fri, 25 Sep 2020 17:42:52 +0000 (19:42 +0200)]
Rollup merge of #77183 - bugadani:issue-77088, r=varkor

Allow multiple allow_internal_unstable attributes

Fixes #77088

3 years agoRollup merge of #77176 - austinkeeley:intrinsics-documentatation-error, r=jyn514
Jonas Schievink [Fri, 25 Sep 2020 17:42:50 +0000 (19:42 +0200)]
Rollup merge of #77176 - austinkeeley:intrinsics-documentatation-error, r=jyn514

Removing erroneous semicolon in transmute documentation

There is a semicolon in the example code that causes the expected value to not be returned.

3 years agoRollup merge of #77155 - lcnr:ImplSource, r=ecstatic-morse
Jonas Schievink [Fri, 25 Sep 2020 17:42:48 +0000 (19:42 +0200)]
Rollup merge of #77155 - lcnr:ImplSource, r=ecstatic-morse

remove enum name from ImplSource variants

This is quite a lot cleaner in my opinion.

3 years agoRollup merge of #77146 - Mark-Simulacrum:xpyinstall, r=alexcrichton
Jonas Schievink [Fri, 25 Sep 2020 17:42:46 +0000 (19:42 +0200)]
Rollup merge of #77146 - Mark-Simulacrum:xpyinstall, r=alexcrichton

Install std for non-host targets

It seems reasonable that when configuring various targets you'd expect all of them to get std installed, even if you're not building compiler toolchains for each of those.

cc #76990

r? @alexcrichton

3 years agoRollup merge of #77126 - Mark-Simulacrum:llvm-less-often, r=alexcrichton
Jonas Schievink [Fri, 25 Sep 2020 17:42:44 +0000 (19:42 +0200)]
Rollup merge of #77126 - Mark-Simulacrum:llvm-less-often, r=alexcrichton

Invalidate local LLVM cache less often

This avoids a download of LLVM after every rebase. The downside to this is that if we land some patch affecting LLVM built in CI that breaks this option, but that PR does not update the LLVM submodule, we'll likely not notice until the next update -- but this seems unlikely to happen in practice and I am not personally worried about it.

r? @alexcrichton

3 years agoRollup merge of #77120 - ecstatic-morse:keep-stage-std, r=Mark-Simulacrum
Jonas Schievink [Fri, 25 Sep 2020 17:42:43 +0000 (19:42 +0200)]
Rollup merge of #77120 - ecstatic-morse:keep-stage-std, r=Mark-Simulacrum

Add `--keep-stage-std` to `x.py` for keeping only standard library artifacts

Unlike `--keep-stage 0`, `--keep-stage-std 0` will allow the stage 0 compiler artifacts (i.e., stage1/bin/rustc) to be rebuilt if it has changed. This allows contributors to iterate on later stages of the compiler in tandem with the standard library without needing to to rebuild the entire compiler. I often run into this when working on const-checking, since I may need to add a feature gate or make a small tweak to the standard library.

3 years agoRollup merge of #77106 - matthiaskrgr:changelog_seen, r=Mark-Simulacrum
Jonas Schievink [Fri, 25 Sep 2020 17:42:41 +0000 (19:42 +0200)]
Rollup merge of #77106 - matthiaskrgr:changelog_seen, r=Mark-Simulacrum

clarify that `changelog-seen = 1` goes to the beginning of config.toml

Fixes #77105

3 years agoRollup merge of #77097 - fusion-engineering-forks:slice-ptr-range-const-fn, r=oli-obk
Jonas Schievink [Fri, 25 Sep 2020 17:42:39 +0000 (19:42 +0200)]
Rollup merge of #77097 - fusion-engineering-forks:slice-ptr-range-const-fn, r=oli-obk

Make [].as_[mut_]ptr_range() (unstably) const.

Gated behind `const_ptr_offset`, as suggested by https://github.com/rust-lang/rust/issues/65807#issuecomment-697229404

This also marks `[].as_mut_ptr()` as const, because it's used by `as_mut_ptr_range`. I gated it behind the same feature, because I figured it's not worth adding a separate tracking issue for const `as_mut_ptr`.

3 years agoRollup merge of #77086 - ehuss:src-libunwind, r=Mark-Simulacrum
Jonas Schievink [Fri, 25 Sep 2020 17:42:37 +0000 (19:42 +0200)]
Rollup merge of #77086 - ehuss:src-libunwind, r=Mark-Simulacrum

Include libunwind in the rust-src component.

Some targets, such as musl, need the libunwind source to build the unwind crate (referenced [here](https://github.com/rust-lang/rust/blob/0da58007451a154da2480160429e1604a1f5f0ec/library/unwind/build.rs#L142)).

Fixes rust-lang/wg-cargo-std-aware#59

3 years agoRollup merge of #77073 - lcnr:ty-trait-param, r=matthewjasper
Jonas Schievink [Fri, 25 Sep 2020 17:42:35 +0000 (19:42 +0200)]
Rollup merge of #77073 - lcnr:ty-trait-param, r=matthewjasper

dead_code: look at trait impls even if they don't contain items

fixes #70225

3 years agoRollup merge of #77066 - jonas-schievink:dest-prop-borrow, r=oli-obk
Jonas Schievink [Fri, 25 Sep 2020 17:42:33 +0000 (19:42 +0200)]
Rollup merge of #77066 - jonas-schievink:dest-prop-borrow, r=oli-obk

Fix dest prop miscompilation around references

Closes https://github.com/rust-lang/rust/issues/77002

3 years agoRollup merge of #77005 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
Jonas Schievink [Fri, 25 Sep 2020 17:42:31 +0000 (19:42 +0200)]
Rollup merge of #77005 - ssomers:btree_cleanup_3, r=Mark-Simulacrum

BtreeMap: refactoring around edges

Parts chipped off a more daring effort, that the btree benchmarks judge to be performance-neutral.

r? @Mark-Simulacrum

3 years agoRollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obk
Jonas Schievink [Fri, 25 Sep 2020 17:42:29 +0000 (19:42 +0200)]
Rollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obk

Unstably allow assume intrinsic in const contexts

Not sure much about this usage because there are concerns
about [blocking  optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic
in inline functions.
But since Oli suggested in https://github.com/rust-lang/rust/issues/76960#issuecomment-695772221,
here we are.

[1]: https://github.com/rust-lang/rust/pull/54995#issuecomment-429302709
[2]: https://github.com/rust-lang/rust/issues/49572#issuecomment-589615423

3 years agoRollup merge of #76932 - fusion-engineering-forks:condvar-promise, r=sfackler
Jonas Schievink [Fri, 25 Sep 2020 17:42:28 +0000 (19:42 +0200)]
Rollup merge of #76932 - fusion-engineering-forks:condvar-promise, r=sfackler

Relax promises about condition variable.

For quite a while now, there have been plans to at some point use parking_lot or some other more efficient implementation of mutexes and condition variables. Right now, Mutex and CondVar both Box the 'real' mutex/condvar inside, to give it a stable address. This was done because implementations like pthread and Windows critical sections may not be moved. More efficient implementations based on futexes, WaitOnAddress, Windows SRW locks, parking_lot, etc. may be moved (while not borrowed), so wouldn't need boxing.

However, not boxing them (which would be great goal to achieve), breaks a promise std currently makes about CondVar. CondVar promises to panic when used with different mutexes, to ensure consistent behaviour on all platforms. To this check, a mutex is considered 'the same' if the address of the 'real mutex' in the Box is the same. This address doesn't change when moving a `std::mutex::Mutex` object, effectively giving it an identity that survives moves of the Mutex object. If we ever switch to a non-boxed version, they no longer carry such an identity, and this check can no longer be made.

Four options:
1. Always box mutexes.
2. Add a `MutexId` similar to `ThreadId`. Making mutexes bigger, and making it hard to ever have a `const fn new` for them.
3. Making the requirement of CondVar stricter: panic if the Mutex object itself moved.
4. Making the promise of CondVar weaker: don't promise to panic.

1, 2, and 3 seem like bad options. This PR updates the documentation for 4.

3 years agoUse proper issue for `const_fn_floating_point_arithmetic`
Dylan MacKenzie [Wed, 23 Sep 2020 20:08:20 +0000 (13:08 -0700)]
Use proper issue for `const_fn_floating_point_arithmetic`

3 years agoMove const fn floating point test out of `min_const_fn`
Dylan MacKenzie [Wed, 23 Sep 2020 19:38:21 +0000 (12:38 -0700)]
Move const fn floating point test out of `min_const_fn`

3 years agoBless tests
Dylan MacKenzie [Wed, 23 Sep 2020 18:58:41 +0000 (11:58 -0700)]
Bless tests

3 years agoAdd new feature gate to standard library
Dylan MacKenzie [Wed, 23 Sep 2020 18:58:22 +0000 (11:58 -0700)]
Add new feature gate to standard library

3 years agoPut floating point arithmetic behind its own feature gate
Dylan MacKenzie [Wed, 23 Sep 2020 18:54:11 +0000 (11:54 -0700)]
Put floating point arithmetic behind its own feature gate

This refactors handling of `Rvalue::{Unary,Binary}Op` in the
const-checker. Now we `span_bug` if there's an unexpected type in a
primitive operation. This also allows unary negation on
`char` values through the const-checker because it makes the code a bit
cleaner. `char` does not actually support these operations, and if it
did, we could evaluate them at compile-time.

3 years agoAdd `const_fn_floating_point_arithmetic`
Dylan MacKenzie [Wed, 23 Sep 2020 18:53:58 +0000 (11:53 -0700)]
Add `const_fn_floating_point_arithmetic`

3 years agoAuto merge of #77157 - tmiasko:simplify-cfg-dup, r=jonas-schievink
bors [Fri, 25 Sep 2020 17:27:52 +0000 (17:27 +0000)]
Auto merge of #77157 - tmiasko:simplify-cfg-dup, r=jonas-schievink

Remove duplicated SimplifyCfg pass

3 years agoRemove extra space from vec drawing
Ivan Tham [Fri, 25 Sep 2020 15:20:22 +0000 (23:20 +0800)]
Remove extra space from vec drawing

3 years agoAuto merge of #73453 - erikdesjardins:tuplayout, r=eddyb
bors [Fri, 25 Sep 2020 14:42:20 +0000 (14:42 +0000)]
Auto merge of #73453 - erikdesjardins:tuplayout, r=eddyb

Ignore ZST offsets when deciding whether to use Scalar/ScalarPair layout

This is important because Scalar/ScalarPair layout previously would not be used if any ZST had nonzero offset.
For example, before this change, only `((), u128)` would be laid out like `u128`, not `(u128, ())`.

Fixes #63244

3 years agoRust vec bench import specific rand::RngCore
Ivan Tham [Fri, 25 Sep 2020 14:19:28 +0000 (22:19 +0800)]
Rust vec bench import specific rand::RngCore

3 years agoAllow multiple allow_internal_unstable attributes
Dániel Buga [Fri, 25 Sep 2020 12:40:16 +0000 (14:40 +0200)]
Allow multiple allow_internal_unstable attributes

Co-authored-by: varkor <github@varkor.com>
3 years agoAuto merge of #77152 - vandenheuvel:update_chalk_further, r=jackh726
bors [Fri, 25 Sep 2020 12:22:05 +0000 (12:22 +0000)]
Auto merge of #77152 - vandenheuvel:update_chalk_further, r=jackh726

Update chalk to 0.28.0

3 years agoLink dynamic and static late_link_args before generic ones
Mateusz Mikuła [Fri, 25 Sep 2020 11:33:25 +0000 (13:33 +0200)]
Link dynamic and static late_link_args before generic ones

3 years agoAuto merge of #77041 - lcnr:const-eval-perf, r=ecstatic-morse
bors [Fri, 25 Sep 2020 10:14:47 +0000 (10:14 +0000)]
Auto merge of #77041 - lcnr:const-eval-perf, r=ecstatic-morse

perf: move cold path of `process_obligations` into a separate function

cc #76575

This probably won't matter too much in the long run once #69218 is merged so we may not want to merge this.

r? `@ecstatic-morse`

3 years agoBTreeMap: various tweaks
Stein Somers [Sun, 9 Aug 2020 10:25:20 +0000 (12:25 +0200)]
BTreeMap: various tweaks

3 years agoBTreeMap: introduce edge methods similar to those of keys and values
Stein Somers [Sun, 9 Aug 2020 10:25:20 +0000 (12:25 +0200)]
BTreeMap: introduce edge methods similar to those of keys and values