]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoSimplfy color availability check
Guillaume Gomez [Wed, 11 Nov 2020 15:44:02 +0000 (16:44 +0100)]
Simplfy color availability check

3 years agoUpdate lock file
Guillaume Gomez [Thu, 16 Jul 2020 14:46:30 +0000 (16:46 +0200)]
Update lock file

3 years agoAdd check to get windows console type to decide to use colors or not
Guillaume Gomez [Thu, 16 Jul 2020 14:36:25 +0000 (16:36 +0200)]
Add check to get windows console type to decide to use colors or not

3 years agoUpdate error code detection in compile_fail doctests
Guillaume Gomez [Tue, 14 Jul 2020 12:44:12 +0000 (14:44 +0200)]
Update error code detection in compile_fail doctests

3 years agoAdd color in rustdoc --test output
Guillaume Gomez [Mon, 13 Jul 2020 13:34:38 +0000 (15:34 +0200)]
Add color in rustdoc --test output

3 years agoAuto merge of #78924 - bjorn3:less_sysroot_build_scripts, r=Mark-Simulacrum
bors [Tue, 17 Nov 2020 06:37:59 +0000 (06:37 +0000)]
Auto merge of #78924 - bjorn3:less_sysroot_build_scripts, r=Mark-Simulacrum

Make the libstd build script smaller

