]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoWrite primitive types via array buffers
Mark Rousskov [Sun, 16 May 2021 01:39:45 +0000 (21:39 -0400)]
Write primitive types via array buffers

This allows a more efficient implementation (avoiding a fallback to memmove,
which is not optimal for short writes).

This saves 0.29% on diesel.

3 years agoSwitch to reserve over extend_from_slice
Mark Rousskov [Sat, 15 May 2021 23:49:54 +0000 (19:49 -0400)]
Switch to reserve over extend_from_slice

This is a 0.15% win on diesel.

3 years agoSpecialize single-element writes to buffer
Mark Rousskov [Sat, 15 May 2021 22:54:57 +0000 (18:54 -0400)]
Specialize single-element writes to buffer

copy_from_slice generally falls back to memcpy/memmove, which is much more expensive
than we need to write a single element in.

This saves 0.26% instructions on the diesel benchmark.

3 years agoAuto merge of #85767 - lqd:stackless_span_stacks, r=oli-obk
bors [Sat, 29 May 2021 13:34:20 +0000 (13:34 +0000)]
Auto merge of #85767 - lqd:stackless_span_stacks, r=oli-obk

A bit more polish on const eval errors

This PR adds a bit more polish to the const eval errors:
- a slight improvement to the PME messages from #85633: I mentioned there that the erroneous item's paths were dependent on the environment, and could be displayed fully qualified or not. This can obscure the items when they come from a dependency. This PR uses the pretty-printing code ensuring the items' paths are not trimmed.
- whenever there are generics involved in an item where const evaluation errors out, the error message now displays the instance and its const arguments, so that we can see which instantiated item and compile-time values lead to the error.

So we get this slight improvement for our beloved `stdarch` example, on nightly:
```
error[E0080]: evaluation of constant value failed
 --> ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
8 |         assert!(IMM >= MIN && IMM <= MAX, "IMM value not in expected range");
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'IMM value not in expected range', /rustc/9111b8ae9793f18179a1336417618fc07a9cac85/library/core/src/../../stdarch/crates/core_arch/src/macros.rs:8:9
  |
```

to this PR's:

```
error[E0080]: evaluation of `core::core_arch::macros::ValidateConstImm::<51_i32, 0_i32, 15_i32>::VALID` failed
 --> ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
8 |         assert!(IMM >= MIN && IMM <= MAX, "IMM value not in expected range");
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'IMM value not in expected range', ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
```

with this PR.

Of course this is an idea from Oli, so maybe r? `@oli-obk` if they have the time.

3 years agoAuto merge of #85798 - hyd-dev:miri, r=RalfJung
bors [Sat, 29 May 2021 09:07:33 +0000 (09:07 +0000)]
Auto merge of #85798 - hyd-dev:miri, r=RalfJung

Update Miri

Fixes #85780.

3 years agoAuto merge of #85703 - clarfonthey:unchecked_shift, r=scottmcm
bors [Sat, 29 May 2021 05:16:09 +0000 (05:16 +0000)]
Auto merge of #85703 - clarfonthey:unchecked_shift, r=scottmcm

Add inherent unchecked_shl, unchecked_shr to integers

Tracking issue: #85122.

Adding more of these methods, since these are missing.

3 years agoAdd inherent unchecked_shl, unchecked_shr to integers
ltdk [Wed, 26 May 2021 01:46:07 +0000 (21:46 -0400)]
Add inherent unchecked_shl, unchecked_shr to integers

3 years agoAuto merge of #85790 - ehuss:nvptx-no-std, r=nagisa
bors [Sat, 29 May 2021 01:01:13 +0000 (01:01 +0000)]
Auto merge of #85790 - ehuss:nvptx-no-std, r=nagisa

Fix typo on nvptx support

I made a minor mistake in https://github.com/rust-lang/rust-forge/pull/356 setting nvptx as std instead of no-std.

3 years agoUpdate Miri
hyd-dev [Sat, 29 May 2021 00:52:58 +0000 (08:52 +0800)]
Update Miri

3 years agoAuto merge of #85607 - LeSeulArtichaut:thir-unsafeck-closures, r=nikomatsakis
bors [Fri, 28 May 2021 20:26:00 +0000 (20:26 +0000)]
Auto merge of #85607 - LeSeulArtichaut:thir-unsafeck-closures, r=nikomatsakis

Make closures inherit their parent's "safety context"

Fixes rust-lang/project-thir-unsafeck#9, ~~blocked on #85273~~.
r? `@nikomatsakis`

3 years agoAuto merge of #85789 - ptrojahn:generator_typo, r=nagisa
bors [Fri, 28 May 2021 17:44:47 +0000 (17:44 +0000)]
Auto merge of #85789 - ptrojahn:generator_typo, r=nagisa

Fix typo

3 years agoFix typo on nvptx support
Eric Huss [Fri, 28 May 2021 17:14:56 +0000 (10:14 -0700)]
Fix typo on nvptx support

3 years agoAuto merge of #85700 - Bobo1239:dso_local_ppc64, r=nagisa
bors [Fri, 28 May 2021 15:03:52 +0000 (15:03 +0000)]
Auto merge of #85700 - Bobo1239:dso_local_ppc64, r=nagisa

Fix static relocation model for PowerPC64

We now also use `should_assume_dso_local()` for declarations and port two
additional cases from clang:
- Exclude PPC64 [1]
- Exclude thread-local variables [2]

[1]: https://github.com/llvm/llvm-project/blob/033138ea452f5f493fb5095e5963419905ad12e1/clang/lib/CodeGen/CodeGenModule.cpp#L1038-L1040
[2]: https://github.com/llvm/llvm-project/blob/033138ea452f5f493fb5095e5963419905ad12e1/clang/lib/CodeGen/CodeGenModule.cpp#L1048-L1050

Tbh I don't know enough about PowerPC(64) to explain why the TOC (table of contents; like the GOT in x86?) is still needed even with the static relocation model. But with these changes [Rust-For-Linux](https://github.com/Rust-for-Linux/linux) runs again on ppc64le. (instead of [getting loaded successfully but crashing](https://github.com/Bobo1239/linux/runs/2646478783?check_suite_focus=true#step:47:358))

r? `@nagisa`

3 years agoAuto merge of #85546 - hyd-dev:unwind, r=RalfJung
bors [Fri, 28 May 2021 08:49:48 +0000 (08:49 +0000)]
Auto merge of #85546 - hyd-dev:unwind, r=RalfJung

const-eval: disallow unwinding across functions that `!fn_can_unwind()`

Following https://github.com/rust-lang/miri/pull/1776#discussion_r633074343, so r? `@RalfJung`

This PR turns `unwind` in `StackPopCleanup::Goto` into a new enum `StackPopUnwind`, with a `NotAllowed` variant to indicate that unwinding is not allowed. This variant is chosen based on `rustc_middle::ty::layout::fn_can_unwind()` in `eval_fn_call()` when pushing the frame. A check is added in `unwind_to_block()` to report UB if unwinding happens across a `StackPopUnwind::NotAllowed` frame.

