]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoCorrect typo
nhamovitz [Sat, 16 Oct 2021 20:36:05 +0000 (13:36 -0700)]
Correct typo

2 years agoRemove FIXME since there is nothing to be fixed.
Guillaume Gomez [Fri, 15 Oct 2021 19:37:31 +0000 (21:37 +0200)]
Remove FIXME since there is nothing to be fixed.

The errors are deduplicated when displayed to users. They only appear
multiple times in UI tests.

2 years agoSuggest a case insensitive match name regardless of levenshtein distance
Yuki Okushi [Sat, 16 Oct 2021 19:51:22 +0000 (04:51 +0900)]
Suggest a case insensitive match name regardless of levenshtein distance

2 years agoAuto merge of #89860 - camsteffen:macro-semi, r=petrochenkov
bors [Sat, 16 Oct 2021 18:20:20 +0000 (18:20 +0000)]
Auto merge of #89860 - camsteffen:macro-semi, r=petrochenkov

Remove trailing semicolon from macro call span

Macro call site spans are now less surprising/more consistent since they no longer contain a semicolon after the macro call.

The downside is that we need to do a little guesswork to get the semicolon in diagnostics. But this should not be noticeable since it is rare for the semicolon to not immediately follow the macro call.

2 years agoclippy::complexity changes
Matthias Krüger [Sat, 16 Oct 2021 08:18:17 +0000 (10:18 +0200)]
clippy::complexity changes

2 years agoAdd `#![cfg_attr(bootstrap, feature(const_panic))]` to `library/core/tests/lib.rs`
woppopo [Sat, 16 Oct 2021 15:32:01 +0000 (00:32 +0900)]
Add `#![cfg_attr(bootstrap, feature(const_panic))]` to `library/core/tests/lib.rs`

2 years agoMake Option::as_mut const
woppopo [Sat, 16 Oct 2021 15:02:42 +0000 (00:02 +0900)]
Make Option::as_mut const

2 years agobootstrap: tweak verbosity settings
Ximin Luo [Sat, 16 Oct 2021 12:30:24 +0000 (13:30 +0100)]
bootstrap: tweak verbosity settings

Currently the verbosity settings are:
- 2: RUSTC-SHIM envvars get spammed on every invocation, O(30) lines
     cargo is passed -v which outputs CLI invocations, O(5) lines
- 3: cargo is passed -vv which outputs build script output, O(0-10) lines

This commit changes it to:

- 1: cargo is passed -v, O(5) lines
- 2: cargo is passed -vv, O(10) lines
- 3: RUSTC-SHIM envvars get spammed, O(30) lines

2 years agoFix an ICE with TAITs and Future
Yuki Okushi [Sat, 16 Oct 2021 09:30:37 +0000 (18:30 +0900)]
Fix an ICE with TAITs and Future

2 years agoRemove a mention to `copy_from_slice` from `clone_from_slice` doc
Yuki Okushi [Sat, 16 Oct 2021 08:30:34 +0000 (17:30 +0900)]
Remove a mention to `copy_from_slice` from `clone_from_slice` doc

2 years agoremove compiler warnings
Stefan Lankes [Sat, 16 Oct 2021 07:45:05 +0000 (09:45 +0200)]
remove compiler warnings

2 years agoHermitCore's kernel itself doesn't support TLS
Stefan Lankes [Sat, 16 Oct 2021 07:41:59 +0000 (09:41 +0200)]
HermitCore's kernel itself doesn't support TLS

HermitCore's kernel itself doesn't support TLS.
Consequently, the entries in x86_64-unknown-none-hermitkernel should be removed.
This commit should help to finalize #89062.

2 years agoAuto merge of #89939 - matthiaskrgr:rollup-q3lrdck, r=matthiaskrgr
bors [Sat, 16 Oct 2021 06:31:40 +0000 (06:31 +0000)]
Auto merge of #89939 - matthiaskrgr:rollup-q3lrdck, r=matthiaskrgr

Rollup of 10 pull requests

Successful merges:

 - #89509 (Stabilize `unreachable_unchecked` as `const fn`)
 - #89898 (Remove alloc::prelude)
 - #89902 (Restrict the aarch64 outline atomics test to Linux)
 - #89906 (Moved format-version constant to rustdoc-json-types)
 - #89912 (emitter: current substitution can be multi-line)
 - #89914 (Emit impl difference error for GenericBoundFailure too)
 - #89915 (Some outlives cleanup)
 - #89918 (Add some GATs related regression tests)
 - #89921 ([fuchsia] Update process info struct)
 - #89925 (updating docs to mention usage of AtomicBool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #89925 - gilescope:update-docs-atomic-usage, r=m-ou-se