Of all sysroot crates currently only compiler_builtins, miniz_oxide and std require a build script. compiler_builtins uses to conditionally enable certain features and possibly compile a C version ([source](https://github.com/rust-lang/compiler-builtins/blob/63ccaf11f08fb5d0b39cc33884c5a1a63f547ace/build.rs)), miniz_oxide only uses it to detect if liballoc is supported as the MSRV is 1.34.0 instead of the 1.36.0 which stabilized liballoc ([source](https://github.com/Frommi/miniz_oxide/blob/28514ec09f0b1ce74bfb2d561de52a6652ce377a/miniz_oxide/build.rs)). std now only uses it to enable `freebsd12` when the `RUST_STD_FREEBSD_12_ABI` env var is set, to determine if `restricted-std` should be set, to set the `STD_ENV_ARCH` env var identical to `CARGO_CFG_TARGET_ARCH`, and to unconditionally enable `backtrace_in_libstd`.

If all build scripts were to be removed, it would be possible for rustc to completely compile it's own sysroot. It currently requires a rustc version that already has an available libstd to compile the build scripts. If rustc can completely compile it's own sysroot, rustbuild could be simplified to not forcefully use the bootstrap compiler for build scripts.

`@rustbot` modify labels: +T-compiler +libs-impl

3 years agoAuto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis
bors [Tue, 17 Nov 2020 03:56:03 +0000 (03:56 +0000)]
Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakis

RFC-2229: Implement Precise Capture Analysis

### This PR introduces
- Feature gate for RFC-2229 (incomplete) `capture_disjoint_field`
- Rustc Attribute to print out the capture analysis `rustc_capture_analysis`
- Precise capture analysis

### Description of the analysis
1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat)
2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout.
3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list.  Check rust-lang/project-rfc-2229#9 for more detailed examples.
4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing.

### Known issues
- Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression.

### Testing
We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762

### Thanks
This has been slowly in the works for a while now.
I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us.

Closes rust-lang/project-rfc-2229#7
Closes rust-lang/project-rfc-2229#9
Closes rust-lang/project-rfc-2229#6
Closes rust-lang/project-rfc-2229#19

r? `@nikomatsakis`

3 years agoAuto merge of #78313 - lcnr:somebody-fold-me, r=nikomatsakis
bors [Tue, 17 Nov 2020 01:14:54 +0000 (01:14 +0000)]
Auto merge of #78313 - lcnr:somebody-fold-me, r=nikomatsakis

TypeFoldable: take self by value

Implements https://github.com/rust-lang/compiler-team/issues/371 which is currently still in FCP.

r? `@nikomatsakis`

3 years agoAuto merge of #79104 - m-ou-se:rollup-v74492y, r=m-ou-se
bors [Mon, 16 Nov 2020 22:32:40 +0000 (22:32 +0000)]
Auto merge of #79104 - m-ou-se:rollup-v74492y, r=m-ou-se

Rollup of 11 pull requests

Successful merges:

 - #74989 (Implement `Index` and `IndexMut` for arrays)
 - #76339 (Test structural matching for all range types)
 - #77691 (Rename/Deprecate LayoutErr in favor of LayoutError)
 - #78364 (Update RELEASES.md for 1.48.0)
 - #78678 (Add tests and improve rendering of cfgs on traits)
 - #78714 (Simplify output capturing)
 - #78769 (Remove unneeded lifetimes in array/mod.rs)
 - #78903 (BTreeMap: test chaotic ordering & other bits & bobs)
 - #79032 (improve type const mismatch errors)
 - #79061 (Make all rustdoc functions and structs crate-private)
 - #79087 (Update E0744 about control flow in `const` contexts to accurately describe when the error is triggered and why)

Failed merges:

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

3 years agoupdate `cg_clif`
Bastian Kauschke [Wed, 28 Oct 2020 07:25:06 +0000 (08:25 +0100)]
update `cg_clif`

3 years agowords
lcnr [Sat, 24 Oct 2020 07:27:15 +0000 (09:27 +0200)]
words

3 years agoclippy: fold by value
Bastian Kauschke [Sat, 24 Oct 2020 00:21:27 +0000 (02:21 +0200)]
clippy: fold by value

3 years agocompiler: fold by value
Bastian Kauschke [Sat, 24 Oct 2020 00:21:18 +0000 (02:21 +0200)]
compiler: fold by value

3 years agoadd IdFunctor to rustc_data_structures
Bastian Kauschke [Sat, 24 Oct 2020 00:20:16 +0000 (02:20 +0200)]
add IdFunctor to rustc_data_structures

3 years agoRollup merge of #79087 - ThePuzzlemaker:issue-79083-docfix, r=RalfJung
Mara Bos [Mon, 16 Nov 2020 16:26:38 +0000 (17:26 +0100)]
Rollup merge of #79087 - ThePuzzlemaker:issue-79083-docfix, r=RalfJung

Update E0744 about control flow in `const` contexts to accurately describe when the error is triggered and why

This PR fixes #79083. `const fn` currently supports `if`, `match`, `loop`, and `while` in terms of control flow. The error relating to control flow in `const` contexts currently states that those control flow constructs are not allowed in `const` contexts. That is no longer true, as RFC 2342 and 2344 were [stabilized](https://github.com/rust-lang/rust/pull/72437). `for` loops, however, as well as `?` and `.await` are still not allowed, so I changed the error message to be more descriptive of the error as it is not just control flow that could trigger this error. I also added links to tracking issues that mark things that are blocking the usage of these expressions.

3 years agoRollup merge of #79061 - jyn514:no-pub, r=GuillaumeGomez
Mara Bos [Mon, 16 Nov 2020 16:26:36 +0000 (17:26 +0100)]
Rollup merge of #79061 - jyn514:no-pub, r=GuillaumeGomez

Make all rustdoc functions and structs crate-private

This gives warnings when code is no longer used, which will be helpful when https://github.com/rust-lang/rust/pull/77820 and https://github.com/rust-lang/rust/pull/78082 land.

AFAIK no one is using this API.

r? ``@GuillaumeGomez``
cc ``@rust-lang/rustdoc``

3 years agoRollup merge of #79032 - lcnr:arg-count, r=varkor
Mara Bos [Mon, 16 Nov 2020 16:26:35 +0000 (17:26 +0100)]
Rollup merge of #79032 - lcnr:arg-count, r=varkor

improve type const mismatch errors

Doesn't completely remove `check_generic_arg_count` as that would have required some more complex changes but
instead checks type and const params in only one step. Also moved the help added by `@JulianKnodt` in #75611 to `generic_arg_mismatch_err`.

r? `@varkor` cc `@petrochenkov`

3 years agoRollup merge of #78903 - ssomers:btree_order_chaos_testing, r=Mark-Simulacrum
Mara Bos [Mon, 16 Nov 2020 16:26:33 +0000 (17:26 +0100)]
Rollup merge of #78903 - ssomers:btree_order_chaos_testing, r=Mark-Simulacrum

BTreeMap: test chaotic ordering & other bits & bobs

r? `@Mark-Simulacrum`

3 years agoRollup merge of #78769 - est31:remove_lifetimes, r=KodrAus
Mara Bos [Mon, 16 Nov 2020 16:26:29 +0000 (17:26 +0100)]
Rollup merge of #78769 - est31:remove_lifetimes, r=KodrAus

Remove unneeded lifetimes in array/mod.rs

3 years agoRollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAus
Mara Bos [Mon, 16 Nov 2020 16:26:27 +0000 (17:26 +0100)]
Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAus

Simplify output capturing

This is a sequence of incremental improvements to the unstable/internal `set_panic` and `set_print` mechanism used by the `test` crate:

1. Remove the `LocalOutput` trait and use `Arc<Mutex<dyn Write>>` instead of `Box<dyn LocalOutput>`. In practice, all implementations of `LocalOutput` were just `Arc<Mutex<..>>`. This simplifies some logic and removes all custom `Sink` implementations such as `library/test/src/helpers/sink.rs`. Also removes a layer of indirection, as the outermost `Box` is now gone. It also means that locking now happens per `write_fmt`, not per individual `write` within. (So `"{} {}\n"` now results in one `lock()`, not four or more.)

2. Since in all cases the `dyn Write`s were just `Vec<u8>`s, replace the type with `Arc<Mutex<Vec<u8>>>`. This simplifies things more, as error handling and flushing can be removed now. This also removes the hack needed in the default panic handler to make this work with `::realstd`, as (unlike `Write`) `Vec<u8>` is from `alloc`, not `std`.

3. Replace the `RefCell`s by regular `Cell`s. The `RefCell`s were mostly used as `mem::replace(&mut *cell.borrow_mut(), something)`, which is just `Cell::replace`. This removes an unecessary bookkeeping and makes the code a bit easier to read.

4. Merge `set_panic` and `set_print` into a single `set_output_capture`. Neither the test crate nor rustc (the only users of this feature) have a use for using these separately. Merging them simplifies things even more. This uses a new function name and feature name, to make it clearer this is internal and not supposed to be used by other crates.

Might be easier to review per commit.

3 years agoRollup merge of #78678 - Nemo157:doc-cfg-w-traits, r=jyn514,GuillaumeGomez
Mara Bos [Mon, 16 Nov 2020 16:26:25 +0000 (17:26 +0100)]
Rollup merge of #78678 - Nemo157:doc-cfg-w-traits, r=jyn514,GuillaumeGomez

Add tests and improve rendering of cfgs on traits

Shows the additional features required to get the trait implementation, suppressing any already shown on the current page. One interesting effect from this is if you have a cfg-ed type, implementing a cfg-ed trait (so the implementation depends on both cfgs), you will get the inverted pair of cfgs shown on each page:

![image](https://user-images.githubusercontent.com/81079/97904671-207bdc00-1d41-11eb-8144-707e8017d2b6.png)

![image](https://user-images.githubusercontent.com/81079/97904700-27a2ea00-1d41-11eb-8b9f-e925ba339044.png)

The hidden items on the trait implementation also now get the correct cfgs displayed on them.

Tests are blocked on #78673.

fixes #68100
cc #43781

3 years agoRollup merge of #78364 - XAMPPRocky:relnote-1.48.0, r=pietroalbini
Mara Bos [Mon, 16 Nov 2020 16:26:21 +0000 (17:26 +0100)]
Rollup merge of #78364 - XAMPPRocky:relnote-1.48.0, r=pietroalbini

Update RELEASES.md for 1.48.0

### [Rendered](https://github.com/XAMPPRocky/rust/blob/relnote-1.48.0/RELEASES.md)

r? `@Mark-Simulacrum`
cc `@rust-lang/release`

3 years agoRollup merge of #77691 - exrook:rename-layouterr, r=KodrAus
Mara Bos [Mon, 16 Nov 2020 16:26:17 +0000 (17:26 +0100)]
Rollup merge of #77691 - exrook:rename-layouterr, r=KodrAus

Rename/Deprecate LayoutErr in favor of LayoutError

Implements rust-lang/wg-allocators#73.

This patch renames LayoutErr to LayoutError, and uses a type alias to support users using the old name.

The new name will be instantly stable in release 1.49 (current nightly), the type alias will become deprecated in release 1.51 (so that when the current nightly is 1.51, 1.49 will be stable).

This is the only error type in `std` that ends in `Err` rather than `Error`, if this PR lands all stdlib error types will end in `Error` :smiling_face_with_three_hearts:

3 years agoRollup merge of #76339 - CDirkx:structural-match-range, r=Mark-Simulacrum
Mara Bos [Mon, 16 Nov 2020 16:26:13 +0000 (17:26 +0100)]
Rollup merge of #76339 - CDirkx:structural-match-range, r=Mark-Simulacrum

Test structural matching for all range types

As of #70166 all range types (`core::ops::Range` etc.) can be structurally matched upon, and by extension used in const generics. In reference to the fact that this is a publicly observable property of these types, and thus falls under the Rust stability guarantees of the standard library, a regression test was added in #70283.

This regression test was implemented by me by testing for the ability to use the range types within const generics, but that is not the actual property the std guarantees now (const generics is still unstable). This PR addresses that situation by adding extra tests for the range types that directly test whether they can be structurally matched upon.

Note: also adds the otherwise unrelated test `test_range_to_inclusive` for completeness with the other range unit tests

3 years agoRollup merge of #74989 - pubfnbar:impl-array-indexing, r=KodrAus
Mara Bos [Mon, 16 Nov 2020 16:26:11 +0000 (17:26 +0100)]
Rollup merge of #74989 - pubfnbar:impl-array-indexing, r=KodrAus

Implement `Index` and `IndexMut` for arrays

Adds implementations of `Index` and `IndexMut` for arrays that simply forward to the slice indexing implementation in order to fix the following problem:

If you implement `Index<MyIndexType>` for an array, you lose all the other indexing functionality that used to be available to the array via its implicit coercion to a slice. An example of what I'm talking about:
```rust
use std::ops::Index;

pub enum MyIndexType {
    _0, _1, _2, _3, _4, _5, _6, _7,
}

impl<T> Index<MyIndexType> for [T; 8] {
    type Output = T;

    fn index(&self, index: MyIndexType) -> &T {
        unsafe { self.get_unchecked(index as usize) }
    }
}

fn main() {
    let array = [11u8; 8];

    println!("{:?}", array[MyIndexType::_0]); // OK

    println!("{:?}", array[0usize]); // error[E0277]
    //               ^^^^^^^^^^^^^ `[u8; 8]` cannot be indexed by `usize`
}
```

3 years agoUpdate E0744 about control flow in `const` contexts to reflect the current status...
James [Mon, 16 Nov 2020 02:34:16 +0000 (20:34 -0600)]
Update E0744 about control flow in `const` contexts to reflect the current status of `const fn`.

This is a squash of these commits:
- Update E0744 about control flow in `const` contexts to reflect current status of `const fn`.
- E0744 isn't just about `for` loops or control flow
- Fix formatting on E0744 cause my editor decided to not copy it well
- Improve wording
- Fix a markdown formatting error
- Fix E0744's description as I interpreted some code wrong
- Fix a minor wording issue again
- Add a few more links to blocking issues
- Improve links to tracking issues

3 years agoimprove error message for const ty param mismatch
Bastian Kauschke [Fri, 13 Nov 2020 19:23:37 +0000 (20:23 +0100)]
improve error message for const ty param mismatch

3 years agoImplement Index[Mut] for arrays
pubfnbar [Fri, 31 Jul 2020 20:19:10 +0000 (23:19 +0300)]
Implement Index[Mut] for arrays

Adds implementations of `Index` and `IndexMut` for arrays that simply forward to the slice indexing implementation.

3 years agoAuto merge of #78631 - ssomers:btree-alias_for_underfull, r=Mark-Simulacrum
bors [Mon, 16 Nov 2020 03:22:10 +0000 (03:22 +0000)]
Auto merge of #78631 - ssomers:btree-alias_for_underfull, r=Mark-Simulacrum

BTreeMap: fix pointer provenance rules in underfullness

Continuing on #78480, and for readability, and possibly for performance: avoid aliasing when handling underfull nodes, and consolidate the code doing that. In particular:
- Avoid the rather explicit aliasing for internal nodes in `remove_kv_tracking`.
- Climb down to the root to handle underfull nodes using a reborrowed handle, rather than one copied with `ptr::read`, before resuming on the leaf level.
- Integrate the code tracking leaf edge position into the functions performing changes, rather than bolting it on.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #79074 - Mark-Simulacrum:fix-ci-llvm, r=jyn514
bors [Mon, 16 Nov 2020 00:40:04 +0000 (00:40 +0000)]
Auto merge of #79074 - Mark-Simulacrum:fix-ci-llvm, r=jyn514

Install CI llvm into the library directory

In other words, my concern in https://github.com/rust-lang/rust/issues/78932#issuecomment-725781767 was perfectly justified by something we were already doing. For now just special case CI LLVM, but in the future we may want a more general fix.

Fixes #79071.

r? `@alexcrichton`

3 years agoIgnore doctest for capture analysis examples
Aman Arora [Sun, 15 Nov 2020 23:06:30 +0000 (18:06 -0500)]
Ignore doctest for capture analysis examples

3 years agoFix case when ExprUseVisitor is called after typeck writeback
Aman Arora [Sun, 15 Nov 2020 22:09:51 +0000 (17:09 -0500)]
Fix case when ExprUseVisitor is called after typeck writeback

Clippy uses `ExprUseVisitor` and atleast in some cases it runs
after writeback.

We currently don't writeback the min_capture results of closure
capture analysis since no place within the compiler itself uses it.

In the short term to fix clippy we add a fallback when walking captures
of a closure to check if closure_capture analysis has any entries in it.

Writeback for closure_min_captures will be implemented in
rust-lang/project-rfc-2229#18

3 years agoMake `Playground` public for error index generator
Joshua Nelson [Sun, 15 Nov 2020 11:44:23 +0000 (06:44 -0500)]
Make `Playground` public for error index generator

3 years agoMake `markdown` module public for doc-tests
Joshua Nelson [Sun, 15 Nov 2020 00:55:03 +0000 (19:55 -0500)]
Make `markdown` module public for doc-tests

3 years agoFix warnings
Joshua Nelson [Sat, 14 Nov 2020 23:02:06 +0000 (18:02 -0500)]
Fix warnings

3 years agoMake all rustdoc functions and structs crate-private
Joshua Nelson [Sat, 14 Nov 2020 22:59:58 +0000 (17:59 -0500)]
Make all rustdoc functions and structs crate-private

This gives warnings about dead code.

3 years agoAuto merge of #79064 - ehuss:rustbook-logs, r=Mark-Simulacrum
bors [Sun, 15 Nov 2020 15:39:58 +0000 (15:39 +0000)]
Auto merge of #79064 - ehuss:rustbook-logs, r=Mark-Simulacrum

Fix displaying errors when rustbook tests fail.

This ensures that output from mdbook is displayed when running the rustbook wrapper. I believe this was a regression as a result of #69115 where it was changed from running `rustdoc` directly to using rustbook.

3 years agoMake the libstd build script smaller
bjorn3 [Tue, 10 Nov 2020 18:01:21 +0000 (19:01 +0100)]
Make the libstd build script smaller

Remove all rustc-link-lib from the std build script. Also remove use of
feature = "restricted-std" where not necessary.

3 years agoInstall CI llvm into the library directory
Mark Rousskov [Sun, 15 Nov 2020 13:59:53 +0000 (08:59 -0500)]
Install CI llvm into the library directory

3 years agoAuto merge of #79070 - jonas-schievink:rollup-wacn2b8, r=jonas-schievink
bors [Sun, 15 Nov 2020 13:19:05 +0000 (13:19 +0000)]
Auto merge of #79070 - jonas-schievink:rollup-wacn2b8, r=jonas-schievink

Rollup of 13 pull requests

Successful merges:

 - #77802 (Allow making `RUSTC_BOOTSTRAP` conditional on the crate name)
 - #79004 (Add `--color` support to bootstrap)
 - #79005 (cleanup: Remove `ParseSess::injected_crate_name`)
 - #79016 (Make `_` an expression, to discard values in destructuring assignments)
 - #79019 (astconv: extract closures into a separate trait)
 - #79026 (Implement BTreeMap::retain and BTreeSet::retain)
 - #79031 (Validate that locals have a corresponding `LocalDecl`)
 - #79034 (rustc_resolve: Make `macro_rules` scope chain compression lazy)
 - #79036 (Move Steal to rustc_data_structures.)
 - #79041 (Rename clean::{ItemEnum -> ItemKind}, clean::Item::{inner -> kind})
 - #79058 (Move likely/unlikely argument outside of invisible unsafe block)
 - #79059 (Print 'checking cranelift artifacts' to easily separate it from other artifacts)
 - #79063 (Update rustfmt to v1.4.26)

Failed merges:

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

3 years agoRollup merge of #79063 - calebcartwright:update-rustfmt, r=Mark-Simulacrum
Jonas Schievink [Sun, 15 Nov 2020 12:40:07 +0000 (13:40 +0100)]
Rollup merge of #79063 - calebcartwright:update-rustfmt, r=Mark-Simulacrum

Update rustfmt to v1.4.26

3 years agoRollup merge of #79059 - jyn514:cranelift, r=Mark-Simulacrum
Jonas Schievink [Sun, 15 Nov 2020 12:40:05 +0000 (13:40 +0100)]
Rollup merge of #79059 - jyn514:cranelift, r=Mark-Simulacrum

Print 'checking cranelift artifacts' to easily separate it from other artifacts

Before:

```
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking rustdoc v0.0.0 (/home/joshua/rustc/src/librustdoc)
    Checking rustdoc-tool v0.0.0 (/home/joshua/rustc/src/tools/rustdoc)
    Finished release [optimized] target(s) in 2.08s
    Checking regalloc v0.0.31
    Checking gimli v0.22.0
    Checking object v0.21.1
    Checking cranelift-codegen v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-module v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-native v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-frontend v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-object v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-simplejit v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking rustc_codegen_cranelift v0.1.0 (/home/joshua/rustc/compiler/rustc_codegen_cranelift)
    Finished release [optimized] target(s) in 10.55s

```

After:

```
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking rustdoc v0.0.0 (/home/joshua/rustc/src/librustdoc)
    Checking rustdoc-tool v0.0.0 (/home/joshua/rustc/src/tools/rustdoc)
    Finished release [optimized] target(s) in 2.08s
Checking cranelift artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking cranelift-codegen v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
```

r? `@bjorn3`
`@bors` delegate=bjorn3

3 years agoRollup merge of #79058 - dtolnay:likelymacro, r=Mark-Simulacrum
Jonas Schievink [Sun, 15 Nov 2020 12:40:03 +0000 (13:40 +0100)]
Rollup merge of #79058 - dtolnay:likelymacro, r=Mark-Simulacrum

Move likely/unlikely argument outside of invisible unsafe block

The previous `likely!`/`unlikely!` macros were unsound because it permits the caller's expr to contain arbitrary unsafe code.

```rust
pub fn huh() -> bool {
    likely!(std::ptr::read(&() as *const () as *const bool))
}
```

**Before:** compiles cleanly.
**After:**

```console
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
   |
70 |     likely!(std::ptr::read(&() as *const () as *const bool))
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
   |
   = note: consult the function's documentation for information on how to avoid undefined behavior
```

3 years agoRollup merge of #79041 - jyn514:inner-to-kind, r=petrochenkov
Jonas Schievink [Sun, 15 Nov 2020 12:40:01 +0000 (13:40 +0100)]
Rollup merge of #79041 - jyn514:inner-to-kind, r=petrochenkov

Rename clean::{ItemEnum -> ItemKind}, clean::Item::{inner -> kind}

r? ````@petrochenkov````
cc ````@GuillaumeGomez````

Follow-up to https://github.com/rust-lang/rust/pull/77820#discussion_r502931757.

3 years agoRollup merge of #79036 - cjgillot:steal, r=oli-obk
Jonas Schievink [Sun, 15 Nov 2020 12:39:59 +0000 (13:39 +0100)]
Rollup merge of #79036 - cjgillot:steal, r=oli-obk

Move Steal to rustc_data_structures.

3 years agoRollup merge of #79034 - petrochenkov:mrscopes3, r=eddyb
Jonas Schievink [Sun, 15 Nov 2020 12:39:57 +0000 (13:39 +0100)]
Rollup merge of #79034 - petrochenkov:mrscopes3, r=eddyb

rustc_resolve: Make `macro_rules` scope chain compression lazy

As suggested in https://github.com/rust-lang/rust/pull/78826#issuecomment-723420664.

3 years agoRollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-schievink
Jonas Schievink [Sun, 15 Nov 2020 12:39:56 +0000 (13:39 +0100)]
Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-schievink

Validate that locals have a corresponding `LocalDecl`

Fixes #73356.

3 years agoRollup merge of #79026 - mbrubeck:btree_retain, r=m-ou-se
Jonas Schievink [Sun, 15 Nov 2020 12:39:54 +0000 (13:39 +0100)]
Rollup merge of #79026 - mbrubeck:btree_retain, r=m-ou-se

Implement BTreeMap::retain and BTreeSet::retain

Adds new methods `BTreeMap::retain` and `BTreeSet::retain`.  These are implemented on top of `drain_filter` (#70530).

The API of these methods is identical to `HashMap::retain` and `HashSet::retain`, which were implemented in #39560 and stabilized in #36648.  The docs and tests are also copied from HashMap/HashSet.

The new methods are unstable, behind the `btree_retain` feature gate, with tracking issue #79025.  See also rust-lang/rfcs#1338.

3 years agoRollup merge of #79019 - lcnr:generic-arg-validation, r=petrochenkov
Jonas Schievink [Sun, 15 Nov 2020 12:39:50 +0000 (13:39 +0100)]
Rollup merge of #79019 - lcnr:generic-arg-validation, r=petrochenkov

astconv: extract closures into a separate trait

Am currently looking into completely removing `check_generic_arg_count` and `create_substs_for_generic_args` was somewhat difficult to understand for me so I moved these closures into a trait.

This should not have changed the behavior of any of these methods

3 years agoRollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov
Jonas Schievink [Sun, 15 Nov 2020 12:39:48 +0000 (13:39 +0100)]
Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov

Make `_` an expression, to discard values in destructuring assignments

This is the third and final step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the third and final part of #71156, which was split up to allow for easier review.

With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance,
```rust
(a, _) = (1, 2)
```
will simply assign 1 to `a` and discard the 2. Note that for consistency,
```
_ = foo
```
is also allowed and equivalent to just `foo`.

Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating.

r? ````@petrochenkov````

3 years agoRollup merge of #79005 - petrochenkov:noinjected, r=davidtwco
Jonas Schievink [Sun, 15 Nov 2020 12:39:46 +0000 (13:39 +0100)]
Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwco

cleanup: Remove `ParseSess::injected_crate_name`

Its only remaining use is in pretty-printing where the necessary information can be easily re-computed.

3 years agoRollup merge of #79004 - jyn514:bacon, r=Mark-Simulacrum
Jonas Schievink [Sun, 15 Nov 2020 12:39:45 +0000 (13:39 +0100)]
Rollup merge of #79004 - jyn514:bacon, r=Mark-Simulacrum

Add `--color` support to bootstrap

When running under external utilities which wrap x.py, it can be convenient to force color support on.

3 years agoRollup merge of #77802 - jyn514:bootstrap-specific, r=nikomatsakis
Jonas Schievink [Sun, 15 Nov 2020 12:39:43 +0000 (13:39 +0100)]
Rollup merge of #77802 - jyn514:bootstrap-specific, r=nikomatsakis

Allow making `RUSTC_BOOTSTRAP` conditional on the crate name

Motivation: This came up in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Require.20users.20to.20confirm.20they.20know.20RUSTC_.E2.80.A6.20compiler-team.23350/near/208403962) for https://github.com/rust-lang/compiler-team/issues/350.
See also https://github.com/rust-lang/cargo/pull/6608#issuecomment-458546258; this implements https://github.com/rust-lang/cargo/issues/6627.
The goal is for this to eventually allow prohibiting setting `RUSTC_BOOTSTRAP` in build.rs (https://github.com/rust-lang/cargo/issues/7088).

## User-facing changes

- `RUSTC_BOOTSTRAP=1` still works; there is no current plan to remove this.
- Things like `RUSTC_BOOTSTRAP=0` no longer activate nightly features. In practice this shouldn't be a big deal, since `RUSTC_BOOTSTRAP` is the opposite of stable and everyone uses `RUSTC_BOOTSTRAP=1` anyway.
- `RUSTC_BOOTSTRAP=x` will enable nightly features only for crate `x`.
- `RUSTC_BOOTSTRAP=x,y` will enable nightly features only for crates `x` and `y`.

## Implementation changes

The main change is that `UnstableOptions::from_environment` now requires
an (optional) crate name. If the crate name is unknown (`None`), then the new feature is not available and you still have to use `RUSTC_BOOTSTRAP=1`. In practice this means the feature is only available for `--crate-name`, not for `#![crate_name]`; I'm interested in supporting the second but I'm not sure how.

Other major changes:

- Added `Session::is_nightly_build()`, which uses the `crate_name` of
the session
- Added `nightly_options::match_is_nightly_build`, a convenience method
for looking up `--crate-name` from CLI arguments.
`Session::is_nightly_build()`should be preferred where possible, since
it will take into account `#![crate_name]` (I think).
- Added `unstable_features` to `rustdoc::RenderOptions`

I'm not sure whether this counts as T-compiler or T-lang; _technically_ RUSTC_BOOTSTRAP is an implementation detail, but it's been used so much it seems like this counts as a language change too.

r? `@joshtriplett`
cc `@Mark-Simulacrum` `@hsivonen`

3 years agoAuto merge of #78472 - hermitcore:builtins, r=Mark-Simulacrum
bors [Sun, 15 Nov 2020 10:37:11 +0000 (10:37 +0000)]
Auto merge of #78472 - hermitcore:builtins, r=Mark-Simulacrum

add options to use optimized and mangled compiler builtins

In principle the compiler builtin features are also offered to alloc and std.

3 years agoadd options to use optimized and mangled compiler builtins
Stefan Lankes [Wed, 28 Oct 2020 06:54:30 +0000 (07:54 +0100)]
add options to use optimized and mangled compiler builtins

3 years agoAuto merge of #79065 - Dylan-DPC:rollup-gag1drk, r=Dylan-DPC
bors [Sun, 15 Nov 2020 02:21:18 +0000 (02:21 +0000)]
Auto merge of #79065 - Dylan-DPC:rollup-gag1drk, r=Dylan-DPC

Rollup of 15 pull requests

Successful merges:

 - #78352 (Do not call `unwrap` with `signatures` option enabled)
 - #78590 (refactor: removing alloc::collections::vec_deque ignore-tidy-filelength)
 - #78848 (Bump minimal supported LLVM version to 9)
 - #78856 (Explicitly checking for or-pattern before test)
 - #78948 (test: add `()=()=()=...` to weird-exprs.rs)
 - #78962 (Add a test for r# identifiers)
 - #78963 (Added some unit tests as requested)
 - #78966 (Never inline C variadics, cold functions, functions with incompatible attributes ...)
 - #78968 (Include llvm-as in llvm-tools-preview component)
 - #78969 (Normalize function type during validation)
 - #78980 (Fix rustc_ast_pretty print_qpath resulting in invalid macro input)
 - #78986 (Avoid installing external LLVM dylibs)
 - #78988 (Fix an intrinsic invocation on threaded wasm)
 - #78993 (rustc_target: Fix dash vs underscore mismatches in option names)
 - #79013 (Clean up outdated `use_once_payload` pretty printer comment)

Failed merges:

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

3 years agoRollup merge of #79013 - jryans:cleanup-use-once-pretty-comment, r=Mark-Simulacrum
Dylan DPC [Sun, 15 Nov 2020 02:03:01 +0000 (03:03 +0100)]
Rollup merge of #79013 - jryans:cleanup-use-once-pretty-comment, r=Mark-Simulacrum

Clean up outdated `use_once_payload` pretty printer comment

While reading some parts of the pretty printer code, I noticed this old comment
which seemed out of place. The `use_once_payload` this outdated comment mentions
was removed in 2017 in 40f03a1e0d6702add1922f82d716d5b2c23a59f0, so this
completes the work by removing the comment.

3 years agoRollup merge of #78993 - petrochenkov:specdash, r=oli-obk
Dylan DPC [Sun, 15 Nov 2020 02:02:59 +0000 (03:02 +0100)]
Rollup merge of #78993 - petrochenkov:specdash, r=oli-obk

rustc_target: Fix dash vs underscore mismatches in option names

Fixes https://github.com/rust-lang/rust/issues/78981 (regression from https://github.com/rust-lang/rust/pull/78875, the old option names used dashes)

3 years agoRollup merge of #78988 - alexcrichton:one-more-intrinsic, r=sfackler
Dylan DPC [Sun, 15 Nov 2020 02:02:57 +0000 (03:02 +0100)]
Rollup merge of #78988 - alexcrichton:one-more-intrinsic, r=sfackler

Fix an intrinsic invocation on threaded wasm

This looks like it was forgotten to get updated in #74482 and wasm with
threads isn't built on CI so we didn't catch this by accident.

3 years agoRollup merge of #78986 - Mark-Simulacrum:fix-llvm, r=alexcrichton
Dylan DPC [Sun, 15 Nov 2020 02:02:55 +0000 (03:02 +0100)]
Rollup merge of #78986 - Mark-Simulacrum:fix-llvm, r=alexcrichton

Avoid installing external LLVM dylibs

If the LLVM was externally provided, then we don't currently copy artifacts into
the sysroot. This is not necessarily the right choice (in particular, it will
require the LLVM dylib to be in the linker's load path at runtime), but the
common use case for external LLVMs is distribution provided LLVMs, and in that
case they're usually in the standard search path (e.g., /usr/lib) and copying
them here is going to cause problems as we may end up with the wrong files and
isn't what distributions want.

This behavior may be revisited in the future though.

Fixes #78932.

3 years agoRollup merge of #78980 - thiolliere:gui-fix-qpath, r=estebank
Dylan DPC [Sun, 15 Nov 2020 02:02:53 +0000 (03:02 +0100)]
Rollup merge of #78980 - thiolliere:gui-fix-qpath, r=estebank

Fix rustc_ast_pretty print_qpath resulting in invalid macro input

related https://github.com/rust-lang/rust/issues/76874 (third case)

### Issue:

The input for a procedural macro is incorrect, for the rust code:
```rust

mod m {
    pub trait Tr {
        type Ts: super::Tu;
    }
}

trait Tu {
    fn dummy() { }
}

#[may_proc_macro]
fn foo() {
    <T as m::Tr>::Ts::dummy();
}
```
the macro will get the input:
```rust
fn foo() {
    <T as m::Tr>::dummy();
}
```
Thus `Ts` has disappeared.

### Fix:

This is due to invalid pretty print of qpath. This PR fix it.

3 years agoRollup merge of #78969 - tmiasko:normalize, r=davidtwco
Dylan DPC [Sun, 15 Nov 2020 02:02:51 +0000 (03:02 +0100)]
Rollup merge of #78969 - tmiasko:normalize, r=davidtwco

Normalize function type during validation

During inlining, the callee body is normalized and has types revealed,
but some of locals corresponding to the arguments might come from the
caller body which is not. As a result the caller body does not pass
validation without additional normalization.

Closes #78442.

3 years agoRollup merge of #78968 - zec:add-llvm-as, r=Mark-Simulacrum
Dylan DPC [Sun, 15 Nov 2020 02:02:49 +0000 (03:02 +0100)]
Rollup merge of #78968 - zec:add-llvm-as, r=Mark-Simulacrum

Include llvm-as in llvm-tools-preview component

Including `llvm-as` adds the ability to include assembly language fragments that can be inlined using LTO while making sure the correct version of LLVM is always used.

3 years agoRollup merge of #78966 - tmiasko:inline-never, r=oli-obk
Dylan DPC [Sun, 15 Nov 2020 02:02:48 +0000 (03:02 +0100)]
Rollup merge of #78966 - tmiasko:inline-never, r=oli-obk

Never inline C variadics, cold functions, functions with incompatible attributes ...

... and fix generator inlining.

Closes #67863.
Closes #78859.

3 years agoRollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tmandry
Dylan DPC [Sun, 15 Nov 2020 02:02:46 +0000 (03:02 +0100)]
Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tmandry

Added some unit tests as requested

As discussed in PR #78267, for example:

* https://github.com/rust-lang/rust/pull/78267#discussion_r515404722
* https://github.com/rust-lang/rust/pull/78267#discussion_r515405958

r? ```````@tmandry```````
FYI: ```````@wesleywiser```````

This is pretty much self contained, but depending on feedback and timing, I may have a chance to add a few more unit tests requested against `counters.rs`. I'm looking at those now.

3 years agoRollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514
Dylan DPC [Sun, 15 Nov 2020 02:02:44 +0000 (03:02 +0100)]
Rollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514

Add a test for r# identifiers

I'm not entirely sure I properly ran the test locally (I think so though), waiting for CI to confirm. :)

```````@rustbot``````` modify labels: T-rustdoc

r? ```````@jyn514```````

3 years agoRollup merge of #78948 - slanterns:master, r=varkor
Dylan DPC [Sun, 15 Nov 2020 02:02:42 +0000 (03:02 +0100)]
Rollup merge of #78948 - slanterns:master, r=varkor

test: add `()=()=()=...` to weird-exprs.rs

Idea from https://github.com/rust-lang/rust/pull/71156#discussion_r410953972 😄

Builds on nightly since https://github.com/rust-lang/rust/pull/78748 has been merged.

3 years agoRollup merge of #78856 - mark-i-m:fix-or-pat-ice, r=matthewjasper
Dylan DPC [Sun, 15 Nov 2020 02:02:40 +0000 (03:02 +0100)]
Rollup merge of #78856 - mark-i-m:fix-or-pat-ice, r=matthewjasper

Explicitly checking for or-pattern before test

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

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

r? ````@varkor````

3 years agoRollup merge of #78848 - DevJPM:ci-llvm-9, r=nikic
Dylan DPC [Sun, 15 Nov 2020 02:02:39 +0000 (03:02 +0100)]
Rollup merge of #78848 - DevJPM:ci-llvm-9, r=nikic

Bump minimal supported LLVM version to 9

This bumps the minimal tested llvm version to 9.
This should enable supporting newer LLVM features (and CPU extensions).

This was motived by #78361 having to drop features because of LLVM 8 not supporting certain CPU extensions yet.
This was declared relatively uncontroversial on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Min.20Supported.20LLVM.20Upgrade.20Process.3F/near/215957859).

Paging ````@eddyb```` because there was a comment in the [dockerfile](https://github.com/rust-lang/rust/blob/master/src/ci/docker/host-x86_64/x86_64-gnu-llvm-8/Dockerfile#L42) describing a hack (which I don't quite understand) which was also blocked by not having LLVM 9.

3 years agoRollup merge of #78590 - DeveloperC286:issue_60302, r=varkor
Dylan DPC [Sun, 15 Nov 2020 02:02:37 +0000 (03:02 +0100)]
Rollup merge of #78590 - DeveloperC286:issue_60302, r=varkor

refactor: removing alloc::collections::vec_deque ignore-tidy-filelength

This PR removes the need for ignore-tidy-filelength for alloc::collections::vec_deque which is part of the issue https://github.com/rust-lang/rust/issues/60302

It is probably easiest to review this PR by looking at it commit by commit rather than looking at the overall diff.

3 years agoRollup merge of #78352 - JohnTitor:issue-75229, r=Dylan-DPC
Dylan DPC [Sun, 15 Nov 2020 02:02:34 +0000 (03:02 +0100)]
Rollup merge of #78352 - JohnTitor:issue-75229, r=Dylan-DPC

Do not call `unwrap` with `signatures` option enabled

Fixes #75229
Didn't add a test since I couldn't set `RUST_SAVE_ANALYSIS_CONFIG` even with `rustc-env`.

3 years agoFix displaying errors when rustbook tests fail.
Eric Huss [Sun, 15 Nov 2020 01:37:02 +0000 (17:37 -0800)]
Fix displaying errors when rustbook tests fail.

3 years agoUpdate rustfmt to v1.4.26
Caleb Cartwright [Sun, 15 Nov 2020 00:47:34 +0000 (18:47 -0600)]
Update rustfmt to v1.4.26

3 years agoPrint 'checking cranelift artifacts' to easily separate it from other artifacts
Joshua Nelson [Sat, 14 Nov 2020 22:35:50 +0000 (17:35 -0500)]
Print 'checking cranelift artifacts' to easily separate it from other artifacts

Before:

```
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking rustdoc v0.0.0 (/home/joshua/rustc/src/librustdoc)
    Checking rustdoc-tool v0.0.0 (/home/joshua/rustc/src/tools/rustdoc)
    Finished release [optimized] target(s) in 2.08s
    Checking regalloc v0.0.31
    Checking gimli v0.22.0
    Checking object v0.21.1
    Checking cranelift-codegen v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-module v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-native v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-frontend v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-object v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking cranelift-simplejit v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
    Checking rustc_codegen_cranelift v0.1.0 (/home/joshua/rustc/compiler/rustc_codegen_cranelift)
    Finished release [optimized] target(s) in 10.55s

```

After:

```
Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking rustdoc v0.0.0 (/home/joshua/rustc/src/librustdoc)
    Checking rustdoc-tool v0.0.0 (/home/joshua/rustc/src/tools/rustdoc)
    Finished release [optimized] target(s) in 2.08s
Checking cranelift artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Checking cranelift-codegen v0.67.0 (https://github.com/bytecodealliance/wasmtime/?branch=main#44cbdece)
```

3 years agoAuto merge of #79049 - tmiasko:lower-intrinsics, r=jonas-schievink
bors [Sat, 14 Nov 2020 22:05:54 +0000 (22:05 +0000)]
Auto merge of #79049 - tmiasko:lower-intrinsics, r=jonas-schievink

Lower intrinsics calls: forget, size_of, unreachable, wrapping_*

This allows constant propagation to evaluate `size_of` and `wrapping_*`,
and unreachable propagation to propagate a call to `unreachable`.

The lowering is performed as a MIR optimization, rather than during MIR
building to preserve the special status of intrinsics with respect to
unsafety checks and promotion.

Currently enabled by default to determine the performance impact (no
significant impact expected). In practice only useful when combined with
inlining since intrinsics are rarely used directly (with exception of
`unreachable` and `discriminant_value` used by built-in derive macros).

Closes #32716.

3 years agoMove likely/unlikely argument outside of invisible unsafe block
David Tolnay [Sat, 14 Nov 2020 21:54:45 +0000 (13:54 -0800)]
Move likely/unlikely argument outside of invisible unsafe block

The previous `likely!`/`unlikely!` macros were unsound because it
permits the caller's expr to contain arbitrary unsafe code.

    pub fn huh() -> bool {
        likely!(std::ptr::read(&() as *const () as *const bool))
    }

Before: compiles cleanly.
After:

    error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
       |
    70 |     likely!(std::ptr::read(&() as *const () as *const bool))
       |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
       |
       = note: consult the function's documentation for information on how to avoid undefined behavior

3 years agoAdd tests and improve rendering of features on traits
Wim Looman [Mon, 2 Nov 2020 18:17:33 +0000 (19:17 +0100)]
Add tests and improve rendering of features on traits

3 years agoAuto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obk
bors [Sat, 14 Nov 2020 18:03:17 +0000 (18:03 +0000)]
Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obk

add error_occured field to ConstQualifs,

fix #76064

I wasn't sure what `in_return_place` actually did and not sure why it returns `ConstQualifs` while it's sibling functions return `bool`. So I tried to make as minimal changes to the structure as possible. Please point out whether I have to refactor it or not.

r? `@oli-obk`
cc `@RalfJung`

3 years agoAdd underscore expressions for destructuring assignments
Fabian Zaiser [Wed, 11 Nov 2020 13:15:15 +0000 (13:15 +0000)]
Add underscore expressions for destructuring assignments

Co-authored-by: varkor <github@varkor.com>
3 years agoStyle nit
Who? Me?! [Sat, 14 Nov 2020 13:20:25 +0000 (07:20 -0600)]
Style nit

Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>
3 years agoAuto merge of #75272 - the8472:spec-copy, r=KodrAus
bors [Sat, 14 Nov 2020 12:01:55 +0000 (12:01 +0000)]
Auto merge of #75272 - the8472:spec-copy, r=KodrAus

specialize io::copy to use copy_file_range, splice or sendfile

Fixes #74426.
Also covers #60689 but only as an optimization instead of an official API.

The specialization only covers std-owned structs so it should avoid the problems with #71091

Currently linux-only but it should be generalizable to other unix systems that have sendfile/sosplice and similar.

There is a bit of optimization potential around the syscall count. Right now it may end up doing more syscalls than the naive copy loop when doing short (<8KiB) copies between file descriptors.

The test case executes the following:

```
[pid 103776] statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=17, ...}) = 0
[pid 103776] write(4, "wxyz", 4)        = 4
[pid 103776] write(4, "iklmn", 5)       = 5
[pid 103776] copy_file_range(3, NULL, 4, NULL, 5, 0) = 5

```

0-1 `stat` calls to identify the source file type. 0 if the type can be inferred from the struct from which the FD was extracted
𝖬 `write` to drain the `BufReader`/`BufWriter` wrappers. only happen when buffers are present. 𝖬 ≾ number of wrappers present. If there is a write buffer it may absorb the read buffer contents first so only result in a single write. Vectored writes would also be an option but that would require more invasive changes to `BufWriter`.
𝖭 `copy_file_range`/`splice`/`sendfile` until file size, EOF or the byte limit from `Take` is reached. This should generally be *much* more efficient than the read-write loop and also have other benefits such as DMA offload or extent sharing.

## Benchmarks

```

OLD

test io::tests::bench_file_to_file_copy         ... bench:      21,002 ns/iter (+/- 750) = 6240 MB/s    [ext4]
test io::tests::bench_file_to_file_copy         ... bench:      35,704 ns/iter (+/- 1,108) = 3671 MB/s  [btrfs]
test io::tests::bench_file_to_socket_copy       ... bench:      57,002 ns/iter (+/- 4,205) = 2299 MB/s
test io::tests::bench_socket_pipe_socket_copy   ... bench:     142,640 ns/iter (+/- 77,851) = 918 MB/s

NEW

test io::tests::bench_file_to_file_copy         ... bench:      14,745 ns/iter (+/- 519) = 8889 MB/s    [ext4]
test io::tests::bench_file_to_file_copy         ... bench:       6,128 ns/iter (+/- 227) = 21389 MB/s   [btrfs]
test io::tests::bench_file_to_socket_copy       ... bench:      13,767 ns/iter (+/- 3,767) = 9520 MB/s
test io::tests::bench_socket_pipe_socket_copy   ... bench:      26,471 ns/iter (+/- 6,412) = 4951 MB/s
```

3 years agoAuto merge of #78959 - petrochenkov:likeuefi, r=nagisa
bors [Sat, 14 Nov 2020 09:11:25 +0000 (09:11 +0000)]
Auto merge of #78959 - petrochenkov:likeuefi, r=nagisa

rustc_target: Mark UEFI targets as `is_like_windows`/`is_like_msvc`

And document what `is_like_windows` and `is_like_msvc` actually mean in more detail.

Addresses FIXMEs left from https://github.com/rust-lang/rust/pull/71030.
r? `@nagisa`

3 years agoRename ItemEnum -> ItemKind, inner -> kind
Joshua Nelson [Sat, 14 Nov 2020 08:45:10 +0000 (03:45 -0500)]
Rename ItemEnum -> ItemKind, inner -> kind

3 years agoAuto merge of #78951 - petrochenkov:unknown, r=ehuss
bors [Sat, 14 Nov 2020 06:44:18 +0000 (06:44 +0000)]
Auto merge of #78951 - petrochenkov:unknown, r=ehuss

rustc_target: Change os and vendor values to "none" and "unknown" for some targets

Closes https://github.com/rust-lang/rust/issues/77730
r? `@ehuss`

3 years agoAuto merge of #78736 - petrochenkov:lazyenum, r=Aaron1011
bors [Sat, 14 Nov 2020 04:21:56 +0000 (04:21 +0000)]
Auto merge of #78736 - petrochenkov:lazyenum, r=Aaron1011

rustc_parse: Remove optimization for 0-length streams in `collect_tokens`

The optimization conflates empty token streams with unknown token stream, which is at least suspicious, and doesn't affect performance because 0-length token streams are very rare.

r? `@Aaron1011`

3 years agoMove Steal to rustc_data_structures.
Camille GILLOT [Sat, 14 Nov 2020 00:29:30 +0000 (01:29 +0100)]
Move Steal to rustc_data_structures.

3 years agoLower intrinsics calls: forget, size_of, unreachable, wrapping_*
Tomasz Miąsko [Sat, 14 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Lower intrinsics calls: forget, size_of, unreachable, wrapping_*

This allows constant propagation to evaluate `size_of` and `wrapping_*`,
and unreachable propagation to propagate a call to `unreachable`.

The lowering is performed as a MIR optimization, rather than during MIR
building to preserve the special status of intrinsics with respect to
unsafety checks and promotion.

3 years agoAuto merge of #78683 - Nemo157:issue-78673, r=lcnr
bors [Fri, 13 Nov 2020 23:12:01 +0000 (23:12 +0000)]
Auto merge of #78683 - Nemo157:issue-78673, r=lcnr

Check predicates from blanket trait impls while testing if they apply

fixes #78673

3 years agoAlways handle EOVERFLOW by falling back to the generic copy loop
The8472 [Thu, 12 Nov 2020 22:39:49 +0000 (23:39 +0100)]
Always handle EOVERFLOW by falling back to the generic copy loop

Previously EOVERFLOW handling was only applied for io::copy specialization
but not for fs::copy sharing the same code.

Additionally we lower the chunk size to 1GB since we have a user report
that older kernels may return EINVAL when passing 0x8000_0000
but smaller values succeed.

3 years agodo direct splice syscall and probe availability to get android builds to work
The8472 [Fri, 6 Nov 2020 22:36:23 +0000 (23:36 +0100)]
do direct splice syscall and probe availability to get android builds to work

Android builds use feature level 14, the libc wrapper for splice is gated
on feature level 21+ so we have to invoke the syscall directly.
Additionally the emulator doesn't seem to support it so we also have to
add ENOSYS checks.

3 years agomove sendfile/splice/copy_file_range into kernel_copy module
The8472 [Thu, 15 Oct 2020 01:07:57 +0000 (03:07 +0200)]
move sendfile/splice/copy_file_range into kernel_copy module

3 years agolimit visibility of copy offload helpers to sys::unix module
The8472 [Wed, 14 Oct 2020 23:51:47 +0000 (01:51 +0200)]
limit visibility of copy offload helpers to sys::unix module

3 years agomove copy specialization tests to their own module
The8472 [Wed, 7 Oct 2020 21:07:04 +0000 (23:07 +0200)]
move copy specialization tests to their own module

3 years agomove copy specialization into sys::unix module
The8472 [Tue, 6 Oct 2020 23:01:12 +0000 (01:01 +0200)]
move copy specialization into sys::unix module

3 years agorustc_resolve: Make `macro_rules` scope chain compression lazy
Vadim Petrochenkov [Fri, 13 Nov 2020 21:05:05 +0000 (00:05 +0300)]
rustc_resolve: Make `macro_rules` scope chain compression lazy

3 years agoLog closure as well
Aman Arora [Fri, 13 Nov 2020 06:51:19 +0000 (01:51 -0500)]
Log closure as well

3 years agoValidate that locals have a corresponding `LocalDecl`
Camelid [Fri, 13 Nov 2020 19:23:12 +0000 (11:23 -0800)]
Validate that locals have a corresponding `LocalDecl`

3 years agoAuto merge of #78888 - richkadel:llvm-coverage-tests, r=tmandry
bors [Fri, 13 Nov 2020 20:06:46 +0000 (20:06 +0000)]
Auto merge of #78888 - richkadel:llvm-coverage-tests, r=tmandry

Fix and re-enable two coverage tests on MacOS

Note, in the coverage-reports test, the comment about MacOS was wrong.
The setting is based on config.toml llvm `optimize` setting. There
doesn't appear to be any environment variable I can check, and I
don't think we should add one. Testing the binary itself is a more
reliable way to check anyway.

For the coverage-spanview test, I removed the dependency on sed
altogether, which is much less ugly than trying to work around the
MacOS sed differences.

I tested these changes on Linux, Windows, and Mac.

r? `@tmandry`
FYI `@wesleywiser`

3 years agoadd benchmarks
The8472 [Fri, 4 Sep 2020 22:34:16 +0000 (00:34 +0200)]
add benchmarks

3 years agoreduce syscalls by inferring FD types based on source struct instead of calling stat()
The8472 [Thu, 10 Sep 2020 20:12:42 +0000 (22:12 +0200)]
reduce syscalls by inferring FD types based on source struct instead of calling stat()

also adds handling for edge-cases involving large sparse files where sendfile could fail with EOVERFLOW