Tested with Miri `HEAD` with [minor changes](https://github.com/rust-lang/miri/compare/HEAD..9cf3c7f0d86325a586fbcbf2acdc9232b861f1d8) and the rust-lang/miri#1776 branch with [these changes](https://github.com/rust-lang/miri/compare/d866c1c52f48bf562720383455b75c257bb1ad92..626638fbfe2fff34648dda29a34d59db498a6e52).

3 years agoAuto merge of #85745 - veber-alex:panic_any, r=m-ou-se
bors [Fri, 28 May 2021 06:08:58 +0000 (06:08 +0000)]
Auto merge of #85745 - veber-alex:panic_any, r=m-ou-se

Add #[track_caller] to panic_any

Report the panic location from the user code.

```rust
use std::panic;
use std::panic::panic_any;

fn main() {
    panic::set_hook(Box::new(|panic_info| {
        if let Some(location) = panic_info.location() {
            println!(
                "panic occurred in file '{}' at line {}",
                location.file(),
                location.line(),
            );
        } else {
            println!("panic occurred but can't get location information...");
        }
    }));

    panic_any(42);
}
````

Before:
`panic occurred in file '/rustc/ff2c947c00f867b9f012e28ba88cecfbe556f904/library/std/src/panic.rs' at line 59`

After:
`panic occurred in file 'src/main.rs' at line 17`

3 years agoAuto merge of #84968 - FabianWolff:master, r=estebank
bors [Fri, 28 May 2021 03:38:28 +0000 (03:38 +0000)]
Auto merge of #84968 - FabianWolff:master, r=estebank

Fix incorrect suggestions for E0605

Fixes #84598. Here is a simplified version of the problem presented in issue #84598:

```Rust
#![allow(unused_variables)]
#![allow(dead_code)]

trait T { fn t(&self) -> i32; }

unsafe fn foo(t: *mut dyn T) {
    (t as &dyn T).t();
}

fn main() {}
```

The current output is:
```
error[E0605]: non-primitive cast: `*mut (dyn T + 'static)` as `&dyn T`
 --> src/main.rs:7:5
  |
7 |     (t as &dyn T).t();
  |     ^^^^^^^^^^^^^ invalid cast
  |
help: borrow the value for the cast to be valid
  |
7 |     (&t as &dyn T).t();
  |      ^
```

This is incorrect, though: The cast will _not_ be valid when writing `&t` instead of `t`:
```
error[E0277]: the trait bound `*mut (dyn T + 'static): T` is not satisfied
 --> t4.rs:7:6
  |
7 |     (&t as &dyn T).t();
  |      ^^ the trait `T` is not implemented for `*mut (dyn T + 'static)`
  |
  = note: required for the cast to the object type `dyn T`
```

The correct suggestion is `&*t`, which I have implemented in this pull request. Of course, this suggestion will always require an unsafe block, but arguably, that's what the user really wants if they're trying to cast a pointer to a reference.

In any case, claiming that the cast will be valid after implementing the suggestion is overly optimistic, as the coercion logic doesn't seem to resolve all nested obligations, i.e. the cast may still be invalid after implementing the suggestion. I have therefore rephrased the suggestion slightly ("consider borrowing the value" instead of "borrow the value for the cast to be valid").

Additionally, I have fixed another incorrect suggestion not mentioned in #84598, which relates to casting immutable references to mutable ones:

```rust
fn main() {
    let mut x = 0;
    let m = &x as &mut i32;
}
```
currently leads to
```
error[E0605]: non-primitive cast: `&i32` as `&mut i32`
 --> t5.rs:3:13
  |
3 |     let m = &x as &mut i32;
  |             ^^^^^^^^^^^^^^ invalid cast
  |
help: borrow the value for the cast to be valid
  |
3 |     let m = &mut &x as &mut i32;
  |             ^^^^
```
which is obviously incorrect:
```
error[E0596]: cannot borrow data in a `&` reference as mutable
 --> t5.rs:3:13
  |
3 |     let m = &mut &x as &mut i32;
  |             ^^^^^^^ cannot borrow as mutable
```
I've changed the suggestion to a note explaining the problem:
```
error[E0605]: non-primitive cast: `&i32` as `&mut i32`
 --> t5.rs:3:13
  |
3 |     let m = &x as &mut i32;
  |             ^^^^^^^^^^^^^^ invalid cast
  |
note: this reference is immutable
 --> t5.rs:3:13
  |
3 |     let m = &x as &mut i32;
  |             ^^
note: trying to cast to a mutable reference type
 --> t5.rs:3:19
  |
3 |     let m = &x as &mut i32;
  |                   ^^^^^^^^
```
In this example, it would have been even nicer to suggest replacing `&x` with `&mut x`, but this would be much more complex because we would have to take apart the expression to be cast (currently, we only look at its type), and `&x` could be stored in a variable, where such a suggestion would not even be directly applicable:
```rust
fn main() {
    let mut x = 0;
    let r = &x;
    let m = r as &mut i32;
}
```
My solution covers this case, too.

3 years agoFix static relocation model for PowerPC64
Boris-Chengbiao Zhou [Tue, 25 May 2021 21:54:07 +0000 (23:54 +0200)]
Fix static relocation model for PowerPC64

We now also use `should_assume_dso_local()` for declarations and port two
additional cases from clang:
- Exclude PPC64 [1]
- Exclude thread-local variables [2]

[1]: https://github.com/llvm/llvm-project/blob/033138ea452f5f493fb5095e5963419905ad12e1/clang/lib/CodeGen/CodeGenModule.cpp#L1038-L1040
[2]: https://github.com/llvm/llvm-project/blob/033138ea452f5f493fb5095e5963419905ad12e1/clang/lib/CodeGen/CodeGenModule.cpp#L1048-L1050

3 years agoRewrite to a `match`
hyd-dev [Fri, 28 May 2021 01:20:43 +0000 (09:20 +0800)]
Rewrite to a `match`

3 years ago"a frame" -> "a stack frame"
hyd-dev [Fri, 28 May 2021 01:18:18 +0000 (09:18 +0800)]
"a frame" -> "a stack frame"

3 years agoAuto merge of #85743 - bjorn3:sync_cg_clif-2021-05-27, r=bjorn3
bors [Fri, 28 May 2021 00:57:39 +0000 (00:57 +0000)]
Auto merge of #85743 - bjorn3:sync_cg_clif-2021-05-27, r=bjorn3

Sync rustc_codegen_cranelift

The main highlight this sync is the removal of several dependencies, making compilation of cg_clif itself faster. There have also been a couple of new features like `#[link_section]` now supporting different segments for Mach-O binaries (thanks `@eggyal!)` and the `imported_main` feature, which is currently unstable.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

3 years agoconst eval errors: display the current item instance if there are generics involved
Rémy Rakic [Thu, 27 May 2021 20:42:07 +0000 (22:42 +0200)]
const eval errors: display the current item instance if there are generics involved

3 years agoAuto merge of #84568 - andoriyu:libtest/junit_formatter, r=yaahc
bors [Thu, 27 May 2021 21:14:55 +0000 (21:14 +0000)]
Auto merge of #84568 - andoriyu:libtest/junit_formatter, r=yaahc

feat(libtest): Add JUnit formatter

tracking issue: https://github.com/rust-lang/rust/issues/85563

Add an alternative formatter to `libtest`. Formatter produces valid xml that later can be interpreted as JUnit report.

Caveats:

- `timestamp` is required by schema, but every viewer/parser ignores it. Attribute is not set to avoid depending on chrono;
- Running all "suits" (unit tests, doc-tests and integration tests) will produce a mess;
- I couldn't find a way to get integration test binary name, so it's just goes by "integration";

Sample output for unit tests (pretty printed by 3rd party tool):
```
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="13" skipped="1">
    <testcase classname="results::tests" name="test_completed_bad" time="0"/>
    <testcase classname="results::tests" name="suite_started" time="0"/>
    <testcase classname="results::tests" name="suite_ended_ok" time="0"/>
    <testcase classname="results::tests" name="suite_ended_bad" time="0"/>
    <testcase classname="junit::tests" name="test_failed_output" time="0"/>
    <testcase classname="junit::tests" name="test_simple_output" time="0"/>
    <testcase classname="junit::tests" name="test_multiple_outputs" time="0"/>
    <testcase classname="results::tests" name="test_completed_ok" time="0"/>
    <testcase classname="results::tests" name="test_stared" time="0"/>
    <testcase classname="junit::tests" name="test_generate_xml_no_error_single_testsuite" time="0"/>
    <testcase classname="results::tests" name="test_simple_output" time="0"/>
    <testcase classname="test" name="should_panic" time="0"/>
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>
```

Sample output for integration tests (pretty printed by 3rd party tool):

```
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0">
    <testcase classname="integration" name="test_add" time="0"/>
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>
```

Sample output for Doc-tests (pretty printed by 3rd party tool):

```
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0">
    <testcase classname="src/lib.rs" name="(line 2)" time="0"/>
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>
```

3 years agodon't trim paths in collector PME message
Rémy Rakic [Thu, 27 May 2021 20:28:04 +0000 (22:28 +0200)]
don't trim paths in collector PME message

3 years agoTest THIR unsafeck for unsafe ops in closures
LeSeulArtichaut [Thu, 27 May 2021 18:37:49 +0000 (20:37 +0200)]
Test THIR unsafeck for unsafe ops in closures

3 years agoAuto merge of #85757 - GuillaumeGomez:rollup-k8hfhp8, r=GuillaumeGomez
bors [Thu, 27 May 2021 18:33:43 +0000 (18:33 +0000)]
Auto merge of #85757 - GuillaumeGomez:rollup-k8hfhp8, r=GuillaumeGomez

Rollup of 3 pull requests

Successful merges:

 - #85722 (Fix trait methods' toggle)
 - #85730 (Mention workaround for floats in Iterator::{min, max})
 - #85738 (Rename opensbd to openbsd)

Failed merges:

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

3 years agoRollup merge of #85738 - 370417:opensbd, r=m-ou-se
Guillaume Gomez [Thu, 27 May 2021 18:08:24 +0000 (20:08 +0200)]
Rollup merge of #85738 - 370417:opensbd, r=m-ou-se

Rename opensbd to openbsd

OpenBsd was sometimes spelled "opensbd" in the standard library.

3 years agoRollup merge of #85730 - Smittyvb:iter-min-max-floats, r=m-ou-se
Guillaume Gomez [Thu, 27 May 2021 18:08:21 +0000 (20:08 +0200)]
Rollup merge of #85730 - Smittyvb:iter-min-max-floats, r=m-ou-se

Mention workaround for floats in Iterator::{min, max}

`Iterator::{min, max}` can't be used with iterators of floats due to NaN issues. This suggests a workaround in the documentation of those functions.

3 years agoRollup merge of #85722 - GuillaumeGomez:trait-toggle, r=jsha
Guillaume Gomez [Thu, 27 May 2021 18:08:17 +0000 (20:08 +0200)]
Rollup merge of #85722 - GuillaumeGomez:trait-toggle, r=jsha

Fix trait methods' toggle

A `<details>` tag wasn't closed on trait methods, which created broken DOM. I also used this occasion to only generate the toggle in case there is documentation on the method.

r? `@jsha`

3 years agoAuto merge of #85729 - LeSeulArtichaut:thir-no-hash, r=nikomatsakis
bors [Thu, 27 May 2021 15:46:48 +0000 (15:46 +0000)]
Auto merge of #85729 - LeSeulArtichaut:thir-no-hash, r=nikomatsakis

Don't hash `thir_body`

Experiment to see if/how much this helps negate the perf impact of #85273.
r? `@ghost`

3 years agoMake closures inherit their parent's "safety context"
LeSeulArtichaut [Sun, 23 May 2021 16:10:32 +0000 (18:10 +0200)]
Make closures inherit their parent's "safety context"

3 years agoUpdate compiler/rustc_middle/src/query/mod.rs
Niko Matsakis [Thu, 27 May 2021 14:31:47 +0000 (10:31 -0400)]
Update compiler/rustc_middle/src/query/mod.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
3 years agoAuto merge of #85737 - scottmcm:vec-calloc-option-nonzero, r=m-ou-se
bors [Thu, 27 May 2021 13:05:57 +0000 (13:05 +0000)]
Auto merge of #85737 - scottmcm:vec-calloc-option-nonzero, r=m-ou-se

Enable Vec's calloc optimization for Option<NonZero>

Someone on discord noticed that `vec![None::<NonZeroU32>; N]` wasn't getting the optimization, so here's a PR 🙃

We can certainly do this in the standard library because we know for sure this is ok, but I think it's also a necessary consequence of documented guarantees like those in https://doc.rust-lang.org/std/option/#representation and https://doc.rust-lang.org/core/num/struct.NonZeroU32.html

It feels weird to do this without adding a test, but I wasn't sure where that would belong.  Is it worth adding codegen tests for these?

3 years agoRemove unused tidy dep exceptions
bjorn3 [Thu, 27 May 2021 11:23:32 +0000 (13:23 +0200)]
Remove unused tidy dep exceptions

3 years agoAdd #[track_caller] to panic_any
Alex Veber [Thu, 27 May 2021 11:19:47 +0000 (14:19 +0300)]
Add #[track_caller] to panic_any

3 years agoMerge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
bjorn3 [Thu, 27 May 2021 11:08:14 +0000 (13:08 +0200)]
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27

3 years agoAuto merge of #85732 - Smittyvb:trait-alias-camelcase-lint, r=varkor
bors [Thu, 27 May 2021 10:42:01 +0000 (10:42 +0000)]
Auto merge of #85732 - Smittyvb:trait-alias-camelcase-lint, r=varkor

Lint against non-CamelCase trait alias names

Type aliases are linted as such, so (unstable) trait aliases should be treated the same way.

3 years agoRustfmt
bjorn3 [Thu, 27 May 2021 10:40:08 +0000 (12:40 +0200)]
Rustfmt

3 years agoRustup to rustc 1.54.0-nightly (ff2c947c0 2021-05-25)
bjorn3 [Thu, 27 May 2021 10:39:40 +0000 (12:39 +0200)]
Rustup to rustc 1.54.0-nightly (ff2c947c0 2021-05-25)

3 years agoEnable Vec's calloc optimization for Option<NonZero>
Scott McMurray [Thu, 27 May 2021 06:19:35 +0000 (23:19 -0700)]
Enable Vec's calloc optimization for Option<NonZero>

3 years agoRename opensbd to openbsd
Albert Ford [Thu, 27 May 2021 06:17:13 +0000 (23:17 -0700)]
Rename opensbd to openbsd

3 years agoAuto merge of #84124 - 12101111:libunwind, r=petrochenkov
bors [Thu, 27 May 2021 04:08:20 +0000 (04:08 +0000)]
Auto merge of #84124 - 12101111:libunwind, r=petrochenkov

libunwind fix and cleanup

Fix:

1. "system-llvm-libunwind" now only skip build-script for linux target
2. workaround from https://github.com/rust-lang/rust/pull/65972 is not needed, upstream fix it in https://github.com/llvm/llvm-project/commit/68c50708d1f2b9aee3f10ec710df0b1387f701e5 ( LLVM 11 )
3. remove code for MSCV and Apple in `compile()`, as they are not used
4. fix https://github.com/rust-lang/rust/issues/69222 , compile c files and cpp files in different config
5. fix conditional compilation for musl target.
6. fix that x86_64-fortanix-unknown-sgx don't link libunwind built in build-script into rlib

3 years agoAuto merge of #85734 - Dylan-DPC:rollup-q6iiees, r=Dylan-DPC
bors [Thu, 27 May 2021 01:43:20 +0000 (01:43 +0000)]
Auto merge of #85734 - Dylan-DPC:rollup-q6iiees, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #84221 (E0599 suggestions and elision of generic argument if no canditate is found)
 - #84701 (stabilize member constraints)
 - #85564 ( readd capture disjoint fields gate)
 - #85583 (Get rid of PreviousDepGraph.)
 - #85649 (Update cc)
 - #85689 (Remove Iterator #[rustc_on_unimplemented]s that no longer apply.)
 - #85719 (Add inline attr to CString::into_inner so it can optimize out NonNull checks)
 - #85725 (Remove unneeded workaround)

Failed merges:

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

3 years agoRollup merge of #85725 - Smittyvb:rm-24159-workaround, r=RalfJung
Dylan DPC [Thu, 27 May 2021 01:02:12 +0000 (03:02 +0200)]
Rollup merge of #85725 - Smittyvb:rm-24159-workaround, r=RalfJung

Remove unneeded workaround

This removes a workaround for #24159, which has been fixed.

3 years agoRollup merge of #85719 - elichai:cstring-into_inner-inline, r=m-ou-se
Dylan DPC [Thu, 27 May 2021 01:02:11 +0000 (03:02 +0200)]
Rollup merge of #85719 - elichai:cstring-into_inner-inline, r=m-ou-se

Add inline attr to CString::into_inner so it can optimize out NonNull checks

It seems that currently if you convert any of the standard library's container to a pointer and then to a NonNull pointer, all will optimize out the NULL check except `CString`(https://godbolt.org/z/YPKW9G5xn),
because for some reason `CString::into_inner` isn't inlined even though it's a private function that should compile into a simple `mov` instruction.

Adding a simple `#[inline]` attribute solves this, code example:
```rust
use std::ffi::CString;
use std::ptr::NonNull;

pub fn cstring_nonull(mut n: CString) -> NonNull<i8> {
    NonNull::new(CString::into_raw(n)).unwrap()
}
```

assembly before:
```asm
__ZN3wat14cstring_nonull17h371c755bcad76294E:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
callq __ZN3std3ffi5c_str7CString10into_inner17h28ece07b276e2878E
testq %rax, %rax
je LBB0_2
popq %rbp
retq
LBB0_2:
leaq l___unnamed_1(%rip), %rdi
leaq l___unnamed_2(%rip), %rdx
movl $43, %esi
callq __ZN4core9panicking5panic17h92a83fa9085a8f73E
.cfi_endproc

.section __TEXT,__const
l___unnamed_1:
.ascii "called `Option::unwrap()` on a `None` value"

l___unnamed_3:
.ascii "wat.rs"

.section __DATA,__const
.p2align 3
l___unnamed_2:
.quad l___unnamed_3
.asciz "\006\000\000\000\000\000\000\000\006\000\000\000(\000\000"
```

Assembly after:
```asm
__ZN3wat14cstring_nonull17h9645eb9341fb25d7E:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movq %rdi, %rax
popq %rbp
retq
.cfi_endproc
```

(Related discussion on zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/NonNull.20From.3CBox.3CT.3E.3E)

3 years agoRollup merge of #85689 - m-ou-se:array-intoiter-3, r=estebank
Dylan DPC [Thu, 27 May 2021 01:02:10 +0000 (03:02 +0200)]
Rollup merge of #85689 - m-ou-se:array-intoiter-3, r=estebank

Remove Iterator #[rustc_on_unimplemented]s that no longer apply.

Now that `IntoIterator` is implemented for arrays, all the `rustc_on_unimplemented` for arrays of ranges (e.g. `for _ in [1..3] {}`) no longer apply, since they are now valid Rust.

Separated these from #85670, because we should discuss a potential new (clippy?) lint for these.

Until Rust 1.52, `for _ in [1..3] {}` produced:

```
error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator
 --> src/main.rs:2:14
  |
2 |     for _ in [1..3] {}
  |              ^^^^^^ if you meant to iterate between two values, remove the square brackets
  |
  = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]`
  = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end`
  = note: required by `std::iter::IntoIterator::into_iter`
```

But in Rust 1.53 and later, it compiles fine. It iterates over the array by value, for one iteration with the element `1..3`.

This is probably a mistake, which is no longer caught. Should we have a lint for it? Should Clippy have a lint for it?

cc ```@estebank``` ```@flip1995```

cc https://github.com/rust-lang/rust/issues/84513

3 years agoRollup merge of #85649 - ChrisDenton:update-cc, r=matthewjasper
Dylan DPC [Thu, 27 May 2021 01:02:09 +0000 (03:02 +0200)]
Rollup merge of #85649 - ChrisDenton:update-cc, r=matthewjasper

Update cc

Recent commits have improved `cc`'s finding of MSVC tools on Windows. In particular it should help to address these issues: #83043 and #43468

3 years agoRollup merge of #85583 - cjgillot:no-previous-dg, r=petrochenkov
Dylan DPC [Thu, 27 May 2021 01:02:09 +0000 (03:02 +0200)]
Rollup merge of #85583 - cjgillot:no-previous-dg, r=petrochenkov

Get rid of PreviousDepGraph.

Its only role is to access the `SerializedDepGraph`.

3 years agoRollup merge of #85564 - pnkfelix:issue-85435-readd-capture-disjoint-fields-gate...
Dylan DPC [Thu, 27 May 2021 01:02:08 +0000 (03:02 +0200)]
Rollup merge of #85564 - pnkfelix:issue-85435-readd-capture-disjoint-fields-gate, r=nikomatsakis

 readd capture disjoint fields gate

This readds a feature gate guard that was added in PR #83521. (Basically, there were unintended consequences to the code exposed by removing the feature gate guard.)

The root bug still remains to be resolved, as discussed in issue #85561. This is just a band-aid suitable for a beta backport.

Cc issue #85435

Note that the latter issue is unfixed until we backport this (or another fix) to 1.53 beta

3 years agoRollup merge of #84701 - nikomatsakis:stabilize-member-constraints-61997, r=jackh726
Dylan DPC [Thu, 27 May 2021 01:02:07 +0000 (03:02 +0200)]
Rollup merge of #84701 - nikomatsakis:stabilize-member-constraints-61997, r=jackh726

stabilize member constraints

Stabilizes the use of "member constraints" in solving `impl Trait` bindings. This is a step towards stabilizing a "MVP" of "named impl Trait".

# Member constraint stabilization report

| Info | |
| --- | --- |
| Tracking issue | [rust-lang/rust#61997](https://github.com/rust-lang/rust/issues/61997) |
| Implementation history | [rust-lang/rust#61775] |
| rustc-dev-guide coverage | [link](https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/member_constraints.html) |
| Complications | [rust-lang/rust#61773] |

[rust-lang/rust#61775]: https://github.com/rust-lang/rust/pull/61775
[rust-lang/rust#61773]: https://github.com/rust-lang/rust/issues/61773

## Background

Member constraints are an extension to our region solver that was introduced to make async fn region solving tractable. There are used in situations like the following:

```rust
fn foo<'a, 'b>(...) -> impl Trait<'a, 'b> { .. }
```

The problem here is that every region R in the hidden type must be equal to *either* `'a` *or* `'b` (or `'static`). This cannot be expressed simply via 'outlives constriants' like `R: 'a`. Therefore, we introduce a 'member constraint' `R member of ['a, 'b]`.

These constraints were introduced in [rust-lang/rust#61775]. At the time, we kept them feature gated and used them only for `impl Trait` return types that are derived from `async fn`. The intention, however, was always to support them in other contexts once we had time to gain more experience with them.

**In the time since their introduction, we have encountered no surprises or bugs due to these member constraints.** They are tested extensively as part of every async function that involves multiple unrelated lifetimes in its arguments.

## Tests

The behavior of member constraints is covered by the following tests:

* [`src/test/ui/async-await/multiple-lifetimes`](https://github.com/rust-lang/rust/tree/20e032e65007ff1376e8480c1fbdb0a5068028fa/src/test/ui/async-await/multiple-lifetimes) -- tests using the async await, which are mostly already stabilized
* [`src/test/ui/impl-trait/multiple-lifetimes.rs`](https://github.com/rust-lang/rust/blob/20e032e65007ff1376e8480c1fbdb0a5068028fa/src/test/ui/impl-trait/multiple-lifetimes.rs)
* [`src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs`](https://github.com/rust-lang/rust/blob/20e032e65007ff1376e8480c1fbdb0a5068028fa/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs)
* [`src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.rs`](https://github.com/rust-lang/rust/blob/20e032e65007ff1376e8480c1fbdb0a5068028fa/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-fg.rs)
* [`src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs`](https://github.com/rust-lang/rust/blob/20e032e65007ff1376e8480c1fbdb0a5068028fa/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.rs)

These tests cover a number of scenarios:

* `-> implTrait<'a, 'b>` with unrelated lifetimes `'a` and `'b`, as described above
* `async fn` that returns an `impl Trait` like the previous case, which desugars to a kind of "nested" impl trait like `impl Future<Output = impl Trait<'a, 'b>>`

## Potential concerns

There is a potential interaction with `impl Trait` on local variables, described in [rust-lang/rust#61773]. The challenge is that if you have a program like:

```rust=
trait Foo<'_> { }
impl Foo<'_> for &u32 { }

fn bar() {
  let x: impl Foo<'_> = &44; // let's call the region variable for `'_` `'1`
}
```

then we would wind up with `'0 member of ['1, 'static]`, where `'0` is the region variable in the hidden type (`&'0 u32`) and `'1` is the region variable in the bounds `Foo<'1>`. This is tricky because both `'0` and `'1` are being inferred -- so making them equal may have other repercussions.

That said, `impl Trait` in bindings are not stable, and the implementation is pretty far from stabilization. Moreover, the difficulty highlighted here is not due to the presence of member constraints -- it's inherent to the design of the language. In other words, stabilizing member constraints does not actually cause us to accept anything that would make this problem any harder.

So I don't see this as a blocker to stabilization of member constraints; it is potentially a blocker to stablization of `impl trait` in let bindings.

3 years agoRollup merge of #84221 - ABouttefeux:generic-arg-elision, r=estebank
Dylan DPC [Thu, 27 May 2021 01:02:03 +0000 (03:02 +0200)]
Rollup merge of #84221 - ABouttefeux:generic-arg-elision, r=estebank

E0599 suggestions and elision of generic argument if no canditate is found

fixes #81576
changes: In error E0599 (method not found) generic argument are eluded if the method was not found anywhere. If the method was found in another inherent implementation suggest that it was found elsewhere.

Example
```rust

struct Wrapper<T>(T);

struct Wrapper2<T> {
    x: T,
}

impl Wrapper2<i8> {
    fn method(&self) {}
}

fn main() {
    let wrapper = Wrapper(i32);
    wrapper.method();
    let wrapper2 = Wrapper2{x: i32};
    wrapper2.method();
}
```

```
Error[E0599]: no method named `method` found for struct `Wrapper<_>` in the current scope
....
error[E0599]: no method named `method` found for struct `Wrapper2<i32>` in the current scope
...
   = note: The method was found for Wrapper2<i8>.

```
I am not very happy with the ```no method named `test` found for struct `Vec<_, _>` in the current scope```. I think it might be better to show only one generic argument `Vec<_>` if there is a default one. But I haven't yet found a way to do that,

3 years agodon't use unneeded closure
Smittyvb [Thu, 27 May 2021 00:38:50 +0000 (20:38 -0400)]
don't use unneeded closure

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
3 years agodon't use unneeded closure
Smittyvb [Thu, 27 May 2021 00:38:43 +0000 (20:38 -0400)]
don't use unneeded closure

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
3 years agoLint against non-camelCase trait alias names
Smitty [Wed, 26 May 2021 23:55:27 +0000 (19:55 -0400)]
Lint against non-camelCase trait alias names

Type aliases are linted as such, so (unstable) trait aliases should be
treated the same way.

3 years agoAuto merge of #85652 - ehuss:linkchecker-perf, r=Mark-Simulacrum
bors [Wed, 26 May 2021 23:13:15 +0000 (23:13 +0000)]
Auto merge of #85652 - ehuss:linkchecker-perf, r=Mark-Simulacrum

Optimize linkchecker and add report.

This makes three changes to the linkchecker:

* Adds a report displayed after it finishes.
* Improves the performance by caching all filesystem access. The linkchecker can take over a minute to run on some systems, and this should make it about 2-3 times faster.
* Added a few tests.

3 years agoMention float workaround in Iterator::{min,max}
Smitty [Wed, 26 May 2021 21:15:54 +0000 (17:15 -0400)]
Mention float workaround in Iterator::{min,max}

3 years agoDon't hash `thir_body`
LeSeulArtichaut [Wed, 26 May 2021 20:34:42 +0000 (22:34 +0200)]
Don't hash `thir_body`

3 years agoAuto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum
bors [Wed, 26 May 2021 19:22:31 +0000 (19:22 +0000)]
Auto merge of #83770 - the8472:tra-extend, r=Mark-Simulacrum

Add `TrustedRandomAccess` specialization for `Vec::extend()`

This should do roughly the same as the `TrustedLen` specialization but result in less IR by using `__iterator_get_unchecked`
instead of `Iterator::for_each`

Conflicting specializations are manually prioritized by grouping them under yet another helper trait.

3 years agoFix typo
Paul Trojahn [Wed, 26 May 2021 17:19:47 +0000 (19:19 +0200)]
Fix typo

3 years agoRemove unneeded workaround
Smitty [Wed, 26 May 2021 17:16:26 +0000 (13:16 -0400)]
Remove unneeded workaround

This removes a workaround for #24159, which has been fixed.

3 years agoAuto merge of #85721 - Xanewok:update-rls, r=Xanewok
bors [Wed, 26 May 2021 16:35:45 +0000 (16:35 +0000)]
Auto merge of #85721 - Xanewok:update-rls, r=Xanewok

Update RLS

Closes #85453

r? `@ghost`

3 years agobless compare-mode=nll output
Niko Matsakis [Wed, 26 May 2021 16:05:34 +0000 (12:05 -0400)]
bless compare-mode=nll output

3 years agoAuto merge of #85720 - Dylan-DPC:rollup-in5917x, r=Dylan-DPC
bors [Wed, 26 May 2021 13:51:30 +0000 (13:51 +0000)]
Auto merge of #85720 - Dylan-DPC:rollup-in5917x, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #85478 (Disallow shadowing const parameters)
 - #85625 (Prevent double drop in `Vec::dedup_by` if a destructor panics)
 - #85627 (Fix a few details in THIR unsafeck)
 - #85633 (Post-monomorphization errors traces MVP)
 - #85670 (Remove arrays/IntoIterator message from Iterator trait.)
 - #85678 (fix `matches!` and `assert_matches!` on edition 2021)
 - #85679 (Remove num_as_ne_bytes feature)
 - #85712 (Fix typo in core::array::IntoIter comment)

Failed merges:

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

3 years agoUpdate trait toggle test
Guillaume Gomez [Wed, 26 May 2021 12:36:58 +0000 (14:36 +0200)]
Update trait toggle test

3 years ago* Fix bug where some <details> tags were not closed.
Guillaume Gomez [Wed, 26 May 2021 12:35:39 +0000 (14:35 +0200)]
* Fix bug where some <details> tags were not closed.
* Don't generate a <details> if there is no documentation

3 years agoUpdate RLS
Igor Matuszewski [Wed, 26 May 2021 12:02:26 +0000 (14:02 +0200)]
Update RLS

3 years agoSync from rust 1969c2e312303faa458cf19dad9783165e3c72c8
bjorn3 [Wed, 26 May 2021 12:01:50 +0000 (14:01 +0200)]
Sync from rust 1969c2e312303faa458cf19dad9783165e3c72c8

3 years agoAllow switching the regalloc algorithm from the commandline
bjorn3 [Wed, 26 May 2021 12:00:58 +0000 (14:00 +0200)]
Allow switching the regalloc algorithm from the commandline

3 years agoRollup merge of #85712 - BlackHoleFox:fix-iter-typo, r=jyn514
Dylan DPC [Wed, 26 May 2021 11:32:12 +0000 (13:32 +0200)]
Rollup merge of #85712 - BlackHoleFox:fix-iter-typo, r=jyn514

Fix typo in core::array::IntoIter comment

Saw a small typo reading some internal comments and decided to just throw this up to fix it for future readers.

3 years agoRollup merge of #85679 - hch12907:master, r=Mark-Simulacrum
Dylan DPC [Wed, 26 May 2021 11:32:11 +0000 (13:32 +0200)]
Rollup merge of #85679 - hch12907:master, r=Mark-Simulacrum

Remove num_as_ne_bytes feature

From the discussion in #76976, it is determined that eventual results of the safe transmute work as a more general mechanism will let these conversions happen in safe code without needing specialized methods.

Merging this PR closes #76976 and resolves #64464. Several T-libs members have raised their opinion that it doesn't pull its weight as a standalone method, and so we should not track it as a specific thing to add.

3 years agoRollup merge of #85678 - lukas-code:matches2021, r=dtolnay
Dylan DPC [Wed, 26 May 2021 11:32:10 +0000 (13:32 +0200)]
Rollup merge of #85678 - lukas-code:matches2021, r=dtolnay

fix `matches!` and `assert_matches!` on edition 2021

Previously this code failed to compile on edition 2021. [(Playground)](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=53960f2f051f641777b9e458da747707)
```rust
fn main() {
    matches!((), ());
}
```
```
   Compiling playground v0.0.1 (/playground)
error: `$pattern:pat` may be followed by `|`, which is not allowed for `pat` fragments
    |
    = note: allowed there are: `=>`, `,`, `=`, `if` or `in`

error: aborting due to previous error

error: could not compile `playground`

To learn more, run the command again with --verbose.
```

3 years agoRollup merge of #85670 - m-ou-se:array-intoiter-1, r=scottmcm
Dylan DPC [Wed, 26 May 2021 11:32:09 +0000 (13:32 +0200)]
Rollup merge of #85670 - m-ou-se:array-intoiter-1, r=scottmcm

Remove arrays/IntoIterator message from Iterator trait.

Arrays implement IntoIterator since 1.53.

cc https://github.com/rust-lang/rust/issues/84513

3 years agoRollup merge of #85633 - lqd:stackless_span_stacks, r=oli-obk
Dylan DPC [Wed, 26 May 2021 11:32:08 +0000 (13:32 +0200)]
Rollup merge of #85633 - lqd:stackless_span_stacks, r=oli-obk

Post-monomorphization errors traces MVP

This PR works towards better diagnostics for the errors encountered in #85155 and similar.

We can encounter post-monomorphization errors (PMEs) when collecting mono items. The current diagnostics are confusing for these cases when they happen in a dependency (but are acceptable when they happen in the local crate).

These kinds of errors will be more likely now that `stdarch` uses const generics for its intrinsics' immediate arguments, and validates these const arguments with a mechanism that triggers such PMEs.

(Not to mention that the errors happen during codegen, so only when building code that actually uses these code paths. Check builds don't trigger them, neither does unused code)

So in this PR, we detect these kinds of errors during the mono item graph walk: if any error happens while collecting a node or its neighbors, we print a diagnostic about the current collection step, so that the user has at least some context of which erroneous code and dependency triggered the error.

The diagnostics for issue #85155 now have this note showing the source of the erroneous const argument:
```
note: the above error was encountered while instantiating `fn std::arch::x86_64::_mm_blend_ps::<51_i32>`
  --> issue-85155.rs:11:24
   |
11 |         let _blended = _mm_blend_ps(a, b, 0x33);
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
```

Note that #85155 is a reduced version of a case happening in the wild, to indirect users of the `rustfft` crate, as seen in https://github.com/ejmahler/RustFFT/issues/74. The crate had a few of these out-of-range immediates. Here's how the diagnostics in this PR would have looked on one of its examples before it was fixed:

<details>

```
error[E0080]: evaluation of constant value failed
 --> ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
8 |         assert!(IMM >= MIN && IMM <= MAX, "IMM value not in expected range");
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'IMM value not in expected range', ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
  = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

note: the above error was encountered while instantiating `fn _mm_blend_ps::<51_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1314:23
     |
1314 |         let blended = _mm_blend_ps(rows[0], rows[2], 0x33);
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: the above error was encountered while instantiating `fn _mm_permute_pd::<5_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1859:9
     |
1859 |         _mm_permute_pd(self, 0x05)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

note: the above error was encountered while instantiating `fn _mm_permute_pd::<15_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1863:32
     |
1863 |         (_mm_movedup_pd(self), _mm_permute_pd(self, 0x0F))
     |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
error: could not compile `rustfft`

To learn more, run the command again with --verbose.
```

</details>

I've developed and discussed this with them, so maybe r? `@oli-obk` -- but feel free to redirect to someone else of course.

(I'm not sure we can say that this PR definitely closes issue 85155, as it's still unclear exactly which diagnostics and information would be interesting to report in such cases -- and we've discussed printing backtraces before. I have prototypes of some complete and therefore noisy backtraces I showed Oli, but we decided to not include them in this PR for now)

3 years agoRollup merge of #85627 - LeSeulArtichaut:thir-unsafe-fn-lint, r=nikomatsakis
Dylan DPC [Wed, 26 May 2021 11:32:07 +0000 (13:32 +0200)]
Rollup merge of #85627 - LeSeulArtichaut:thir-unsafe-fn-lint, r=nikomatsakis

Fix a few details in THIR unsafeck

This makes it consistent with RFC 2585 (`unsafe_op_in_unsafe_fn`) and with the MIR unsafeck.

r? `@nikomatsakis`

3 years agoRollup merge of #85625 - SkiFire13:fix-85613-vec-dedup-drop-panics, r=nagisa
Dylan DPC [Wed, 26 May 2021 11:32:06 +0000 (13:32 +0200)]
Rollup merge of #85625 - SkiFire13:fix-85613-vec-dedup-drop-panics, r=nagisa

Prevent double drop in `Vec::dedup_by` if a destructor panics

Fixes #85613

3 years agoRollup merge of #85478 - FabianWolff:issue-85348, r=petrochenkov
Dylan DPC [Wed, 26 May 2021 11:32:05 +0000 (13:32 +0200)]
Rollup merge of #85478 - FabianWolff:issue-85348, r=petrochenkov

Disallow shadowing const parameters

This pull request fixes #85348. Trying to shadow a `const` parameter as follows:
```rust
fn foo<const N: i32>() {
    let N @ _ = 0;
}
```
currently causes an ICE. With my changes, I get:
```
error[E0530]: let bindings cannot shadow const parameters
 --> test.rs:2:9
  |
1 | fn foo<const N: i32>() {
  |              - the const parameter `N` is defined here
2 |     let N @ _ = 0;
  |         ^ cannot be named the same as a const parameter

error: aborting due to previous error
```
This is the same error you get when trying to shadow a constant:
```rust
const N: i32 = 0;
let N @ _ = 0;
```
```
error[E0530]: let bindings cannot shadow constants
 --> src/lib.rs:3:5
  |
2 | const N: i32 = 0;
  | ----------------- the constant `N` is defined here
3 | let N @ _ = 0;
  |     ^ cannot be named the same as a constant

error: aborting due to previous error
```
The reason for disallowing shadowing in both cases is described [here](https://github.com/rust-lang/rust/issues/33118#issuecomment-233962221) (the comment there only talks about constants, but the same reasoning applies to `const` parameters).

3 years agocleanup and fix compiling of libunwind
12101111 [Mon, 24 May 2021 09:53:09 +0000 (17:53 +0800)]
cleanup and fix compiling of libunwind

fix conditional compiling of llvm-libunwind feaure for musl target.
update document of llvm-libunwind feature.

3 years agoAdd inline attr to private CString::into_inner
Elichai Turkel [Wed, 26 May 2021 10:12:54 +0000 (13:12 +0300)]
Add inline attr to private CString::into_inner

3 years agostabilize member constraints
Niko Matsakis [Thu, 29 Apr 2021 14:31:44 +0000 (10:31 -0400)]
stabilize member constraints

3 years agoFix typo in core::array::IntoIter comment
BlackHoleFox [Wed, 26 May 2021 07:37:39 +0000 (02:37 -0500)]
Fix typo in core::array::IntoIter comment

3 years agoAuto merge of #85711 - JohnTitor:rollup-8why04t, r=JohnTitor
bors [Wed, 26 May 2021 07:10:44 +0000 (07:10 +0000)]
Auto merge of #85711 - JohnTitor:rollup-8why04t, r=JohnTitor

Rollup of 12 pull requests

Successful merges:

 - #84048 (Avoid CJK legacy fonts in Windows)
 - #85529 (doc: clarify Mutex::try_lock, etc. errors)
 - #85590 (Fix bootstrap using host exe suffix for cargo)
 - #85610 (Fix pointer provenance in <[T]>::copy_within)
 - #85623 (Remove stray .stderr files)
 - #85645 (Demote `ControlFlow::{from|into}_try` to `pub(crate)`)
 - #85647 (Revert "Move llvm submodule updates to rustbuild")
 - #85666 (Document shared_from_cow functions)
 - #85668 (Fix tasklist example in rustdoc book.)
 - #85672 (Move stability attribute for items under the `ip` feature)
 - #85699 (Update books)
 - #85701 (Update cargo)

Failed merges:

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

3 years agoRollup merge of #85701 - ehuss:update-cargo, r=ehuss
Yuki Okushi [Wed, 26 May 2021 04:31:09 +0000 (13:31 +0900)]
Rollup merge of #85701 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in 070e459c2d8b79c5b2ac5218064e7603329c92ae..e931e4796b61de593aa1097649445e535c9c7ee0
2021-05-11 18:12:23 +0000 to 2021-05-24 16:17:27 +0000
- Add `cargo:rustc-link-arg-bin` flag. (rust-lang/cargo#9486)
- Add a cargo-doc.browser config option (rust-lang/cargo#9473)
- Fix bug when with resolver = "1" non-virtual package was allowing unknown features (rust-lang/cargo#9437)
- Add GitHub link to contributor guide. (rust-lang/cargo#9493)
- Add temporary fix for rustup on windows in CI. (rust-lang/cargo#9498)
- 3 typos and some capitalization (rust-lang/cargo#9495)
- fix 6 typos (rust-lang/cargo#9484)

3 years agoRollup merge of #85699 - ehuss:update-books, r=ehuss
Yuki Okushi [Wed, 26 May 2021 04:31:08 +0000 (13:31 +0900)]
Rollup merge of #85699 - ehuss:update-books, r=ehuss

Update books

## reference

4 commits in 5aa457bf1b54bd2cd5d4cf49797f29299bdf89a7..9c68af3ce6ccca2395e1868addef26a0542e9ddd
2021-05-05 08:39:22 -0700 to 2021-05-24 09:53:32 -0700
- missing parameter name in Trait Implementations (rust-lang-nursery/reference#1030)
- Add more content to impl-trait.md (rust-lang-nursery/reference#1017)
- Document extended key-value attributes (rust-lang-nursery/reference#1029)
- Document raw pointer &lt;-&gt; usize casts. (rust-lang-nursery/reference#970)

## rust-by-example

1 commits in 5f8c6da200ada77760a2fe1096938ef58151c9a6..805e016c5792ad2adabb66e348233067d5ea9f10
2021-04-29 08:08:01 -0300 to 2021-05-20 17:08:34 -0300
- Update structs.md (rust-lang/rust-by-example#1440)

## rustc-dev-guide

4 commits in 1e6c7fbda4c45e85adf63ff3f82fa9c870b1447f..50de7f0682adc5d95ce858fe6318d19b4b951553
2021-05-10 13:38:24 +0900 to 2021-05-20 15:02:20 +0200
- update rustfmt references to reflect change from submod to subtree (rust-lang/rustc-dev-guide#1129)
- Remove `--stage 1` argument from `doc` invocations (rust-lang/rustc-dev-guide#1125)
- Update coverage docs (rust-lang/rustc-dev-guide#1122)
- Document -Zunpretty=thir-tree (rust-lang/rustc-dev-guide#1128)

## edition-guide

1 commits in 1da3c411f17adb1ba5de1683bb6acee83362b54a..302a115e8f71876dfc884aebb0ca5ccb02b8a962
2021-02-16 16:46:40 -0800 to 2021-05-21 10:46:11 -0400
- Minimize the edition guide (rust-lang/edition-guide#232)

## embedded-book

1 commits in 569c3391f5c0cc43433bc77831d17f8ff4d76602..7349d173fa28a0bb834cf0264a05286620ef0923
2021-04-07 08:32:11 +0000 to 2021-05-25 13:59:05 +0000
- Remove $ from cargo-binutils  (rust-embedded/book#292)

3 years agoRollup merge of #85672 - CDirkx:ip, r=Mark-Simulacrum
Yuki Okushi [Wed, 26 May 2021 04:31:07 +0000 (13:31 +0900)]
Rollup merge of #85672 - CDirkx:ip, r=Mark-Simulacrum

Move stability attribute for items under the `ip` feature

The `#[unstable]` attribute for items under the `ip` feature is currently located on the `std::net::ip` module itself. This is unusual, and less readable. This has sidetracked discussion about these items numerous times (https://github.com/rust-lang/rust/pull/60145#issuecomment-498016572, https://github.com/rust-lang/rust/pull/76098#discussion_r530463543, https://github.com/rust-lang/rust/pull/76098#discussion_r558067755, https://github.com/rust-lang/rust/pull/75019#discussion_r467464300, https://github.com/rust-lang/rust/pull/75019#issuecomment-672888727) and lead to incorrect assumptions about which items are actually stable (https://github.com/rust-lang/rust/pull/60145#issuecomment-485970669, https://github.com/rust-lang/rust/pull/76098#discussion_r530444275).

This PR moves the attribute from the module to the items themselves.

3 years agoRollup merge of #85668 - ehuss:fix-rustdoc-tasklist, r=Mark-Simulacrum
Yuki Okushi [Wed, 26 May 2021 04:31:05 +0000 (13:31 +0900)]
Rollup merge of #85668 - ehuss:fix-rustdoc-tasklist, r=Mark-Simulacrum

Fix tasklist example in rustdoc book.

There were a few issues with the tasklist example in the rustdoc book:

* Misspelled "incomplete"
* Checkmarks were backwards
* Didn't show the text for each item
* Used HTML which renders differently from how markdown renders it (which uses "disabled" marks)
* Didn't use blockquotes to offset the example like the other extensions do
* Missing a colon

Before:
<img width="160" alt="image" src="https://user-images.githubusercontent.com/43198/119503519-e7787880-bd1f-11eb-9f13-1c67754ce001.png">

After:
<img width="220" alt="image" src="https://user-images.githubusercontent.com/43198/119503449-d6c80280-bd1f-11eb-9ab5-fe4a6df82124.png">

3 years agoRollup merge of #85666 - fee1-dead:document-shared-from-cow, r=dtolnay
Yuki Okushi [Wed, 26 May 2021 04:31:04 +0000 (13:31 +0900)]
Rollup merge of #85666 - fee1-dead:document-shared-from-cow, r=dtolnay

Document shared_from_cow functions

3 years agoRollup merge of #85647 - rust-lang:revert-81601-llvm-on-demand, r=jyn514
Yuki Okushi [Wed, 26 May 2021 04:31:03 +0000 (13:31 +0900)]
Rollup merge of #85647 - rust-lang:revert-81601-llvm-on-demand, r=jyn514

Revert "Move llvm submodule updates to rustbuild"

Reverts rust-lang/rust#81601

This updates LLVM a bit too eagerly -- and particularly on Windows, this can be slow. See discussion on [Zulip].

[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/x.2Epy.20always.20updates.20LLVM.20submodule

3 years agoRollup merge of #85645 - scottmcm:demote-from-into-try, r=yaahc
Yuki Okushi [Wed, 26 May 2021 04:31:02 +0000 (13:31 +0900)]
Rollup merge of #85645 - scottmcm:demote-from-into-try, r=yaahc

Demote `ControlFlow::{from|into}_try` to `pub(crate)`

They have mediocre names and non-obvious semantics, so personally I don't think they're worth trying to stabilize, and thus might as well just be internal (they're used for convenience in iterator adapters), not something shown in the rustdocs.

I don't think anyone actually wanted to use them outside `core` -- they just got made public-but-unstable along with the whole type in https://github.com/rust-lang/rust/pull/76204 that promoted `LoopState` from an internal type to the exposed `ControlFlow` type.

cc https://github.com/rust-lang/rust/issues/75744, the tracking issue they mention.
cc https://github.com/rust-lang/rust/pull/85608, the PR where I'm proposing stabilizing the type.

3 years agoRollup merge of #85623 - LeSeulArtichaut:stray-stderr, r=Mark-Simulacrum
Yuki Okushi [Wed, 26 May 2021 04:31:01 +0000 (13:31 +0900)]
Rollup merge of #85623 - LeSeulArtichaut:stray-stderr, r=Mark-Simulacrum

Remove stray .stderr files

The revisions for the test were [changed in #85555](https://github.com/rust-lang/rust/pull/85555/files#diff-f353939cf3762b63a04bae4d9c1c919039b64351bc4d8722ad894509f6015b0f) but the files weren't deleted.

3 years agoRollup merge of #85610 - SkiFire13:fix-copy-within-provenance, r=oli-obk
Yuki Okushi [Wed, 26 May 2021 04:31:00 +0000 (13:31 +0900)]
Rollup merge of #85610 - SkiFire13:fix-copy-within-provenance, r=oli-obk

Fix pointer provenance in <[T]>::copy_within

Previously the `self.as_mut_ptr()` invalidated the pointer created by the first `self.as_ptr()`. This also triggered miri when run with `-Zmiri-track-raw-pointers`

3 years agoRollup merge of #85590 - jam1garner:tool-bootstrap-su-fix, r=Mark-Simulacrum
Yuki Okushi [Wed, 26 May 2021 04:30:59 +0000 (13:30 +0900)]
Rollup merge of #85590 - jam1garner:tool-bootstrap-su-fix, r=Mark-Simulacrum

Fix bootstrap using host exe suffix for cargo

When attempting to cross compile rustc (for example, from Linux to Windows) and tell it to build cargo/tools, the following error occurs:

```
thread 'main' panicked at 'src.symlink_metadata() failed with No such file or directory (os error 2)', src/bootstrap/lib.rs:1196:24
```

Relevant part of stack trace:
<details>

```
   2: bootstrap::Build::copy
             at ./src/bootstrap/lib.rs:1196:24
   3: <bootstrap::tool::ToolBuild as bootstrap::builder::Step>::run
             at ./src/bootstrap/tool.rs:220:13
```
</details>

If I add `-vvv` (which seemed to be the recommended course for debugging a similar issue according to [zulip logs](https://zulip-archive.rust-lang.org/182449tcompilerhelp/19655failedtobootstrap.html)), it shows:

```
Copy ".../rust/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-pc-windows-gnu/release/cargo" to ".../rust/build/x86_64-unknown-linux-gnu/stage2-tools-bin/cargo"
```
and when taking a look at the contents of `build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-pc-windows-gnu/release` it contains `cargo.exe`, but no `cargo`.

I tried to study the surrounding code to make sure this was the intended behavior and while I can't be 100% certain, it does seem that using the exe suffix for the `compiler.host` target instead of the `target` target won't have the desired behavior when cross-compiling to/from Windows.

3 years agoRollup merge of #85529 - tlyu:trylock-errors, r=JohnTitor
Yuki Okushi [Wed, 26 May 2021 04:30:58 +0000 (13:30 +0900)]
Rollup merge of #85529 - tlyu:trylock-errors, r=JohnTitor

doc: clarify Mutex::try_lock, etc. errors

Clarify error returns from Mutex::try_lock, RwLock::try_read,
RwLock::try_write to make it more obvious that both poisoning
and the lock being already locked are possible errors.

3 years agoRollup merge of #84048 - konan8205:master, r=jsha
Yuki Okushi [Wed, 26 May 2021 04:30:54 +0000 (13:30 +0900)]
Rollup merge of #84048 - konan8205:master, r=jsha

Avoid CJK legacy fonts in Windows

As metioned in #84035, the default serif CJK font in Windows is meh-looking.
To avoid this, we should use sans-serif font or provide CJK glyph supported font in `rustdoc.css`.

3 years agoAuto merge of #85252 - kulikjak:fix-solaris-CI, r=Mark-Simulacrum
bors [Wed, 26 May 2021 04:27:23 +0000 (04:27 +0000)]
Auto merge of #85252 - kulikjak:fix-solaris-CI, r=Mark-Simulacrum

Bring back `x86_64-sun-solaris` target to rustup

Change #82216 removed now deprecated target `x86_64-sun-solaris` from CI, thus making it no longer possible to use `$ rustup target add x86_64-sun-solaris` to install given target (see #85098 for details). Since there should be a period of time between the deprecation and removal, this PR brings it back (while keeping the new one as well).

Please, correct me if I am wrong; my assumption that these Docker scripts are being used to build artifacts later used by `rustup` might be incorrect.

Closes #85098.

3 years agoAuto merge of #85535 - dtolnay:weakdangle, r=kennytm
bors [Wed, 26 May 2021 01:17:02 +0000 (01:17 +0000)]
Auto merge of #85535 - dtolnay:weakdangle, r=kennytm

Weak's type parameter may dangle on drop

Way back in https://github.com/rust-lang/rust/commit/34076bc0c9fb9ee718e1cebc407547eef730a080, #\[may_dangle\] was added to Rc\<T\> and Arc\<T\>'s Drop impls. That appears to have been because a test added in #28929 used Arc and Rc with dangling references at drop time. However, Weak was not covered by that test, and therefore no #\[may_dangle\] was forced to be added at the time.

As far as dropping, Weak has *even less need* to interact with the T than Rc and Arc do. Roughly speaking #\[may_dangle\] describes generic parameters that the outer type's Drop impl does not interact with except by possibly dropping them; no other interaction (such as trait method calls on the generic type) is permissible. It's clear this applies to Rc's and Arc's drop impl, which sometimes drop T but otherwise do not interact with one. It applies *even more* to Weak. Dropping a Weak cannot ever cause T's drop impl to run. Either there are strong references still in existence, in which case better not drop the T. Or there are no strong references still in existence, in which case the T would already have been dropped previously by the drop of the last strong count.

3 years agoUpdate cargo
Eric Huss [Tue, 25 May 2021 23:08:54 +0000 (16:08 -0700)]
Update cargo

3 years agoUpdate books
Eric Huss [Tue, 25 May 2021 22:03:01 +0000 (15:03 -0700)]
Update books

3 years agoRemove Iterator #[rustc_on_unimplemented]s that no longer apply.
Mara Bos [Tue, 25 May 2021 18:20:05 +0000 (20:20 +0200)]
Remove Iterator #[rustc_on_unimplemented]s that no longer apply.

3 years agoRun THIR unsafeck on `unsafe_op_in_unsafe_fn` test
LeSeulArtichaut [Mon, 24 May 2021 10:55:01 +0000 (12:55 +0200)]
Run THIR unsafeck on `unsafe_op_in_unsafe_fn` test

3 years agoFix `unused_unsafe` in THIR unsafeck
LeSeulArtichaut [Mon, 24 May 2021 10:54:26 +0000 (12:54 +0200)]
Fix `unused_unsafe` in THIR unsafeck

3 years agoHandle `unsafe_op_in_unsafe_fn` properly in THIR unsafeck
LeSeulArtichaut [Mon, 24 May 2021 10:43:51 +0000 (12:43 +0200)]
Handle `unsafe_op_in_unsafe_fn` properly in THIR unsafeck