Matthias Krüger [Sat, 16 Oct 2021 06:02:28 +0000 (08:02 +0200)]
Rollup merge of #89925 - gilescope:update-docs-atomic-usage, r=m-ou-se

updating docs to mention usage of AtomicBool

Mouse mentioned we should point out that atomic bool is used by the std lib these days. ( https://github.com/m-ou-se/getrandom/pull/1 )

2 years agoRollup merge of #89921 - joshuaseaton:zircon-process, r=tmandry
Matthias Krüger [Sat, 16 Oct 2021 06:02:27 +0000 (08:02 +0200)]
Rollup merge of #89921 - joshuaseaton:zircon-process, r=tmandry

[fuchsia] Update process info struct

The fuchsia platform is in the process of softly transitioning over to
using a new value for ZX_INFO_PROCESS with a new corresponding struct.
This change migrates libstd.

See [fxrev.dev/510478](https://fxrev.dev/510478) and [fxbug.dev/30751](https://fxbug.dev/30751) for more detail.

2 years agoRollup merge of #89918 - JohnTitor:gats-tests, r=jackh726
Matthias Krüger [Sat, 16 Oct 2021 06:02:26 +0000 (08:02 +0200)]
Rollup merge of #89918 - JohnTitor:gats-tests, r=jackh726

Add some GATs related regression tests

Closes #88287, closes #88405

2 years agoRollup merge of #89915 - jackh726:outlives_cleanup, r=nikomatsakis
Matthias Krüger [Sat, 16 Oct 2021 06:02:25 +0000 (08:02 +0200)]
Rollup merge of #89915 - jackh726:outlives_cleanup, r=nikomatsakis

Some outlives cleanup

No semantic changes here, only moving code around + using `LocalDefId` instead of `HirId`

r? ````@nikomatsakis````

2 years agoRollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank
Matthias Krüger [Sat, 16 Oct 2021 06:02:24 +0000 (08:02 +0200)]
Rollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank

Emit impl difference error for GenericBoundFailure too

Fixes #86787

r? ````@estebank````

2 years agoRollup merge of #89912 - davidtwco:issue-89280-split-lines-multiple-lines, r=oli-obk
Matthias Krüger [Sat, 16 Oct 2021 06:02:24 +0000 (08:02 +0200)]
Rollup merge of #89912 - davidtwco:issue-89280-split-lines-multiple-lines, r=oli-obk

emitter: current substitution can be multi-line

Fixes #89280.

In `splice_lines`, there is some arithmetic to compute the required alignment such that future substitutions in a suggestion are aligned correctly. However, this assumed that the current substitution's span was only on a single line. In circumstances where this was not true, it could result in a arithmetic overflow when the substitution's end column was less than the substitution's start column.

r? ````@oli-obk````

2 years agoRollup merge of #89906 - yuvaldolev:move-format-version-to-rustdoc-json-types, r...
Matthias Krüger [Sat, 16 Oct 2021 06:02:23 +0000 (08:02 +0200)]
Rollup merge of #89906 - yuvaldolev:move-format-version-to-rustdoc-json-types, r=CraftSpider

Moved format-version constant to rustdoc-json-types

Addresses #88620

Moved format-version constant from rustdoc to rustdoc-json-types.

2 years agoRollup merge of #89902 - rusticstuff:outline-atomics-linux-only, r=workingjubilee
Matthias Krüger [Sat, 16 Oct 2021 06:02:22 +0000 (08:02 +0200)]
Rollup merge of #89902 - rusticstuff:outline-atomics-linux-only, r=workingjubilee

Restrict the aarch64 outline atomics test to Linux

The test was introduced in #83655, which enables the `outline-atomics` feature for aarch64-unknown-linux-* but not for any other aarch64 targets. The test did not check for Linux causing test failures on aarch64-apple-darwin.

r? `@workingjubilee`

2 years agoRollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett
Matthias Krüger [Sat, 16 Oct 2021 06:02:21 +0000 (08:02 +0200)]
Rollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett

Remove alloc::prelude

As per the libs team decision in #58935.

Closes #58935

2 years agoRollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk
Matthias Krüger [Sat, 16 Oct 2021 06:02:20 +0000 (08:02 +0200)]
Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk

Stabilize `unreachable_unchecked` as `const fn`

Closes #53188

This PR stabilizes `core::hint::unreachable_unchecked` as `const fn`. MIRI is able to detect when this method is called. Stabilization was delayed until `const_panic` was stabilized so as to avoid users calling this method in its place (thus resulting in runtime UB). With #89508, that is no longer an issue.

````@rustbot```` label +A-const-eval +A-const-fn +T-lang +S-blocked

(not sure why it's T-lang, but that's what the tracking issue is)

2 years agoUpdate the syn crate and adopt let_else in three more places
est31 [Sat, 16 Oct 2021 02:37:30 +0000 (04:37 +0200)]
Update the syn crate and adopt let_else in three more places

The syn crate has gained support for let_else syntax in version 1.0.76,
see https://github.com/dtolnay/syn/pull/1057 .

In the three instances that use let_else, we've sent code through an
attr macro, which would create compile errors when there was no
let_else support in syn. To avoid this, we ran
`cargo +nightly update -p syn` for updating the syn crate.

2 years agoAdopt let_else across the compiler
est31 [Sat, 16 Oct 2021 01:45:14 +0000 (03:45 +0200)]
Adopt let_else across the compiler

This performs a substitution of code following the pattern:

let <id> = if let <pat> = ... { identity } else { ... : ! };

To simplify it to:

let <pat> = ... { identity } else { ... : ! };

By adopting the let_else feature.

2 years agoAuto merge of #85379 - mdaverde:uds-abstract, r=joshtriplett
bors [Fri, 15 Oct 2021 22:31:53 +0000 (22:31 +0000)]
Auto merge of #85379 - mdaverde:uds-abstract, r=joshtriplett

Add abstract namespace support for Unix domain sockets

Hello! The other day I wanted to mess around with UDS in Rust and found that abstract namespaces ([unix(7)](https://man7.org/linux/man-pages/man7/unix.7.html)) on Linux still needed development. I took the approach of adding `_addr` specific public functions to reduce conflicts.

Feature name: `unix_socket_abstract`
Tracking issue: #85410
Further context: #42048

## Non-platform specific additions

`UnixListener::bind_addr(&SocketAddr) -> Result<UnixListener>`

`UnixStream::connect_addr(&SocketAddr) -> Result<()>`

`UnixDatagram::bind_addr(&SocketAddr) -> Result<UnixDatagram>`

`UnixDatagram::connect_addr(&SocketAddr) -> Result<()>`

`UnixDatagram::send_to_addr(&self, &[u8], &SocketAddr) -> Result<usize>`

## Platform-specific (Linux) additions

`SocketAddr::from_abstract_namespace(&[u8]) -> SocketAddr`

`SockerAddr::as_abstract_namespace() -> Option<&[u8]>`

## Example

```rust
#![feature(unix_socket_abstract)]
use std::os::unix::net::{UnixListener, SocketAddr};

fn main() -> std::io::Result<()> {
    let addr = SocketAddr::from_abstract_namespace(b"namespace")?; // Linux only
    let listener = match UnixListener::bind_addr(&addr) {
        Ok(sock) => sock,
        Err(err) => {
            println!("Couldn't bind: {:?}", err);
            return Err(err);
        }
    };
    Ok(())
}
```

## Further Details

The main inspiration for the implementation came from the [nix-rust](https://github.com/nix-rust/nix/blob/master/src/sys/socket/addr.rs#L558) crate but there are also other [historical](https://github.com/rust-lang/rust/commit/c4db0685b181f12c4285dac3d932f1859bba74f5) [attempts](https://github.com/tormol/uds/blob/master/src/addr.rs#L324) with similar approaches.

A comment I did have was with this change, we now allow a `SocketAddr` to be constructed explicitly rather than just used almost as a handle for the return of `peer_addr` and `local_addr`. We could consider adding other explicit constructors (e.g. `SocketAddr::from_pathname`, `SockerAddr::from_unnamed`).

Cheers!

2 years agoupdating docs to reflect current situation
Giles Cope [Fri, 15 Oct 2021 19:43:52 +0000 (20:43 +0100)]
updating docs to reflect current situation

2 years agoAuto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay
bors [Fri, 15 Oct 2021 19:03:57 +0000 (19:03 +0000)]
Auto merge of #84096 - m-ou-se:windows-bcrypt-random, r=dtolnay

Use BCryptGenRandom instead of RtlGenRandom on Windows.

This removes usage of RtlGenRandom on Windows, in favour of BCryptGenRandom.

BCryptGenRandom isn't available on XP, but we dropped XP support a while ago.

2 years agoDocument the new logic
Oli Scherer [Fri, 24 Sep 2021 17:48:06 +0000 (17:48 +0000)]
Document the new logic

2 years agoRemove a now-unused trait
Oli Scherer [Fri, 24 Sep 2021 17:44:32 +0000 (17:44 +0000)]
Remove a now-unused trait

2 years agoEquality of regions is not just on identity, but if both regions outlive each other
Oli Scherer [Fri, 24 Sep 2021 17:32:58 +0000 (17:32 +0000)]
Equality of regions is not just on identity, but if both regions outlive each other

2 years agoNormalize regions before comparing them for member constraints
Oli Scherer [Fri, 24 Sep 2021 17:32:30 +0000 (17:32 +0000)]
Normalize regions before comparing them for member constraints

2 years agoAdd some more instrumentation
Oli Scherer [Fri, 24 Sep 2021 17:31:32 +0000 (17:31 +0000)]
Add some more instrumentation

2 years agoRemove a now-unused struct
Oli Scherer [Fri, 24 Sep 2021 17:30:01 +0000 (17:30 +0000)]
Remove a now-unused struct

2 years agosimplify constrain_opaque_types
Niko Matsakis [Thu, 23 Sep 2021 15:21:01 +0000 (11:21 -0400)]
simplify constrain_opaque_types

2 years ago[fuchsia] Update process info struct
Joshua Seaton [Fri, 15 Oct 2021 17:24:52 +0000 (10:24 -0700)]
[fuchsia] Update process info struct

The fuchsia platform is in the process of softly transitioning over to
using a new value for ZX_INFO_PROCESS with a new corresponding struct.
This change migrates libstd.

See fxrev.dev/510478 and fxbug.dev/30751 for more detail.

2 years agoAdd some GATs related regression tests
Yuki Okushi [Fri, 15 Oct 2021 16:38:49 +0000 (01:38 +0900)]
Add some GATs related regression tests

2 years agoMove some outlives bounds things from rustc_trait_selection to rustc_typeck
jackh726 [Fri, 15 Oct 2021 15:31:22 +0000 (11:31 -0400)]
Move some outlives bounds things from rustc_trait_selection to rustc_typeck

2 years agoUse LocalDefId directly in more places in wfcheck
jackh726 [Thu, 14 Oct 2021 02:22:09 +0000 (22:22 -0400)]
Use LocalDefId directly in more places in wfcheck

2 years agoMove push_outlives_components to rustc_infer
jackh726 [Sat, 9 Oct 2021 02:55:06 +0000 (22:55 -0400)]
Move push_outlives_components to rustc_infer

2 years agoAuto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se
bors [Fri, 15 Oct 2021 15:55:08 +0000 (15:55 +0000)]
Auto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se

Avoid allocations and copying in Vec::leak

The [`Vec::leak`] method (#62195) is currently implemented by calling `Vec::into_boxed_slice` and `Box::leak`.  This shrinks the vector before leaking it, which potentially causes a reallocation and copies the vector's contents.

By avoiding the conversion to `Box`, we can instead leak the vector without any expensive operations, just by returning a slice reference and forgetting the `Vec`.  Users who *want* to shrink the vector first can still do so by calling `shrink_to_fit` explicitly.

**Note:**  This could break code that uses `Box::from_raw` to “un-leak” the slice returned by `Vec::leak`.  However, the `Vec::leak` docs explicitly forbid this, so such code is already incorrect.

[`Vec::leak`]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.leak

2 years agoEmit impl difference error for GenericBoundFailure too
jackh726 [Tue, 5 Oct 2021 21:43:45 +0000 (17:43 -0400)]
Emit impl difference error for GenericBoundFailure too

2 years agoemitter: current substitution can be multi-line
David Wood [Fri, 15 Oct 2021 14:48:57 +0000 (14:48 +0000)]
emitter: current substitution can be multi-line

In `splice_lines`, there is some arithmetic to compute the required
alignment such that future substitutions in a suggestion are aligned
correctly. However, this assumed that the current substitution's span
was only on a single line. In circumstances where this was not true, it
could result in a arithmetic overflow when the substitution's end
column was less than the substitution's start column.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoRework the equivalent test to work with sidebar-items.js
Loïc BRANSTETT [Fri, 15 Oct 2021 14:54:31 +0000 (16:54 +0200)]
Rework the equivalent test to work with sidebar-items.js

2 years agoAuto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se
bors [Fri, 15 Oct 2021 12:51:31 +0000 (12:51 +0000)]
Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se

Optimize VecDeque::append

Optimize `VecDeque::append` to do unsafe copy rather than iterating through each element.

On my `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz`, the benchmark shows 37% improvements:
```
Master:
custom-bench vec_deque_append 583164 ns/iter
custom-bench vec_deque_append 550040 ns/iter

Patched:
custom-bench vec_deque_append 349204 ns/iter
custom-bench vec_deque_append 368164 ns/iter
```

Additional notes on the context: this is the third attempt to implement a non-trivial version of `VecDeque::append`, the last two are reverted due to unsoundness or regression, see:
- https://github.com/rust-lang/rust/pull/52553, reverted in https://github.com/rust-lang/rust/pull/53571
- https://github.com/rust-lang/rust/pull/53564, reverted in https://github.com/rust-lang/rust/pull/54851

Both cases are covered by existing tests.

Signed-off-by: tabokie <xy.tao@outlook.com>
2 years agoAdd missing bcrypt.lib to make-fulldeps Makefile.
Mara Bos [Fri, 15 Oct 2021 11:25:39 +0000 (13:25 +0200)]
Add missing bcrypt.lib to make-fulldeps Makefile.

2 years agoUse BCryptGenRandom instead of RtlGenRandom on Windows.
Mara Bos [Sun, 11 Apr 2021 12:55:47 +0000 (14:55 +0200)]
Use BCryptGenRandom instead of RtlGenRandom on Windows.

BCryptGenRandom isn't available on XP, but we dropped XP support a while
ago.

2 years agoAdd equivalent test in src/test/rustdoc
Loïc BRANSTETT [Fri, 15 Oct 2021 10:56:47 +0000 (12:56 +0200)]
Add equivalent test in src/test/rustdoc

2 years agoApply documentation suggestions from code review
Urgau [Fri, 15 Oct 2021 10:21:25 +0000 (12:21 +0200)]
Apply documentation suggestions from code review

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2 years agoAuto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm
bors [Fri, 15 Oct 2021 09:35:45 +0000 (09:35 +0000)]
Auto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm

add `slice::swap_unchecked`

An unsafe version of `slice::swap` that does not do bounds checking.

2 years agoRevert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov"
Matthias Krüger [Fri, 15 Oct 2021 09:24:20 +0000 (11:24 +0200)]
Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov"

The PR had some unforseen perf regressions that are not as easy to find.
Revert the PR for now.

This reverts commit 6ae8912a3e7d2c4c775024f58a7ba4b1aedc4073, reversing
changes made to 86d6d2b7389fe1b339402c1798edae8b695fc9ef.

2 years agoMoved format-version constant to rustdoc-json-types
Yuval Dolev [Fri, 15 Oct 2021 09:27:42 +0000 (12:27 +0300)]
Moved format-version constant to rustdoc-json-types

2 years agoFix clippy with changed macro statement spans
Cameron Steffen [Thu, 14 Oct 2021 18:28:30 +0000 (13:28 -0500)]
Fix clippy with changed macro statement spans

2 years agoBless tests
Cameron Steffen [Thu, 14 Oct 2021 18:28:28 +0000 (13:28 -0500)]
Bless tests

2 years agoGuess semicolon span for macro statements
Cameron Steffen [Thu, 14 Oct 2021 18:28:25 +0000 (13:28 -0500)]
Guess semicolon span for macro statements

2 years agoRemove trailing semicolon from macro call span
Cameron Steffen [Wed, 13 Oct 2021 18:58:19 +0000 (13:58 -0500)]
Remove trailing semicolon from macro call span

2 years agoRemove redundant matching
Cameron Steffen [Wed, 13 Oct 2021 19:45:35 +0000 (14:45 -0500)]
Remove redundant matching

2 years agoAuto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
bors [Fri, 15 Oct 2021 05:59:49 +0000 (05:59 +0000)]
Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #86011 (move implicit `Sized` predicate to end of list)
 - #89821 (Add a strange test for `unsafe_code` lint.)
 - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant)
 - #89870 (Suggest Box::pin when Pin::new is used instead)
 - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.)
 - #89885 (add long explanation for E0183)
 - #89894 (Remove unused dependencies from rustc_const_eval)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoMake `rust.download-ci-llvm="if-available"` work for tier 2 platforms.
Hans Kratz [Thu, 14 Oct 2021 17:37:26 +0000 (19:37 +0200)]
Make `rust.download-ci-llvm="if-available"` work for tier 2 platforms.

2 years agoRollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum
Matthias Krüger [Fri, 15 Oct 2021 05:44:50 +0000 (07:44 +0200)]
Rollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum

Remove unused dependencies from rustc_const_eval

2 years agoRollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez
Matthias Krüger [Fri, 15 Oct 2021 05:44:49 +0000 (07:44 +0200)]
Rollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez

add long explanation for E0183

Addresses #61137

2 years agoRollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu
Matthias Krüger [Fri, 15 Oct 2021 05:44:48 +0000 (07:44 +0200)]
Rollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu

Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than 12 bits - hence we wouldn't ever need the upper 12 bits.

It's unlikely to ever fail in this small test but this is technically correct.

This was noticed incidentally when we found that LLD doesn't support the `tprel_lo12` relocation, even though LLVM can apparently generate it when using `-mtls-size=12`.

2 years agoRollup merge of #89870 - tmandry:box-pin, r=estebank
Matthias Krüger [Fri, 15 Oct 2021 05:44:47 +0000 (07:44 +0200)]
Rollup merge of #89870 - tmandry:box-pin, r=estebank

Suggest Box::pin when Pin::new is used instead

This fixes an incorrect diagnostic.

**Based on #89390**; only the last commit is specific to this PR. "Ignore whitespace changes" also helps here.

2 years agoRollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk
Matthias Krüger [Fri, 15 Oct 2021 05:44:47 +0000 (07:44 +0200)]
Rollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk

add dedicated error variant for writing the discriminant of an uninhabited enum variant

This is conceptually different from hitting an `Unreachable` terminator. Also add some sanity check making sure we don't write discriminants of things that do not have discriminants.

r? ``@oli-obk``

2 years agoRollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum
Matthias Krüger [Fri, 15 Oct 2021 05:44:45 +0000 (07:44 +0200)]
Rollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum

Add a strange test for `unsafe_code` lint.

The current behavior is a little surprising to me. I'm not sure whether people would change it, but at least let me document the current behavior with a test.

I learnt about this from the [totally-speedy-transmute](https://docs.rs/totally-speedy-transmute) crate.

cc #10599 the original implementation pr.

2 years agoRollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank
Matthias Krüger [Fri, 15 Oct 2021 05:44:44 +0000 (07:44 +0200)]
Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank

move implicit `Sized` predicate to end of list

In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.

Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?

2 years agotest fix: aarch64 atomics are only outlined on Linux.
Hans Kratz [Fri, 15 Oct 2021 04:19:08 +0000 (06:19 +0200)]
test fix: aarch64 atomics are only outlined on Linux.

2 years agoAuto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser
bors [Fri, 15 Oct 2021 02:55:58 +0000 (02:55 +0000)]
Auto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser

Revert enum discriminants

Reverts stabilization of arbitrary enum discriminants per https://github.com/rust-lang/rust/issues/88621#issuecomment-929482371.

Reopens #60553.

2 years agoRemove alloc::prelude
Amanieu d'Antras [Thu, 14 Oct 2021 23:41:31 +0000 (01:41 +0200)]
Remove alloc::prelude

As per the libs team decision in #58935.

Closes #58935

2 years agoDocument structs.
Camille GILLOT [Fri, 24 Sep 2021 19:15:59 +0000 (21:15 +0200)]
Document structs.

2 years agoRemove unused dependencies from rustc_const_eval
Cameron Steffen [Thu, 7 Oct 2021 18:18:41 +0000 (13:18 -0500)]
Remove unused dependencies from rustc_const_eval

2 years agoAllow to hash HIR for coverage.
Camille GILLOT [Thu, 14 Oct 2021 20:24:43 +0000 (22:24 +0200)]
Allow to hash HIR for coverage.

2 years agoSwitch to clang v13 as the C/C++ compiler used for bootstrap
Mark Rousskov [Thu, 14 Oct 2021 19:20:52 +0000 (15:20 -0400)]
Switch to clang v13 as the C/C++ compiler used for bootstrap

2 years agoMove LLVM profiling to a separate phase of compilation
Mark Rousskov [Thu, 14 Oct 2021 14:19:03 +0000 (10:19 -0400)]
Move LLVM profiling to a separate phase of compilation

2 years agoAdd a test for `unsafe_code` lint.
Charles Lew [Tue, 12 Oct 2021 14:34:53 +0000 (22:34 +0800)]
Add a test for `unsafe_code` lint.

2 years agoUpdate the wasi-libc built with the wasm32-wasi target
Alex Crichton [Thu, 14 Oct 2021 17:12:15 +0000 (10:12 -0700)]
Update the wasi-libc built with the wasm32-wasi target

This commit updates the wasi-libc that we include with the wasm32-wasi
target, which brings in various misc fixes such as musl updates and some
math tweaks.

2 years agoadd long explanation for E0183
cameron1024 [Thu, 14 Oct 2021 16:44:04 +0000 (17:44 +0100)]
add long explanation for E0183

2 years agoAuto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr
bors [Thu, 14 Oct 2021 16:23:10 +0000 (16:23 +0000)]
Auto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #89390 (Fix incorrect Box::pin suggestion)
 - #89433 (Fix ctrl-c causing reads of stdin to return empty on Windows.)
 - #89823 (Switch order of terms to prevent overflow)
 - #89865 (Allow static linking LLVM with ThinLTO)
 - #89873 (Add missing word to `FromStr` trait documentation)
 - #89878 (Fix missing remaining compiler specific cfg information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoDrop reverted stabilizations from release notes
Mark Rousskov [Thu, 14 Oct 2021 14:58:16 +0000 (10:58 -0400)]
Drop reverted stabilizations from release notes

2 years agoRevert "Stabilize `arbitrary_enum_discriminant`"
Mark Rousskov [Thu, 14 Oct 2021 14:57:56 +0000 (10:57 -0400)]
Revert "Stabilize `arbitrary_enum_discriminant`"

This reverts commit 7a62f29f3171767090949778ce0f161e930706b9.

2 years agoRollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle
Matthias Krüger [Thu, 14 Oct 2021 14:06:47 +0000 (16:06 +0200)]
Rollup merge of #89878 - GuillaumeGomez:add-missing-cfg-hide, r=notriddle

Fix missing remaining compiler specific cfg information

Follow-up of #89596. We forgot a few of them:

![Screenshot from 2021-10-14 11-36-44](https://user-images.githubusercontent.com/3050060/137292700-64ebc59f-d9d2-41f2-be3a-fa5bf211523c.png)
![Screenshot from 2021-10-14 11-36-56](https://user-images.githubusercontent.com/3050060/137292703-f63fa4e5-2c56-446b-9f86-3652f03dfe59.png)

r? `@notriddle`

2 years agoRollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum
Matthias Krüger [Thu, 14 Oct 2021 14:06:46 +0000 (16:06 +0200)]
Rollup merge of #89873 - askoufis:patch-1, r=Mark-Simulacrum

Add missing word to `FromStr` trait documentation

The doc comment is getting a bit wide, let me know if I should restructure it/add a new line.

2 years agoRollup merge of #89865 - tmandry:llvm-static, r=Mark-Simulacrum
Matthias Krüger [Thu, 14 Oct 2021 14:06:46 +0000 (16:06 +0200)]
Rollup merge of #89865 - tmandry:llvm-static, r=Mark-Simulacrum

Allow static linking LLVM with ThinLTO

There's no reason not to allow this if the user wants it. It works, at least in a local build on linux host.

For our use case, we're happy to spend more time building the compiler if it creates a speedup every time we run it, and we've observed speedups like this with clang.

2 years agoRollup merge of #89823 - jackh726:project-overflow, r=oli-obk
Matthias Krüger [Thu, 14 Oct 2021 14:06:45 +0000 (16:06 +0200)]
Rollup merge of #89823 - jackh726:project-overflow, r=oli-obk

Switch order of terms to prevent overflow

Fixes #89639

r? ``@pnkfelix``

2 years agoRollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett
Matthias Krüger [Thu, 14 Oct 2021 14:06:44 +0000 (16:06 +0200)]
Rollup merge of #89433 - arlosi:stdin-fix, r=joshtriplett

Fix ctrl-c causing reads of stdin to return empty on Windows.

Pressing ctrl+c (or ctrl+break) on Windows caused a blocking read of stdin to unblock and return empty, unlike other platforms which continue to block.

On ctrl-c, `ReadConsoleW` will return success, but also set `LastError` to `ERROR_OPERATION_ABORTED`.

This change detects this case, and re-tries the call to `ReadConsoleW`.

Fixes #89177. See issue for further details.

Tested on Windows 7 and Windows 10 with both MSVC and GNU toolchains

2 years agoRollup merge of #89390 - tmandry:issue-72117, r=estebank
Matthias Krüger [Thu, 14 Oct 2021 14:06:43 +0000 (16:06 +0200)]
Rollup merge of #89390 - tmandry:issue-72117, r=estebank

Fix incorrect Box::pin suggestion

The suggestion checked if `Pin<Box<T>>` could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is still marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.

Fixes #72117.

2 years agoadd dedicated error variant for writing the discriminant of an uninhabited enum variant
Ralf Jung [Wed, 13 Oct 2021 20:53:09 +0000 (16:53 -0400)]
add dedicated error variant for writing the discriminant of an uninhabited enum variant

2 years agodon't duplicate slice `panic_bounds_check`
Ibraheem Ahmed [Thu, 14 Oct 2021 13:31:34 +0000 (09:31 -0400)]
don't duplicate slice `panic_bounds_check`

2 years agoAuto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk
bors [Thu, 14 Oct 2021 13:21:46 +0000 (13:21 +0000)]
Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk

Add check that live_region is live in sanitize_promoted

This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`.

To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region:

    /// Returns an iterator of all the elements contained by the region `r`
    crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_

Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`.

This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.

2 years agoUse non-checking TLS relocation in aarch64 asm! sym test.
Adam Gemmell [Wed, 13 Oct 2021 09:44:02 +0000 (10:44 +0100)]
Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than
12 bits - hence we wouldn't ever need the upper 12 bits.

2 years agoAuto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk
bors [Thu, 14 Oct 2021 10:06:30 +0000 (10:06 +0000)]
Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk

Add `const_eval_select` intrinsic

Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime.

See https://github.com/rust-lang/const-eval/issues/7 for previous discussion.

r? `@oli-obk.`

2 years agoFix missing remaining compiler specific cfg information
Guillaume Gomez [Thu, 14 Oct 2021 09:39:30 +0000 (11:39 +0200)]
Fix missing remaining compiler specific cfg information

2 years agoOops, inverted condition, fix that
Loïc BRANSTETT [Thu, 14 Oct 2021 08:50:46 +0000 (10:50 +0200)]
Oops, inverted condition, fix that

2 years agofix codegen test
Deadbeef [Thu, 14 Oct 2021 07:35:35 +0000 (07:35 +0000)]
fix codegen test

2 years agoFix const stability
Deadbeef [Thu, 14 Oct 2021 06:53:20 +0000 (06:53 +0000)]
Fix const stability

2 years agoAvoid tupling at the callee
Deadbeef [Thu, 14 Oct 2021 06:18:53 +0000 (06:18 +0000)]
Avoid tupling at the callee

2 years agoSelecting the Xcode version no longer needed with the macos-11 runners.
Hans Kratz [Wed, 13 Oct 2021 15:44:39 +0000 (17:44 +0200)]
Selecting the Xcode version no longer needed with the macos-11 runners.

2 years agoAdd missing word to `FromStr` trait docs
Adam Skoufis [Thu, 14 Oct 2021 02:47:54 +0000 (13:47 +1100)]
Add missing word to `FromStr` trait docs

2 years agoAuto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle
bors [Thu, 14 Oct 2021 02:24:52 +0000 (02:24 +0000)]
Auto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle

Associated consts sidebar

Fixes #89354.

A screenshot with `f32`:

![Screenshot from 2021-10-12 15-07-57](https://user-images.githubusercontent.com/3050060/136962078-5faf7b87-7ea5-4d7a-99a4-b2afd77b78e2.png)

2 years agoSuggest Box::pin when Pin::new is used instead
Tyler Mandry [Wed, 13 Oct 2021 23:24:48 +0000 (23:24 +0000)]
Suggest Box::pin when Pin::new is used instead