]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #76434 - RalfJung:black-box, r=Mark-Simulacrum
Ralf Jung [Sat, 19 Sep 2020 09:47:43 +0000 (11:47 +0200)]
Rollup merge of #76434 - RalfJung:black-box, r=Mark-Simulacrum

do not inline black_box when building for Miri

We cannot do the assembly trick in Miri, but let's at least make sure MIR inlining does not circumvent the black_box.

Also use black_box instead of local optimization barriers in a few const tests.

3 years agoRollup merge of #76400 - pickfire:patch-5, r=dtolnay
Ralf Jung [Sat, 19 Sep 2020 09:47:41 +0000 (11:47 +0200)]
Rollup merge of #76400 - pickfire:patch-5, r=dtolnay

Clean up vec benches bench_in_place style

3 years agoRollup merge of #76310 - scottmcm:array-try_from-vec, r=dtolnay
Ralf Jung [Sat, 19 Sep 2020 09:47:39 +0000 (11:47 +0200)]
Rollup merge of #76310 - scottmcm:array-try_from-vec, r=dtolnay

Add `[T; N]: TryFrom<Vec<T>>` (insta-stable)

This is very similar to the [existing](https://doc.rust-lang.org/nightly/std/convert/trait.TryFrom.html#impl-TryFrom%3CBox%3C%5BT%5D%3E%3E) `Box<[T; N]>: TryFrom<Box<[T]>>`, but allows avoiding the `shrink_to_fit` if you have a vector and not a boxed slice.

Like the slice equivalents of this, it fails if the length of the vector is not exactly `N`.
This uses `Vec<T>` as the `Error` type to return the input, like how the `Rc<[T]> -> Rc<[T; N]>` (and Arc) ones also reflect the input directly in the error type.

```rust
#[stable(feature = "array_try_from_vec", since = "1.47.0")]
impl<T, const N: usize> TryFrom<Vec<T>> for [T; N] {
    type Error = Vec<T>;
    fn try_from(mut vec: Vec<T>) -> Result<[T; N], Vec<T>>;
}
```

Inspired by this zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/APIs.20for.20getting.20stuff.20from.20a.20Vec.20by.20owned/near/209048103

3 years agoRollup merge of #75580 - JulianKnodt:or_pattern, r=wesleywiser
Ralf Jung [Sat, 19 Sep 2020 09:47:37 +0000 (11:47 +0200)]
Rollup merge of #75580 - JulianKnodt:or_pattern, r=wesleywiser

Add test for checking duplicated branch or-patterns

This adds a regression test for checking `or-patterns` in MIR as shown in #75439.
This doesn't introduce a fix as I'm not sure where it would go(I suspect maybe here: src/librustc_mir_build/build/matches/mod.rs), and I'm not particularly able to fix it.

cc: @lzutao

3 years agoRollup merge of #75502 - ecstatic-morse:implicit-promotion-in-const-fn, r=RalfJung
Ralf Jung [Sat, 19 Sep 2020 09:47:35 +0000 (11:47 +0200)]
Rollup merge of #75502 - ecstatic-morse:implicit-promotion-in-const-fn, r=RalfJung

Use implicit (not explicit) rules for promotability by default in `const fn`

For crater run. See https://github.com/rust-lang/const-eval/pull/54#discussion_r469995552.

cc #75586

3 years agoRollup merge of #75099 - davidtwco:is-zst-abstraction-violation, r=eddyb
Ralf Jung [Sat, 19 Sep 2020 09:47:34 +0000 (11:47 +0200)]
Rollup merge of #75099 - davidtwco:is-zst-abstraction-violation, r=eddyb

lint/ty: move fns to avoid abstraction violation

This PR moves `transparent_newtype_field` and `is_zst` to `LateContext` where they are used, rather than being on the `VariantDef` and `TyS` types, hopefully addressing @eddyb's concern [from this comment](https://github.com/rust-lang/rust/pull/74340#discussion_r456534910).

3 years agoRollup merge of #73963 - hellow554:unsafe_path, r=Mark-Simulacrum
Ralf Jung [Sat, 19 Sep 2020 09:47:31 +0000 (11:47 +0200)]
Rollup merge of #73963 - hellow554:unsafe_path, r=Mark-Simulacrum

deny(unsafe_op_in_unsafe_fn) in libstd/path.rs

The libstd/path.rs part of #73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.

3 years agoAuto merge of #76879 - shepmaster:zlib-sys, r=Mark-Simulacrum
bors [Sat, 19 Sep 2020 06:28:37 +0000 (06:28 +0000)]
Auto merge of #76879 - shepmaster:zlib-sys, r=Mark-Simulacrum

Upgrade libz-sys to 1.1.2

The current version has warnings that become errors on new versions of clang shipped in XCode:

```
warning: src/zlib/gzlib.c:214:15: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Werror,-Wimplicit-function-declaration]
warning:         (void)snprintf(state->path, len + 1, "%s", (const char *)path);
warning:               ^
warning: src/zlib/gzlib.c:214:15: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
warning: 1 error generated.

warning: src/zlib/gzwrite.c:428:11: error: implicitly declaring library function 'vsnprintf' with type 'int (char *, unsigned long, const char *, __builtin_va_list)' [-Werror,-Wimplicit-function-declaration
warning:     len = vsnprintf(next, state->size, format, va);
warning:           ^
warning: src/zlib/gzwrite.c:428:11: note: include the header <stdio.h> or explicitly provide a declaration for 'vsnprintf'
warning: 1 error generated.
```

r? `@Mark-Simulacrum`

/cc `@joshtriplett`

3 years agoAuto merge of #76856 - jonas-schievink:dist-rustc-src, r=Mark-Simulacrum
bors [Sat, 19 Sep 2020 04:21:11 +0000 (04:21 +0000)]
Auto merge of #76856 - jonas-schievink:dist-rustc-src, r=Mark-Simulacrum

Distribute rustc sources as part of `rustc-dev`

They can be used to provide IDE features when working on rustc plugins/backends/etc without having to locate a separate Rust checkout.

r? `@Mark-Simulacrum`

3 years agoAuto merge of #76838 - est31:dogfood_uninit_features, r=oli-obk
bors [Sat, 19 Sep 2020 02:21:19 +0000 (02:21 +0000)]
Auto merge of #76838 - est31:dogfood_uninit_features, r=oli-obk

Dogfood new_uninit and maybe_uninit_slice in rustc_arena

Dogfoods a few cool `MaybeUninit` related features in the compiler's rustc_arena crate.

Split off from #76821

r? `@oli-obk`

3 years agoAuto merge of #76787 - lzutao:slice_iters_new, r=lcnr
bors [Fri, 18 Sep 2020 23:38:17 +0000 (23:38 +0000)]
Auto merge of #76787 - lzutao:slice_iters_new, r=lcnr

Using <Iter>::new instead of exposing internal fields

As requested in https://github.com/rust-lang/rust/pull/76311#discussion_r487685126

3 years agoAuto merge of #76782 - lzutao:rd-cap, r=jyn514
bors [Fri, 18 Sep 2020 21:31:08 +0000 (21:31 +0000)]
Auto merge of #76782 - lzutao:rd-cap, r=jyn514

Specialize merge_attrs in good case

Just a non-important micro-optimization.
r? `@jyn514`

3 years agoAuto merge of #76884 - Mark-Simulacrum:fix-macos-ci, r=pietroalbini
bors [Fri, 18 Sep 2020 19:13:02 +0000 (19:13 +0000)]
Auto merge of #76884 - Mark-Simulacrum:fix-macos-ci, r=pietroalbini

Add host triples to target lists

This PR is primarily intended to fix https://github.com/rust-lang/rustup/issues/2494, which is the second commit. That bug was introduced by #76415, and incompletely fixed by #76639. (#76639 added host triples, which gave us compilers, but missed that we also need documentation and other target-only things). However, it also removes duplicate macOS CI builders.

r? `@pietroalbini`

3 years agoAuto merge of #76575 - lcnr:abstract-const, r=oli-obk
bors [Fri, 18 Sep 2020 16:59:50 +0000 (16:59 +0000)]
Auto merge of #76575 - lcnr:abstract-const, r=oli-obk

compare generic constants using `AbstractConst`s

This is a MVP of rust-lang/compiler-team#340. The changes in this PR should only be relevant if `feature(const_evaluatable_checked)` is enabled.

~~currently based on top of #76559, so blocked on that.~~

r? `@oli-obk` cc `@varkor` `@eddyb`

3 years agoMake sure we build target-only things (e.g., docs) for host platforms too
Mark Rousskov [Fri, 18 Sep 2020 15:56:41 +0000 (11:56 -0400)]
Make sure we build target-only things (e.g., docs) for host platforms too

3 years agoRemove duplicate macOS builders
Mark Rousskov [Fri, 18 Sep 2020 15:54:00 +0000 (11:54 -0400)]
Remove duplicate macOS builders

3 years agoadd `const-evaluatable_checked` check back in
Bastian Kauschke [Fri, 18 Sep 2020 15:36:11 +0000 (17:36 +0200)]
add `const-evaluatable_checked` check back in

3 years agoreview, small cleanup
Bastian Kauschke [Fri, 18 Sep 2020 15:11:17 +0000 (17:11 +0200)]
review, small cleanup

3 years agodocument `const_evaluatable`
Bastian Kauschke [Fri, 11 Sep 2020 19:50:17 +0000 (21:50 +0200)]
document `const_evaluatable`

3 years agoremove allow(warnings)
Bastian Kauschke [Fri, 11 Sep 2020 19:19:15 +0000 (21:19 +0200)]
remove allow(warnings)

3 years agosupport const_evaluatable_checked across crate boundaries
Bastian Kauschke [Fri, 11 Sep 2020 19:16:16 +0000 (21:16 +0200)]
support const_evaluatable_checked across crate boundaries

3 years agoadd test for let-bindings
Bastian Kauschke [Fri, 11 Sep 2020 08:46:35 +0000 (10:46 +0200)]
add test for let-bindings

3 years agoadd function calls
Bastian Kauschke [Fri, 11 Sep 2020 08:35:28 +0000 (10:35 +0200)]
add function calls

3 years agoallow unary operations and ignore StorageLive/Dead stmts
Bastian Kauschke [Fri, 11 Sep 2020 08:00:06 +0000 (10:00 +0200)]
allow unary operations and ignore StorageLive/Dead stmts

3 years agouse newtype_index for abstract_const::NodeId
Bastian Kauschke [Fri, 11 Sep 2020 07:18:54 +0000 (09:18 +0200)]
use newtype_index for abstract_const::NodeId

3 years agorefactor AbstractConstBuilder
Bastian Kauschke [Fri, 11 Sep 2020 07:00:21 +0000 (09:00 +0200)]
refactor AbstractConstBuilder

3 years agouse abstract consts when unifying ConstKind::Unevaluated
Bastian Kauschke [Thu, 10 Sep 2020 16:48:18 +0000 (18:48 +0200)]
use abstract consts when unifying ConstKind::Unevaluated

3 years agoinitial working state
Bastian Kauschke [Thu, 10 Sep 2020 07:06:30 +0000 (09:06 +0200)]
initial working state

3 years agoAuto merge of #72412 - VFLashM:issue-72408-nested-closures-exponential, r=tmandry
bors [Fri, 18 Sep 2020 14:08:39 +0000 (14:08 +0000)]
Auto merge of #72412 - VFLashM:issue-72408-nested-closures-exponential, r=tmandry

Issue 72408 nested closures exponential

This fixes #72408.

Nested closures were resulting in exponential compilation time.

This PR is enhancing asymptotic complexity, but also increasing the constant, so I would love to see perf run results.

3 years agoUpgrade libz-sys to 1.1.2
Jake Goulding [Fri, 18 Sep 2020 00:14:09 +0000 (20:14 -0400)]
Upgrade libz-sys to 1.1.2

3 years agoAuto merge of #76837 - wesleywiser:disable_consideredequal, r=oli-obk
bors [Fri, 18 Sep 2020 10:54:14 +0000 (10:54 +0000)]
Auto merge of #76837 - wesleywiser:disable_consideredequal, r=oli-obk

[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame opt

The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)

r? `@oli-obk`

3 years agoRemove redundancy in cache key
Tyler Mandry [Fri, 18 Sep 2020 06:07:19 +0000 (06:07 +0000)]
Remove redundancy in cache key

3 years agoinline inner function of inlining methods
Lzu Tao [Thu, 17 Sep 2020 09:23:14 +0000 (09:23 +0000)]
inline inner function of inlining methods

3 years agoMove unsafe code of slice `new` function of their Iterator structs
Lzu Tao [Thu, 17 Sep 2020 09:14:28 +0000 (09:14 +0000)]
Move unsafe code of slice `new` function of their Iterator structs

Init false state in Split* constructors

3 years agoAuto merge of #76854 - aDotInTheVoid:mir-opt-32-64-diff-name, r=oli-obk
bors [Fri, 18 Sep 2020 08:28:03 +0000 (08:28 +0000)]
Auto merge of #76854 - aDotInTheVoid:mir-opt-32-64-diff-name, r=oli-obk

Rename mir-opt diff tests with 32/64 bit

Now syntax highlighting should work.

I've tested that `--bless` works localy, but I'm not sure it's possible on CI

Fixes #75746

r? `@oli-obk`

3 years agoAuto merge of #76790 - ssomers:btree_slice_slasher_returns, r=Mark-Simulacrum
bors [Fri, 18 Sep 2020 05:47:00 +0000 (05:47 +0000)]
Auto merge of #76790 - ssomers:btree_slice_slasher_returns, r=Mark-Simulacrum

BTreeMap: avoid slices even more

Epilogue to #73971: it seems the compiler is unable to realize that creating a slice and `get_unchecked`-ing one element is a simple fetch. So try to spell it out for the only remaining but often invoked case.

Also, the previous code doesn't seem fair game to me, using `get_unchecked` to reach beyond the end of a slice. Although the local function `slice_insert` also does that.

r? `@Mark-Simulacrum`

3 years agoAdd bench_typed_arena_clear_100 bench
est31 [Fri, 18 Sep 2020 03:52:45 +0000 (05:52 +0200)]
Add bench_typed_arena_clear_100 bench

3 years agoReplace loop with drop_in_place call
est31 [Thu, 17 Sep 2020 15:20:22 +0000 (17:20 +0200)]
Replace loop with drop_in_place call

3 years agoDogfood new_uninit and maybe_uninit_slice in rustc_arena
est31 [Thu, 17 Sep 2020 14:40:02 +0000 (16:40 +0200)]
Dogfood new_uninit and maybe_uninit_slice in rustc_arena

3 years agoCalculate more correct capacity in merge_attrs
Lzu Tao [Fri, 18 Sep 2020 01:55:40 +0000 (01:55 +0000)]
Calculate more correct capacity in merge_attrs

Co-authored-by: jyn514 <joshua@yottadb.com>
3 years agoIntorduced MiniMap - a tiny small storage optimized map implementation
Valerii Lashmanov [Fri, 18 Sep 2020 01:43:29 +0000 (20:43 -0500)]
Intorduced MiniMap - a tiny small storage optimized map implementation

This makes everything about 1% faster in rustc-perf,
mostly negating performance hit of previous commit.

3 years agoBetter handling for exponential-sized types in misc places
Valerii Lashmanov [Tue, 15 Sep 2020 23:22:24 +0000 (18:22 -0500)]
Better handling for exponential-sized types in misc places

Mostly to fix ui/issues/issue-37311-type-length-limit/issue-37311.rs.

Most parts of the compiler can handle deeply nested types with a lot
of duplicates just fine, but some parts still attempt to naively
traverse type tree.

Before such problems were caught by type length limit check,
but now these places will have to be changed to handle
duplicated types gracefully.

3 years agoOnly visit types once when walking the type tree
Valerii Lashmanov [Tue, 15 Sep 2020 14:37:19 +0000 (09:37 -0500)]
Only visit types once when walking the type tree

This fixes #72408.

Nested closures were resulting in exponential compilation time.

As a performance optimization this change introduces MiniSet,
which is a simple small storage optimized set.

3 years agoFix --bless for mir-opt 32/64 bit file
Nixon Enraght-Moony [Thu, 17 Sep 2020 21:25:33 +0000 (22:25 +0100)]
Fix --bless for mir-opt 32/64 bit file

3 years agoDistribute rustc sources as part of `rustc-dev`
Jonas Schievink [Thu, 17 Sep 2020 22:18:19 +0000 (00:18 +0200)]
Distribute rustc sources as part of `rustc-dev`

3 years agoRename 32 bit mir files to be more tool friendly
Nixon Enraght-Moony [Thu, 17 Sep 2020 20:49:21 +0000 (21:49 +0100)]
Rename 32 bit mir files to be more tool friendly

See #75746

3 years agoRename 64 bit mir files to be more tool friendly
Nixon Enraght-Moony [Thu, 17 Sep 2020 20:35:21 +0000 (21:35 +0100)]
Rename 64 bit mir files to be more tool friendly

See #75746

3 years agoPut bit qualifier before mir/diff
Nixon Enraght-Moony [Thu, 17 Sep 2020 20:32:02 +0000 (21:32 +0100)]
Put bit qualifier before mir/diff

3 years agoAuto merge of #76645 - fusion-engineering-forks:windows-lock, r=kennytm
bors [Thu, 17 Sep 2020 19:23:58 +0000 (19:23 +0000)]
Auto merge of #76645 - fusion-engineering-forks:windows-lock, r=kennytm

 Small cleanups in Windows Mutex.

 - Move `held` into the boxed part, since the SRW lock implementation does not use this. This makes the Mutex 50% smaller.
 - Use `Cell` instead of `UnsafeCell` for `held`, such that `.replace()` can be used.
 - Add some comments.
 - Avoid creating multiple `&mut`s to the critical section object in `ReentrantMutex`.

3 years agoDefault to implicit (not explicit) rules for promotability in `const fn`
Dylan MacKenzie [Tue, 1 Sep 2020 19:28:55 +0000 (12:28 -0700)]
Default to implicit (not explicit) rules for promotability in `const fn`

3 years ago[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame opt
Wesley Wiser [Thu, 17 Sep 2020 13:29:39 +0000 (09:29 -0400)]
[mir-opt] Disable the `ConsideredEqual` logic in SimplifyBranchSame opt

The logic is currently broken and we need to disable it to fix a beta
regression (see #76803)

3 years agoAuto merge of #76634 - RalfJung:miri-guaranteed-eq-ne, r=oli-obk
bors [Thu, 17 Sep 2020 12:15:57 +0000 (12:15 +0000)]
Auto merge of #76634 - RalfJung:miri-guaranteed-eq-ne, r=oli-obk

move guaranteed{ne,eq} implementation to compile-time machine

Currently, Miri needs a special hack to avoid using the core engine implementation of these intrinsics. That seems silly, so let's move them to the CTFE machine, which is the only machine that wants to use them.

I also added a reference to https://github.com/rust-lang/rust/issues/73722 as a warning to anyone who wants to adjust `guaranteed_eq`.

3 years agoUsing <Iter>::new instead of exposing internal fields
Lzu Tao [Wed, 16 Sep 2020 09:42:05 +0000 (09:42 +0000)]
Using <Iter>::new instead of exposing internal fields

3 years agoAuto merge of #76028 - aticu:improve_e0118, r=estebank,jyn514,GuillaumeGomez
bors [Thu, 17 Sep 2020 03:56:38 +0000 (03:56 +0000)]
Auto merge of #76028 - aticu:improve_e0118, r=estebank,jyn514,GuillaumeGomez

Improve E0118

- Changes the "base type" terminology to "nominal type" (according to the [reference](https://doc.rust-lang.org/stable/reference/items/implementations.html#inherent-implementations)).
- Suggests removing a reference, if one is present on the type.
- Clarify what is meant by a "nominal type".

closes #69392

This is my first not-entirely-trivial PR, so please let me know if I missed anything or if something could be improved. Though I probably won't be able to fix anything in the upcoming week.

3 years agoAuto merge of #76804 - tmandry:rollup-nwntt3q, r=tmandry
bors [Wed, 16 Sep 2020 20:18:19 +0000 (20:18 +0000)]
Auto merge of #76804 - tmandry:rollup-nwntt3q, r=tmandry

Rollup of 16 pull requests

Successful merges:

 - #75026 (Add array_windows fn)
 - #76642 (Do not lint ignored private doc tests)
 - #76719 (Change error message for ty param in const)
 - #76721 (Use intra-doc links in `core::mem`)
 - #76728 (Add a comment why `extern crate` is necessary for rustdoc)
 - #76735 (Remove unnecessary `clone()`s in bootstrap)
 - #76741 (Avoid printing dry run timings)
 - #76747 (Add missing code examples in libcore)
 - #76756 (fix a couple of stylistic clippy warnings)
 - #76758 ([fuchsia] Propagate the userspace UTC clock)
 - #76759 (Fix stabilization marker for future_readiness_fns)
 - #76760 (don't lazily evaluate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations))
 - #76764 (Update books)
 - #76775 (Strip a single leading tab when rendering dataflow diffs)
 - #76778 (Simplify iter fuse struct doc)
 - #76794 (Make graphviz font configurable)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76794 - richkadel:graphviz-font, r=ecstatic-morse
Tyler Mandry [Wed, 16 Sep 2020 19:24:30 +0000 (12:24 -0700)]
Rollup merge of #76794 - richkadel:graphviz-font, r=ecstatic-morse

Make graphviz font configurable

Alternative to PR #76776.

To change the graphviz output to use an alternative `fontname` value,
add a command line option like: `rustc --graphviz-font=monospace`.

r? @ecstatic-morse

3 years agoRollup merge of #76778 - pickfire:patch-7, r=jonas-schievink
Tyler Mandry [Wed, 16 Sep 2020 19:24:28 +0000 (12:24 -0700)]
Rollup merge of #76778 - pickfire:patch-7, r=jonas-schievink

Simplify iter fuse struct doc

3 years agoRollup merge of #76775 - ecstatic-morse:dataflow-extra-tab-diff, r=Mark-Simulacrum
Tyler Mandry [Wed, 16 Sep 2020 19:24:27 +0000 (12:24 -0700)]
Rollup merge of #76775 - ecstatic-morse:dataflow-extra-tab-diff, r=Mark-Simulacrum

Strip a single leading tab when rendering dataflow diffs

The `fmt_diff_with` formatter uses a tab to separate additions from subtractions. Strip it when rendering those diffs on separate lines.

r? @Mark-Simulacrum (since you're speedy)

3 years agoRollup merge of #76764 - ehuss:update-books, r=ehuss
Tyler Mandry [Wed, 16 Sep 2020 19:24:25 +0000 (12:24 -0700)]
Rollup merge of #76764 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in 25854752549d44d76fbd7650e17cb4f167a0b8fb..6e57e64501f61873ab80cb78a07180a22751a5d6
2020-08-19 16:41:48 -0400 to 2020-09-14 11:40:23 -0400
- Fix API change to alloc::Global::grow. (rust-lang-nursery/nomicon#236)

## reference

3 commits in 25391dba46262f882fa846beefaff54a966a8fa5..56a13c082ee90736c08d6abdcd90462517b703d3
2020-09-02 07:22:55 -0700 to 2020-09-14 23:20:16 -0700
- Update the description of staticlib (rust-lang-nursery/reference#884)
- Rust 1.46 now allows more features in const fn (rust-lang-nursery/reference#883)
- Document the enum changes in RFC 2195 (rust-lang-nursery/reference#879)

## book

1 commits in e5ed97128302d5fa45dbac0e64426bc7649a558c..cb28dee95e5e50b793e6ba9291c5d1568d3ad72e
2020-08-31 12:53:40 -0500 to 2020-09-09 10:06:00 -0500
- Fixed the error message of invalid array element access in ch03.2 (rust-lang/book#2446)

3 years agoRollup merge of #76760 - matthiaskrgr:clippy_lazy_eval, r=varkor
Tyler Mandry [Wed, 16 Sep 2020 19:24:23 +0000 (12:24 -0700)]
Rollup merge of #76760 - matthiaskrgr:clippy_lazy_eval, r=varkor

don't lazily evaluate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations)

3 years agoRollup merge of #76759 - yoshuawuyts:fix-future-pending-ready-stabilization-label...
Tyler Mandry [Wed, 16 Sep 2020 19:24:21 +0000 (12:24 -0700)]
Rollup merge of #76759 - yoshuawuyts:fix-future-pending-ready-stabilization-label, r=Dylan-DPC

Fix stabilization marker for future_readiness_fns

Updated the rustc version in which this will be stabilized from `1.47.0 -> 1.48.0`. Fixes https://github.com/rust-lang/rust/pull/74328#issuecomment-692133125. Ref #70921.

r? @Dylan-DPC

3 years agoRollup merge of #76758 - adamlesinski:clone_clock, r=tmandry
Tyler Mandry [Wed, 16 Sep 2020 19:24:19 +0000 (12:24 -0700)]
Rollup merge of #76758 - adamlesinski:clone_clock, r=tmandry

[fuchsia] Propagate the userspace UTC clock

On Fuchsia, spawning a subprocess does not automatically
clone all of the parent process' capabilities. UTC time on
Fuchsia is managed by a top-level userspace clock capability
that is cloned and passed to subprocesses.

This change ensures that any Rust subprocess gets access to the
UTC clock, if the parent had access to it. This is critical for
tests, which on Fuchsia, use panic=abort and spawn subprocesses
per test.

3 years agoRollup merge of #76756 - matthiaskrgr:cl123ppy, r=Dylan-DPC
Tyler Mandry [Wed, 16 Sep 2020 19:24:17 +0000 (12:24 -0700)]
Rollup merge of #76756 - matthiaskrgr:cl123ppy, r=Dylan-DPC

fix a couple of stylistic clippy warnings

namely:

clippy::redundant_pattern_matching
clippy::redundant_pattern
clippy::search_is_some
clippy::filter_next
clippy::into_iter_on_ref
clippy::clone_on_copy
clippy::needless_return

3 years agoRollup merge of #76747 - GuillaumeGomez:more-missing-libcore-code-examples, r=Mark...
Tyler Mandry [Wed, 16 Sep 2020 19:24:16 +0000 (12:24 -0700)]
Rollup merge of #76747 - GuillaumeGomez:more-missing-libcore-code-examples, r=Mark-Simulacrum

Add missing code examples in libcore

3 years agoRollup merge of #76741 - Mark-Simulacrum:no-dry-run-timing, r=alexcrichton
Tyler Mandry [Wed, 16 Sep 2020 19:24:14 +0000 (12:24 -0700)]
Rollup merge of #76741 - Mark-Simulacrum:no-dry-run-timing, r=alexcrichton

Avoid printing dry run timings

This avoids a wall of text on CI with 0.000 as the likely time.

r? @alexcrichton

3 years agoRollup merge of #76735 - jyn514:no-clone, r=Mark-Simulacrum
Tyler Mandry [Wed, 16 Sep 2020 19:24:12 +0000 (12:24 -0700)]
Rollup merge of #76735 - jyn514:no-clone, r=Mark-Simulacrum

Remove unnecessary `clone()`s in bootstrap

The performance difference is negligible, but it makes me feel better.

r? @Mark-Simulacrum

3 years agoRollup merge of #76728 - jyn514:rustdoc-extern-crate, r=ehuss
Tyler Mandry [Wed, 16 Sep 2020 19:24:10 +0000 (12:24 -0700)]
Rollup merge of #76728 - jyn514:rustdoc-extern-crate, r=ehuss

Add a comment why `extern crate` is necessary for rustdoc

r? @ehuss

From https://github.com/rust-lang/rust/pull/74293#discussion_r488335500.

3 years agoRollup merge of #76721 - camelid:intra-doc-links-for-core-mem, r=jyn514
Tyler Mandry [Wed, 16 Sep 2020 19:24:08 +0000 (12:24 -0700)]
Rollup merge of #76721 - camelid:intra-doc-links-for-core-mem, r=jyn514

Use intra-doc links in `core::mem`

Part of #75080.

Last one for now!

---

@rustbot modify labels: A-intra-doc-links T-doc

3 years agoRollup merge of #76719 - hameerabbasi:min-const-generics-ty, r=lcnr
Tyler Mandry [Wed, 16 Sep 2020 19:24:06 +0000 (12:24 -0700)]
Rollup merge of #76719 - hameerabbasi:min-const-generics-ty, r=lcnr

Change error message for ty param in const

This PR introduces the following changes:

* Change error message for type param in a const expression when using
`min_const_generics`
* Change `ParamInNonTrivialAnonConst` to contain an extra `bool` used for
distinguishing whether the passed-in symbol is a type or a value.

Fixes #76701

3 years agoRollup merge of #76642 - GuillaumeGomez:ignored-private-doc-test, r=jyn514
Tyler Mandry [Wed, 16 Sep 2020 19:24:05 +0000 (12:24 -0700)]
Rollup merge of #76642 - GuillaumeGomez:ignored-private-doc-test, r=jyn514

Do not lint ignored private doc tests

Fixes #76457.

r? @ehuss

3 years agoRollup merge of #75026 - JulianKnodt:array_windows, r=Amanieu
Tyler Mandry [Wed, 16 Sep 2020 19:24:03 +0000 (12:24 -0700)]
Rollup merge of #75026 - JulianKnodt:array_windows, r=Amanieu

Add array_windows fn

This mimicks the functionality added by array_chunks, and implements a const-generic form of
`windows`. It makes egregious use of `unsafe`, but by necessity because the array must be
re-interpreted as a slice of arrays, and unlike array_chunks this cannot be done by casting the
original array once, since each time the index is advanced it needs to move one element, not
`N`.

I'm planning on adding more tests, but this should be good enough as a premise for the functionality.
Notably: should there be more functions overwritten for the iterator implementation/in general?

~~I've marked the issue as #74985 as there is no corresponding exact issue for `array_windows`, but it's based of off `array_chunks`.~~

Edit: See Issue #75027 created by @lcnr for tracking issue

~~Do not merge until I add more tests, please.~~

r? @lcnr

3 years agoAvoid creating `&mut`s in Windows ReentrantMutex.
Mara Bos [Wed, 16 Sep 2020 19:16:32 +0000 (21:16 +0200)]
Avoid creating `&mut`s in Windows ReentrantMutex.

3 years agoDon't use `mut` in Windows Mutex.
Mara Bos [Wed, 16 Sep 2020 19:09:53 +0000 (21:09 +0200)]
Don't use `mut` in Windows Mutex.

3 years agoAdded RUSTC_GRAPHVIZ_FONT environment variable
Rich Kadel [Wed, 16 Sep 2020 17:47:56 +0000 (10:47 -0700)]
Added RUSTC_GRAPHVIZ_FONT environment variable

Overrides the debugging_opts.graphviz_font setting.

3 years agoAuto merge of #76420 - Gelbpunkt:aarch64-linux-musl, r=pietroalbini
bors [Wed, 16 Sep 2020 17:22:54 +0000 (17:22 +0000)]
Auto merge of #76420 - Gelbpunkt:aarch64-linux-musl, r=pietroalbini

Add aarch64-unknown-linux-musl host builds

This adds aarch64-unknown-linux-musl to the hosts list and adds the build to the dist-arm-linux builder as `@Mark-Simulacrum` suggested to me in Zulip. `@jyn514` requested to be mentioned :smile:

I had to update the config for crosstool-ng as it had a prompt about the glibc version.

I ran `src/ci/docker/run.sh dist-arm-linux` to test it.

```
Build completed successfully in 1:31:50
Compile requests              8180
Compile requests executed     8135
Cache hits                     287
Cache misses                  7848
Cache timeouts                   0
Cache read errors                0
Forced recaches                  0
Cache write errors               0
Compilation failures             0
Cache errors                     0
Non-cacheable compilations       0
Non-cacheable calls             36
Non-compilation calls            9
Unsupported compiler calls       0
Average cache write          0.000 s
Average cache read miss      6.389 s
Average cache read hit       0.000 s
Cache location             Local disk: "/sccache"
Cache size                     202 MiB
Max cache size                  10 GiB
== clock drift check ==
  local time: Sun Sep  6 19:30:17 UTC 2020
  network time: Sun, 06 Sep 2020 19:30:17 GMT
== end clock drift check ==
```

Only errors were in miri due to struct fields being private (already been reported [here](https://github.com/rust-lang/rust/issues/76337))

Edit: Maybe it is helpful if I add that it is a working compiler
```sh
/rust-nightly-aarch64-unknown-linux-musl # ash install.sh
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'cargo'
install: installing component 'rls-preview'
install: installing component 'rust-analyzer-preview'
install: installing component 'clippy-preview'
install: installing component 'rustfmt-preview'
install: installing component 'llvm-tools-preview'
install: installing component 'rust-analysis-aarch64-unknown-linux-musl'
install: installing component 'rust-std-aarch64-unknown-linux-musl'
install: WARNING: failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error

    Rust is ready to roll.

/ # cat test.rs
fn main() { println!("hello world"); }
/ # rustc test.rs
/ # ./test
hello world
 # file test
test: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped
```

3 years agoMake graphviz font configurable
Rich Kadel [Wed, 16 Sep 2020 15:10:06 +0000 (08:10 -0700)]
Make graphviz font configurable

Alternative to PR ##76776.

To change the graphviz output to use an alternative `fontname` value,
add a command line option like: `rustc --graphviz-font=monospace`.

3 years agoAdd array window fn
kadmin [Thu, 13 Aug 2020 19:09:14 +0000 (19:09 +0000)]
Add array window fn

Updated issue to #75027

Update to rm oob access

And hopefully fix docs as well

Fixed naming conflict in test

Fix test which used 1-indexing

Nth starts from 0, woops

Fix a bunch of off by 1 errors

See https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=757b311987e3fae1ca47122969acda5a

Add even more off by 1 errors

And also write `next` and `next_back` in terms of `nth` and `nth_back`.

Run fmt

Fix forgetting to change fn name in test

add nth_back test & document unsafe

Remove as_ref().unwrap()
Documented occurrences of unsafe, noting what invariants are maintained

3 years agoAuto merge of #76786 - Dylan-DPC:rollup-x6p60m6, r=Dylan-DPC
bors [Wed, 16 Sep 2020 13:23:46 +0000 (13:23 +0000)]
Auto merge of #76786 - Dylan-DPC:rollup-x6p60m6, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #76669 (Prefer asm! over llvm_asm! in core)
 - #76675 (Small improvements to asm documentation)
 - #76681 (remove orphaned files)
 - #76694 (Introduce a PartitioningCx struct)
 - #76695 (fix syntax error in suggesting generic constraint in trait parameter)
 - #76699 (improve const infer error)
 - #76707 (Simplify iter flatten struct doc)
 - #76710 (:arrow_up: rust-analyzer)
 - #76714 (Small docs improvements)
 - #76717 (Fix generating rustc docs with non-default lib directory.)

Failed merges:

r? `@ghost`

3 years agoRemove unnecessary `clone()`s in bootstrap
Joshua Nelson [Tue, 15 Sep 2020 04:08:37 +0000 (00:08 -0400)]
Remove unnecessary `clone()`s in bootstrap

The performance difference is negligible, but it makes me feel better.

Note that this does not remove some clones in `config`, because it would
require changing the logic around (and performance doesn't matter
for bootstrap).

3 years agoRollup merge of #76717 - ehuss:fix-rustc-book-libdir, r=Mark-Simulacrum
Dylan DPC [Wed, 16 Sep 2020 10:34:29 +0000 (12:34 +0200)]
Rollup merge of #76717 - ehuss:fix-rustc-book-libdir, r=Mark-Simulacrum

Fix generating rustc docs with non-default lib directory.

If `libdir` is set in `config.toml`, then the tool to generate the rustc docs was unable to run `rustc` because it could not find the shared libraries. The solution is to set the dylib search path to include the libdir.

I changed the API of `add_rustc_lib_path` to take `Command` instead of `Cargo` to try to share the code in several places. This is how it worked before https://github.com/rust-lang/rust/pull/64316, and I think this still retains the spirit of that change.

Fixes #76702

3 years agoRollup merge of #76714 - camelid:patch-3, r=jonas-schievink
Dylan DPC [Wed, 16 Sep 2020 10:34:27 +0000 (12:34 +0200)]
Rollup merge of #76714 - camelid:patch-3, r=jonas-schievink

Small docs improvements

@rustbot modify labels: T-doc T-compiler

3 years agoRollup merge of #76710 - rust-lang:rust-analyzer-2020-09-14, r=jonas-schievink
Dylan DPC [Wed, 16 Sep 2020 10:34:25 +0000 (12:34 +0200)]
Rollup merge of #76710 - rust-lang:rust-analyzer-2020-09-14, r=jonas-schievink

:arrow_up: rust-analyzer

r? @ghost

3 years agoRollup merge of #76707 - pickfire:patch-4, r=jonas-schievink
Dylan DPC [Wed, 16 Sep 2020 10:34:23 +0000 (12:34 +0200)]
Rollup merge of #76707 - pickfire:patch-4, r=jonas-schievink

Simplify iter flatten struct doc

3 years agoRollup merge of #76699 - lcnr:const-infer-err, r=varkor
Dylan DPC [Wed, 16 Sep 2020 10:34:21 +0000 (12:34 +0200)]
Rollup merge of #76699 - lcnr:const-infer-err, r=varkor

improve const infer error

cc #72328

reduces it from
```
error[E0282]: type annotations needed
  --> src/main.rs:17:5
   |
17 |     Foo.bar().bar().bar().bar().baz();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: unable to infer the value of a const parameter
```
to
```
error[E0282]: type annotations needed
  --> $DIR/method-chain.rs:21:33
   |
LL |     Foo.bar().bar().bar().bar().baz();
   |                                 ^^^
   |
   = note: cannot infer the value of the const parameter `N`
```

r? @varkor

3 years agoRollup merge of #76695 - iximeow:trait-generic-bound-suggestion, r=estebank
Dylan DPC [Wed, 16 Sep 2020 10:34:20 +0000 (12:34 +0200)]
Rollup merge of #76695 - iximeow:trait-generic-bound-suggestion, r=estebank

fix syntax error in suggesting generic constraint in trait parameter

suggest `where T: Foo` for the first bound on a trait, then suggest
`, T: Foo` when the suggested bound would add to an existing set of
`where` clauses. `where T: Foo` may be the first bound if `T` has a
default, because we'd rather suggest
```
trait A<T=()> where T: Copy
```
than
```
trait A<T: Copy=()>
```
for legibility reasons.

the test case i added here is derived from [this reproduction](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0bf3ace9f2a183d0bdbd748c6b8e3971):
```
struct B<T: Copy> {
    t: T
}

trait A<T = ()> {
    fn returns_constrained_type(&self, t: T) -> B<T> {
        B { t }
    }
}
```
where the suggested fix,
```
trait A<T = ()>, T: Copy { ... }
```
is in fact invalid syntax!

i also found an error in the existing suggestion for `trait Base<T = String>: Super<T>` where rustc would suggest `trait Base<T = String>: Super<T>, T: Copy`, but `T: Copy` is the first of the trait's `where` clauses and should be `where T: Copy` as well. the test for that suggestion expects invalid syntax, and has been revised to a compiler-pleasing `trait Base<T = String>: Super<T> where T: Copy`.

judging by https://github.com/rust-lang/rust/pull/70009 i'll.. cc @estebank ?

3 years agoRollup merge of #76694 - wesleywiser:partitioning_cx_trait, r=davidtwco
Dylan DPC [Wed, 16 Sep 2020 10:34:18 +0000 (12:34 +0200)]
Rollup merge of #76694 - wesleywiser:partitioning_cx_trait, r=davidtwco

Introduce a PartitioningCx struct

This contains all the data used by the partitioning algorithm and allows that data to be used at each stage of the partitioning. This is useful for other approaches to partitioning which may want different pieces of the data available at each step.

cc @rust-lang/wg-incr-comp

3 years agoRollup merge of #76681 - tshepang:unused, r=Mark-Simulacrum
Dylan DPC [Wed, 16 Sep 2020 10:34:15 +0000 (12:34 +0200)]
Rollup merge of #76681 - tshepang:unused, r=Mark-Simulacrum

remove orphaned files

Should been part of https://github.com/rust-lang/rust/pull/74163

3 years agoRollup merge of #76675 - lzutao:asm_doc, r=Amanieu
Dylan DPC [Wed, 16 Sep 2020 10:34:14 +0000 (12:34 +0200)]
Rollup merge of #76675 - lzutao:asm_doc, r=Amanieu

Small improvements to asm documentation

Save people from searching and reading tons of comments in tracking issues.

3 years agoRollup merge of #76669 - lzutao:core_asm, r=Amanieu
Dylan DPC [Wed, 16 Sep 2020 10:34:11 +0000 (12:34 +0200)]
Rollup merge of #76669 - lzutao:core_asm, r=Amanieu

Prefer asm! over llvm_asm! in core

Replace llvm_asm! with asm! in core.

x86 asm compare (in somecases I replaced generic type with String).
* https://rust.godbolt.org/z/59eEMv
* https://rust.godbolt.org/z/v78s6q
* https://rust.godbolt.org/z/7qYY41

3 years agoFix black_box bug detected by Amanieu
Lzu Tao [Wed, 16 Sep 2020 09:25:54 +0000 (09:25 +0000)]
Fix black_box bug detected by Amanieu

Co-authored-by: Amanieu <amanieu@gmail.com>
3 years agoAuto merge of #76781 - RalfJung:rollup-ve66o2j, r=RalfJung
bors [Wed, 16 Sep 2020 06:46:24 +0000 (06:46 +0000)]
Auto merge of #76781 - RalfJung:rollup-ve66o2j, r=RalfJung

Rollup of 10 pull requests

Successful merges:

 - #76056 (Add more info for Vec Drain doc)
 - #76062 (Vec slice example fix style and show type elision)
 - #76262 (Use inline(never) instead of cold)
 - #76335 (Make all methods of `Duration` unstably const)
 - #76366 (Add Arith Tests in Library)
 - #76369 (Move Various str tests in library)
 - #76534 (Add doc comments for From impls)
 - #76622 (Update bootstrap readme)
 - #76641 (Some cleanup changes and commenting)
 - #76662 (Fix liballoc test suite for Miri)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76662 - RalfJung:lib-test-miri, r=Mark-Simulacrum
Ralf Jung [Wed, 16 Sep 2020 06:25:02 +0000 (08:25 +0200)]
Rollup merge of #76662 - RalfJung:lib-test-miri, r=Mark-Simulacrum

Fix liballoc test suite for Miri

Mostly, fix the regression introduced by https://github.com/rust-lang/rust/pull/75207 that caused slices (i.e., references) to be created to invalid memory or memory that has aliasing pointers that we want to keep valid. @dylni  this changes the type of `check_range` to only require the length, not the full reference to the slice, which indeed is all the information this function requires.

Also reduce the size of a test introduced in https://github.com/rust-lang/rust/pull/70793 to make it not take 3 minutes in Miri.

This makes https://github.com/RalfJung/miri-test-libstd work again.

3 years agoRollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Ralf Jung [Wed, 16 Sep 2020 06:25:00 +0000 (08:25 +0200)]
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb

Some cleanup changes and commenting

r? @nikomatsakis
Cc @eddyb

3 years agoRollup merge of #76622 - jyn514:bootstrap-readme, r=Mark-Simulacrum
Ralf Jung [Wed, 16 Sep 2020 06:24:58 +0000 (08:24 +0200)]
Rollup merge of #76622 - jyn514:bootstrap-readme, r=Mark-Simulacrum

Update bootstrap readme

- Reflect changes in x.py defaults
- Remove recommendation to use nightly for incremental; it works fine on
beta
- Remove note that incremental chooses stage 1 by default; stage 1 is
already the default
- Update Discord -> Zulip

r? @Mark-Simulacrum

3 years agoRollup merge of #76534 - notriddle:doc-comments, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:56 +0000 (08:24 +0200)]
Rollup merge of #76534 - notriddle:doc-comments, r=jyn514

Add doc comments for From impls

https://github.com/rust-lang/rust/issues/51430

3 years agoRollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:54 +0000 (08:24 +0200)]
Rollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, r=jyn514

Move Various str tests in library

Moved various string ui  tests in library  as a part of #76268

r? @matklad

3 years agoRollup merge of #76366 - ayushmishra2005:arith_tests_in_library, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:52 +0000 (08:24 +0200)]
Rollup merge of #76366 - ayushmishra2005:arith_tests_in_library, r=jyn514

Add Arith Tests in Library

Added Arith Tests library as a part of #76268

r? @matklad

3 years agoRollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morse
Ralf Jung [Wed, 16 Sep 2020 06:24:50 +0000 (08:24 +0200)]
Rollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morse

Make all methods of `Duration` unstably const

Make the following methods of `Duration` unstable const under `duration_const_2`:
 - `from_secs_f64`
 - `from_secs_f32`
 - `mul_f64`
 - `mul_f32`
 - `div_f64`
 - `div_f32`

This results in all methods of `Duration` being (unstable) const.

Moved the tests to `library` as part of #76268.

Possible because of #72449, which made the relevant `f32` and `f64` methods const.

Tracking issue: #72440

r? @ecstatic-morse

3 years agoRollup merge of #76262 - howard0su:patch-1, r=cramertj
Ralf Jung [Wed, 16 Sep 2020 06:24:49 +0000 (08:24 +0200)]
Rollup merge of #76262 - howard0su:patch-1, r=cramertj

Use inline(never) instead of cold

inline(never) is better way to avoid optimizer to inline the function instead of cold.

3 years agoRollup merge of #76062 - pickfire:patch-13, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:46 +0000 (08:24 +0200)]
Rollup merge of #76062 - pickfire:patch-13, r=jyn514

Vec slice example fix style and show type elision