]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #78050 - GuillaumeGomez:small-css-cleanup, r=jyn514
Yuki Okushi [Sat, 17 Oct 2020 19:11:13 +0000 (04:11 +0900)]
Rollup merge of #78050 - GuillaumeGomez:small-css-cleanup, r=jyn514

Small CSS cleanup

r? @jyn514

3 years agoRollup merge of #78048 - blyxxyz:e0424-improve-self-placement, r=lcnr
Yuki Okushi [Sat, 17 Oct 2020 19:11:11 +0000 (04:11 +0900)]
Rollup merge of #78048 - blyxxyz:e0424-improve-self-placement, r=lcnr

Suggest correct place to add `self` parameter when inside closure

It would incorrectly suggest adding it as a parameter to the closure instead of the containing function.

[For example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1936bcd1e5f981573386e0cee985c3c0):
```
help: add a `self` receiver parameter to make the associated `fn` a method
  |
5 |         let _ = || self&self;
  |                        ^^^^^
```

`DiagnosticMetadata.current_function` is only used for these messages so tweaking its behavior should be ok.

3 years agoRollup merge of #78043 - willcrozi:e0210-error-note-fix, r=lcnr
Yuki Okushi [Sat, 17 Oct 2020 19:11:09 +0000 (04:11 +0900)]
Rollup merge of #78043 - willcrozi:e0210-error-note-fix, r=lcnr

Fix grammar in note for orphan-rule error [E0210]

Fixes the grammar in the error note for [E0210] from:

_"= note: implementing a foreign trait is only possible if at least one of the types for which **is it** implemented is local"_

to:

_"= note: implementing a foreign trait is only possible if at least one of the types for which **it is** implemented is local"_

The content of this commit is the result of running the following command at the repository root:

`find . \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/which is it implemented/which it is implemented/g'`

3 years agoRollup merge of #77851 - exrook:split-btreemap, r=dtolnay
Yuki Okushi [Sat, 17 Oct 2020 19:11:07 +0000 (04:11 +0900)]
Rollup merge of #77851 - exrook:split-btreemap, r=dtolnay

BTreeMap: refactor Entry out of map.rs into its own file

btree/map.rs is approaching the 3000 line mark, splitting out the entry
code buys about 500 lines of headroom.

I've created this PR because the changes I've made in #77438 will push `map.rs` over the 3000 line limit and cause tidy to complain.

I picked `Entry` to factor out because it feels less tightly coupled to the rest of `BTreeMap` than the various iterator implementations.

Related: #60302

3 years agoRollup merge of #76607 - Mark-Simulacrum:tidy-bins, r=pnkfelix
Yuki Okushi [Sat, 17 Oct 2020 19:11:05 +0000 (04:11 +0900)]
Rollup merge of #76607 - Mark-Simulacrum:tidy-bins, r=pnkfelix

Modify executable checking to be more universal

This uses a dummy file to check if the filesystem being used supports the executable bit in general.

Supersedes #74753.

3 years agoRollup merge of #75802 - petrochenkov:nometa, r=nikomatsakis
Yuki Okushi [Sat, 17 Oct 2020 19:11:03 +0000 (04:11 +0900)]
Rollup merge of #75802 - petrochenkov:nometa, r=nikomatsakis

resolve: Do not put nonexistent crate `meta` into prelude

Before the 2018 edition release there was some vague suggestion about adding a crate named `meta` to the standard distribution.
On this basis the name `meta` was "partially reserved" by putting `meta` into extern prelude (this means importing something named `meta` will result in an ambiguity error, for example).
This only caused confusion so far, and two years later there are no specific plans to add such crate.

If some standard crate (named `meta` or not) is added in the future, then cargo will hopefully already have ability to put it into extern prelude explicitly through `Cargo.toml`.
Otherwise, it could be added to extern prelude by the compiler at edition boundary.

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

3 years agoAppease the almightly lord clippy, hallowed be thy name
Jacob Hughes [Sat, 17 Oct 2020 17:45:40 +0000 (13:45 -0400)]
Appease the almightly lord clippy, hallowed be thy name

3 years agoAuto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obk
bors [Sat, 17 Oct 2020 14:44:51 +0000 (14:44 +0000)]
Auto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obk

Implement const expressions and patterns (RFC 2920)

cc `@ecstatic-morse` `@lcnr` `@oli-obk` `@petrochenkov`

3 years agoSmall CSS cleanup
Guillaume Gomez [Sat, 17 Oct 2020 13:17:00 +0000 (15:17 +0200)]
Small CSS cleanup

3 years agoAuto merge of #78039 - tmiasko:unreachable-block, r=Mark-Simulacrum
bors [Sat, 17 Oct 2020 12:36:32 +0000 (12:36 +0000)]
Auto merge of #78039 - tmiasko:unreachable-block, r=Mark-Simulacrum

Remove unused cached_unreachable_block from MIR builder

3 years agoSuggest correct place to add `self` parameter when inside closure
Jan Verbeek [Sat, 17 Oct 2020 11:36:59 +0000 (13:36 +0200)]
Suggest correct place to add `self` parameter when inside closure

It would incorrectly suggest adding it as a parameter to the closure instead of the
containing function.

3 years agoresolve: Do not put nonexistent crate `meta` into prelude
Vadim Petrochenkov [Sat, 22 Aug 2020 09:28:09 +0000 (12:28 +0300)]
resolve: Do not put nonexistent crate `meta` into prelude

3 years agoAuto merge of #77685 - jackh726:binder-map, r=lcnr
bors [Sat, 17 Oct 2020 10:28:52 +0000 (10:28 +0000)]
Auto merge of #77685 - jackh726:binder-map, r=lcnr

Use rebind instead of Binder::bind when possible

These are really only the easy places. I just searched for `Binder::bind` and replaced where it straightforward.

r? `@lcnr`
cc. `@nikomatsakis`

3 years agoFix grammar in note for orphan-rule error [E0210]
Will Crozier [Sat, 17 Oct 2020 09:56:54 +0000 (10:56 +0100)]
Fix grammar in note for orphan-rule error [E0210]

3 years agoAuto merge of #76096 - pickfire:rustdoc-quote, r=jyn514
bors [Sat, 17 Oct 2020 08:19:12 +0000 (08:19 +0000)]
Auto merge of #76096 - pickfire:rustdoc-quote, r=jyn514

Use double quote for rustdoc html

r? `@GuillaumeGomez`

Feels scary without escaping stuff when I looked at the code, probably susceptible to XSS.
Follow up of https://github.com/rust-lang/rust/pull/75842

3 years agoAuto merge of #77455 - asm89:faster-spawn, r=kennytm
bors [Sat, 17 Oct 2020 06:16:00 +0000 (06:16 +0000)]
Auto merge of #77455 - asm89:faster-spawn, r=kennytm

Use posix_spawn() on unix if program is a path

Previously `Command::spawn` would fall back to the non-posix_spawn based
implementation if the `PATH` environment variable was possibly changed.
On systems with a modern (g)libc `posix_spawn()` can be significantly
faster. If program is a path itself the `PATH` environment variable is
not used for the lookup and it should be safe to use the
`posix_spawnp()` method. [1]

We found this, because we have a cli application that effectively runs a
lot of subprocesses. It would sometimes noticeably hang while printing
output. Profiling showed that the process was spending the majority of
time in the kernel's `copy_page_range` function while spawning
subprocesses. During this time the process is completely blocked from
running, explaining why users were reporting the cli app hanging.

Through this we discovered that `std::process::Command` has a fast and
slow path for process execution. The fast path is backed by
`posix_spawnp()` and the slow path by fork/exec syscalls being called
explicitly. Using fork for process creation is supposed to be fast, but
it slows down as your process uses more memory.  It's not because the
kernel copies the actual memory from the parent, but it does need to
copy the references to it (see `copy_page_range` above!).  We ended up
using the slow path, because the command spawn implementation in falls
back to the slow path if it suspects the PATH environment variable was
changed.

Here is a smallish program demonstrating the slowdown before this code
change:

```
use std::process::Command;
use std::time::Instant;

fn main() {
    let mut args = std::env::args().skip(1);
    if let Some(size) = args.next() {
        // Allocate some memory
        let _xs: Vec<_> = std::iter::repeat(0)
            .take(size.parse().expect("valid number"))
            .collect();

        let mut command = Command::new("/bin/sh");
        command
            .arg("-c")
            .arg("echo hello");

        if args.next().is_some() {
            println!("Overriding PATH");
            command.env("PATH", std::env::var("PATH").expect("PATH env var"));
        }

        let now = Instant::now();
        let child = command
            .spawn()
            .expect("failed to execute process");

        println!("Spawn took: {:?}", now.elapsed());

        let output = child.wait_with_output().expect("failed to wait on process");
        println!("Output: {:?}", output);
    } else {
        eprintln!("Usage: prog [size]");
        std::process::exit(1);
    }
    ()
}
```

Running it and passing different amounts of elements to use to allocate
memory shows that the time taken for `spawn()` can differ quite
significantly. In latter case the `posix_spawnp()` implementation is 30x
faster:

```
$ cargo run --release 10000000
...
Spawn took: 324.275µs
hello
$ cargo run --release 10000000 changepath
...
Overriding PATH
Spawn took: 2.346809ms
hello
$ cargo run --release 100000000
...
Spawn took: 387.842µs
hello
$ cargo run --release 100000000 changepath
...
Overriding PATH
Spawn took: 13.434677ms
hello
```

[1]: https://github.com/bminor/glibc/blob/5f72f9800b250410cad3abfeeb09469ef12b2438/posix/execvpe.c#L81

3 years agoFix some double quote that cause CI failure
Ivan Tham [Sat, 17 Oct 2020 05:53:51 +0000 (13:53 +0800)]
Fix some double quote that cause CI failure

Co-authored-by: Oliver Middleton <olliemail27@gmail.com>
3 years agoAuto merge of #78025 - ehuss:bump-bootstrap, r=Mark-Simulacrum
bors [Sat, 17 Oct 2020 04:09:08 +0000 (04:09 +0000)]
Auto merge of #78025 - ehuss:bump-bootstrap, r=Mark-Simulacrum

Bump bootstrap compiler

Mainly to bring in #77953 to fix https://github.com/rust-lang/cargo/issues/8517.

3 years agoAuto merge of #78033 - Dylan-DPC:rollup-ds2cfsf, r=Dylan-DPC
bors [Sat, 17 Oct 2020 01:41:43 +0000 (01:41 +0000)]
Auto merge of #78033 - Dylan-DPC:rollup-ds2cfsf, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #76199 (Permit uninhabited enums to cast into ints)
 - #77751 (liballoc: VecDeque: Add binary search functions)
 - #77785 (Remove compiler-synthesized reexports when documenting)
 - #77932 (BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values)
 - #77961 (Set .llvmbc and .llvmcmd sections as allocatable)
 - #77985 (llvm: backport SystemZ fix for AGR clobbers)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #77985 - cuviper:systemz-agr-clobbers-cc, r=nikic
Dylan DPC [Sat, 17 Oct 2020 01:27:22 +0000 (03:27 +0200)]
Rollup merge of #77985 - cuviper:systemz-agr-clobbers-cc, r=nikic

llvm: backport SystemZ fix for AGR clobbers

Fixes #77382.

3 years agoRollup merge of #77961 - glandium:embed-bitcode, r=nagisa
Dylan DPC [Sat, 17 Oct 2020 01:27:20 +0000 (03:27 +0200)]
Rollup merge of #77961 - glandium:embed-bitcode, r=nagisa

Set .llvmbc and .llvmcmd sections as allocatable

This marks both sections as allocatable rather than excluded, which matches what
clang does with the equivalent `-fembed-bitcode` flag.

3 years agoRollup merge of #77932 - ssomers:btree_cleanup_gdb, r=Mark-Simulacrum
Dylan DPC [Sat, 17 Oct 2020 01:27:18 +0000 (03:27 +0200)]
Rollup merge of #77932 - ssomers:btree_cleanup_gdb, r=Mark-Simulacrum

BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values

I accidentally pushed an earlier revision in #77788: it changes the index of tuples for BTreeSet from ""[{}]".format(i) to "key{}".format(i). Which doesn't seem to make the slightest difference on my linux box nor on CI. In fact, gdb doesn't make any distinction between "key{}" and "val{}" for a BTreeMap either, leading to confusing output if you test more. But easy to improve.

r? @Mark-Simulacrum

3 years agoRollup merge of #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27
Dylan DPC [Sat, 17 Oct 2020 01:27:17 +0000 (03:27 +0200)]
Rollup merge of #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27

Remove compiler-synthesized reexports when documenting

Fixes #77567

r? @ollie27

3 years agoRollup merge of #77751 - vojtechkral:vecdeque-binary-search, r=scottmcm,dtolnay
Dylan DPC [Sat, 17 Oct 2020 01:27:15 +0000 (03:27 +0200)]
Rollup merge of #77751 - vojtechkral:vecdeque-binary-search, r=scottmcm,dtolnay

liballoc: VecDeque: Add binary search functions

I am submitting rust-lang/rfcs#2997 as a PR as suggested by @scottmcm

I haven't yet created a tracking issue - if there's a favorable feedback I'll create one and update the issue links in the unstable attribs.

3 years agoRollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakis
Dylan DPC [Sat, 17 Oct 2020 01:27:12 +0000 (03:27 +0200)]
Rollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakis

Permit uninhabited enums to cast into ints

This essentially reverts part of #6204; it is unclear why that [commit](https://github.com/rust-lang/rust/pull/6204/commits/c0f587de34f30b060df8a88c4068740e587b9340) was introduced, and I suspect no one remembers.

The changed code was only called from casting checks and appears to not affect any callers of that code (other than permitting this one case).

Fixes #75647.

3 years agoRemove unused cached_unreachable_block from MIR builder
Tomasz Miąsko [Sat, 17 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Remove unused cached_unreachable_block from MIR builder

3 years agoAuto merge of #77997 - fusion-engineering-forks:to-string-no-shrink, r=joshtriplett
bors [Fri, 16 Oct 2020 22:53:50 +0000 (22:53 +0000)]
Auto merge of #77997 - fusion-engineering-forks:to-string-no-shrink, r=joshtriplett

Remove shrink_to_fit from default ToString::to_string implementation.

As suggested by `@scottmcm` on Zulip. shrink_to_fit() seems like the wrong thing to do here in most use cases of to_string(). Would be intereseting to see if it makes any difference in a timer run.

r? `@joshtriplett`

3 years agoAdd inline const to INCOMPLETE_FEATURES
Santiago Pastorino [Fri, 16 Oct 2020 21:15:57 +0000 (18:15 -0300)]
Add inline const to INCOMPLETE_FEATURES

3 years agoAuto merge of #78028 - JohnTitor:rollup-jt3hikb, r=JohnTitor
bors [Fri, 16 Oct 2020 20:43:27 +0000 (20:43 +0000)]
Auto merge of #78028 - JohnTitor:rollup-jt3hikb, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #75209 (Suggest imports of unresolved macros)
 - #77547 (stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union')
 - #77827 (Don't link to nightly primitives on stable channel)
 - #77855 (resolve: further improvements to "try using the enum's variant" diagnostic)
 - #77900 (Use fdatasync for File::sync_data on more OSes)
 - #77925 (Suggest minimal subset features in `incomplete_features` lint)
 - #77971 (Deny broken intra-doc links in linkchecker)
 - #77991 (Bump backtrace-rs)
 - #77992 (instrument-coverage: try our best to not ICE)
 - #78013 (Fix sidebar scroll on mobile devices)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78013 - GuillaumeGomez:fix-sidebar-scroll-mobile-devices, r=jyn514
Yuki Okushi [Fri, 16 Oct 2020 20:36:54 +0000 (05:36 +0900)]
Rollup merge of #78013 - GuillaumeGomez:fix-sidebar-scroll-mobile-devices, r=jyn514

Fix sidebar scroll on mobile devices

Fixes #77942.

The issue was coming from the appearance/disappearance of the "wrapper" on the mobile devices web browsers, which triggers the "resize" event, calling the `hideSidebar` function is the JS code.

r? @jyn514

3 years agoRollup merge of #77992 - nagisa:thaw-coverage-instrumentation, r=wesleywiser
Yuki Okushi [Fri, 16 Oct 2020 20:36:52 +0000 (05:36 +0900)]
Rollup merge of #77992 - nagisa:thaw-coverage-instrumentation, r=wesleywiser

instrument-coverage: try our best to not ICE

instrument-coverage was ICEing for me on some code, in particular code
that had devirtualized paths from standard library. Instrument coverage
probably has no bussiness dictating which paths are valid and which
aren't so just feed it everything and whatever and let tooling deal with
other stuff.

For example, with this commit we can generate coverage hitpoints for
these interesting paths:

* `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore
* `/home/.../src/library/core/lib.rs` – devirtualized version of above
* `<inline asm>`, `<anon>` and many similar synthetic paths

Even if those paths somehow get to the instrumentation pass, I'd much
rather get hits for these weird paths and hope some of them work (as
would be the case for devirtualized path to libcore), rather than have
compilation fail entirely.

3 years agoRollup merge of #77991 - Aaron1011:bump-backtrace-again, r=Mark-Simulacrum
Yuki Okushi [Fri, 16 Oct 2020 20:36:50 +0000 (05:36 +0900)]
Rollup merge of #77991 - Aaron1011:bump-backtrace-again, r=Mark-Simulacrum

Bump backtrace-rs

This pulls in https://github.com/rust-lang/backtrace-rs/pull/376, which
fixes Miri support for `std::backtrace::Backtrace`.

3 years agoRollup merge of #77971 - jyn514:broken-intra-doc-links, r=mark-simulacrum
Yuki Okushi [Fri, 16 Oct 2020 20:36:49 +0000 (05:36 +0900)]
Rollup merge of #77971 - jyn514:broken-intra-doc-links, r=mark-simulacrum

Deny broken intra-doc links in linkchecker

Since rustdoc isn't warning about these links, check for them manually.

This also fixes the broken links that popped up from the lint.

3 years agoRollup merge of #77925 - JohnTitor:sugg-min-features, r=davidtwco,oli-obk
Yuki Okushi [Fri, 16 Oct 2020 20:36:47 +0000 (05:36 +0900)]
Rollup merge of #77925 - JohnTitor:sugg-min-features, r=davidtwco,oli-obk

Suggest minimal subset features in `incomplete_features` lint

This tells users that we have a minimal subset feature of it and they can fix the lint warning without allowing it.
The wording improvement is helpful :)

Fixes #77913

3 years agoRollup merge of #77900 - Thomasdezeeuw:fdatasync, r=dtolnay
Yuki Okushi [Fri, 16 Oct 2020 20:36:45 +0000 (05:36 +0900)]
Rollup merge of #77900 - Thomasdezeeuw:fdatasync, r=dtolnay

Use fdatasync for File::sync_data on more OSes

Add support for the following OSes:
 * Android
 * FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=fdatasync&sektion=2
 * OpenBSD: https://man.openbsd.org/OpenBSD-5.8/fsync.2
 * NetBSD: https://man.netbsd.org/fdatasync.2
 * illumos: https://illumos.org/man/3c/fdatasync

3 years agoRollup merge of #77855 - davidtwco:pr-77341-follow-up-non-constructable-variants...
Yuki Okushi [Fri, 16 Oct 2020 20:36:43 +0000 (05:36 +0900)]
Rollup merge of #77855 - davidtwco:pr-77341-follow-up-non-constructable-variants, r=estebank

resolve: further improvements to "try using the enum's variant" diagnostic

Follow-up on https://github.com/rust-lang/rust/pull/77341#issuecomment-702738281.

This PR improves the diagnostic modified in #77341 to suggest not only those variants which do not have fields, but those with fields (by suggesting with placeholders). In addition, the wording of the tuple-variant-only case is improved slightly.

I've not made further changes to the tuple-variant-only case (e.g. to only suggest variants with the correct number of fields) because I don't think I have enough information to do so reliably (e.g. in the case where there is an attempt to construct a tuple variant, I have no information on how many fields were provided; and in the case of pattern matching, I only have a slice of spans and would need to check for things like `..` in those spans, which doesn't seem worth it).

r? @estebank

3 years agoRollup merge of #77827 - jyn514:stable-primitives, r=GuillaumeGomez
Yuki Okushi [Fri, 16 Oct 2020 20:36:41 +0000 (05:36 +0900)]
Rollup merge of #77827 - jyn514:stable-primitives, r=GuillaumeGomez

Don't link to nightly primitives on stable channel

I am not sure how to test this.

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

r? @GuillaumeGomez

3 years agoRollup merge of #77547 - RalfJung:stable-union-drop, r=matthewjasper
Yuki Okushi [Fri, 16 Oct 2020 20:36:38 +0000 (05:36 +0900)]
Rollup merge of #77547 - RalfJung:stable-union-drop, r=matthewjasper

stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union'

As [discussed by @SimonSapin and @withoutboats](https://github.com/rust-lang/rust/issues/55149#issuecomment-634692020), this PR proposes to stabilize parts of the `untagged_union` feature gate:

* It will be possible to have a union with field type `ManuallyDrop<T>` for any `T`.
* While at it I propose we also stabilize `impl Drop for Union`; to my knowledge, there are no open concerns around this feature.

In the RFC discussion, we also talked about allowing `&mut T` as another non-`Copy` non-dropping type, but that felt to me like an overly specific exception so I figured we'd wait if there is actually any use for such a special case.

Some things remain unstable and still require the `untagged_union` feature gate:
* Union with fields that do not drop, are not `Copy`, and are not `ManuallyDrop<_>`. The reason to not stabilize this is to avoid semver concerns around libraries adding `Drop` implementations later. (This is already not fully semver compatible as, to my knowledge, the borrow checker will exploit the non-dropping nature of any type, but it seems prudent to avoid further increasing the amount of trouble adding an `impl Drop` can cause.)

Due to this, quite a few tests still need the `untagged_union` feature, but I think the ones where I could remove the feature flag provide good test coverage for the stable part.

Cc @rust-lang/lang

3 years agoRollup merge of #75209 - Hirrolot:suggest-macro-imports, r=estebank
Yuki Okushi [Fri, 16 Oct 2020 20:36:32 +0000 (05:36 +0900)]
Rollup merge of #75209 - Hirrolot:suggest-macro-imports, r=estebank

Suggest imports of unresolved macros

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

3 years agoDo not check unused braces on inline consts
Santiago Pastorino [Fri, 9 Oct 2020 22:21:40 +0000 (19:21 -0300)]
Do not check unused braces on inline consts

3 years agoAdd check_generic_arg early pass
Santiago Pastorino [Fri, 9 Oct 2020 22:20:06 +0000 (19:20 -0300)]
Add check_generic_arg early pass

3 years agoHandle ExprKind::ConstBlock on clippy
Santiago Pastorino [Tue, 6 Oct 2020 21:51:31 +0000 (18:51 -0300)]
Handle ExprKind::ConstBlock on clippy

3 years agoAdd inline const tests
Santiago Pastorino [Tue, 6 Oct 2020 20:53:12 +0000 (17:53 -0300)]
Add inline const tests

3 years agoReview comments
Jack Huey [Fri, 16 Oct 2020 19:14:38 +0000 (15:14 -0400)]
Review comments

3 years agoBump bootstrap compiler
Eric Huss [Fri, 16 Oct 2020 18:54:16 +0000 (11:54 -0700)]
Bump bootstrap compiler

3 years agoliballoc: VecDeque: Simplify binary_search_by()
Vojtech Kral [Fri, 16 Oct 2020 18:24:49 +0000 (20:24 +0200)]
liballoc: VecDeque: Simplify binary_search_by()

3 years agoinstrument-coverage: try our best to not ICE
Simonas Kazlauskas [Thu, 15 Oct 2020 20:14:50 +0000 (23:14 +0300)]
instrument-coverage: try our best to not ICE

instrument-coverage was ICEing for me on some code, in particular code
that had devirtualized paths from standard library. Instrument coverage
probably has no bussiness dictating which paths are valid and which
aren't so just feed it everything and whatever and let tooling deal with
other stuff.

For example, with this commit we can generate coverage hitpoints for
these interesting paths:

* `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore
* `/home/.../src/library/core/lib.rs` – devirtualized version of above
* `<inline asm>`, `<anon>` and many similar synthetic paths

Even if those paths somehow get to the instrumentation pass, I'd much
rather get hits for these weird paths and hope some of them work (as
would be the case for devirtualized path to libcore), rather than have
compilation fail entirely.

3 years agomap_bound_ref -> rebind
Jack Huey [Fri, 16 Oct 2020 18:04:11 +0000 (14:04 -0400)]
map_bound_ref -> rebind

3 years agoTypeck inline consts
Santiago Pastorino [Tue, 6 Oct 2020 20:52:32 +0000 (17:52 -0300)]
Typeck inline consts

3 years agoLower inline const down to MIR
Santiago Pastorino [Tue, 6 Oct 2020 20:51:15 +0000 (17:51 -0300)]
Lower inline const down to MIR

3 years agoLower inline const's AST to HIR
Santiago Pastorino [Tue, 6 Oct 2020 19:58:53 +0000 (16:58 -0300)]
Lower inline const's AST to HIR

3 years agoParse inline const patterns
Santiago Pastorino [Wed, 23 Sep 2020 21:34:44 +0000 (18:34 -0300)]
Parse inline const patterns

3 years agoParse inline const expressions
Santiago Pastorino [Mon, 21 Sep 2020 20:55:58 +0000 (17:55 -0300)]
Parse inline const expressions

3 years agoAdd inline_const feature flag
Santiago Pastorino [Mon, 21 Sep 2020 19:10:31 +0000 (16:10 -0300)]
Add inline_const feature flag

3 years agoAuto merge of #78023 - RalfJung:miri, r=RalfJung
bors [Fri, 16 Oct 2020 17:26:35 +0000 (17:26 +0000)]
Auto merge of #78023 - RalfJung:miri, r=RalfJung

update miri

Fixes https://github.com/rust-lang/rust/issues/77988
Cc `@rust-lang/miri` r? `@ghost`

3 years agoupdate miri
Ralf Jung [Fri, 16 Oct 2020 17:11:36 +0000 (19:11 +0200)]
update miri

3 years agoSuggest minimal subset features in `incomplete_features` lint
Yuki Okushi [Tue, 13 Oct 2020 23:35:32 +0000 (08:35 +0900)]
Suggest minimal subset features in `incomplete_features` lint

3 years agoReview comments
Jack Huey [Sun, 11 Oct 2020 21:14:07 +0000 (17:14 -0400)]
Review comments

3 years agoUse map_bound(_ref) instead of Binder::bind when possible
Jack Huey [Thu, 8 Oct 2020 00:02:06 +0000 (20:02 -0400)]
Use map_bound(_ref) instead of Binder::bind when possible

3 years agoUse double quote for rustdoc html
Ivan Tham [Thu, 15 Oct 2020 16:52:49 +0000 (00:52 +0800)]
Use double quote for rustdoc html

3 years agoliballoc: VecDeque: Add tracking issue for binary search fns
Vojtech Kral [Fri, 16 Oct 2020 16:17:55 +0000 (18:17 +0200)]
liballoc: VecDeque: Add tracking issue for binary search fns

3 years agoAuto merge of #77972 - Mark-Simulacrum:side-effect-loop, r=nagisa
bors [Fri, 16 Oct 2020 14:06:37 +0000 (14:06 +0000)]
Auto merge of #77972 - Mark-Simulacrum:side-effect-loop, r=nagisa

Prevent miscompilation in trivial loop {}

Ideally, we would want to handle a broader set of cases to fully fix the
underlying bug here. That is currently relatively expensive at compile and
runtime, so we don't do that for now.

Performance results indicate this is not a major regression, if at all, so it should be safe to land.

cc #28728

3 years agoFix sidebar scroll on mobile devices
Guillaume Gomez [Fri, 16 Oct 2020 13:01:17 +0000 (15:01 +0200)]
Fix sidebar scroll on mobile devices

3 years agoAuto merge of #77850 - kornelski:resizedefault, r=dtolnay
bors [Fri, 16 Oct 2020 12:11:32 +0000 (12:11 +0000)]
Auto merge of #77850 - kornelski:resizedefault, r=dtolnay

Remove deprecated unstable Vec::resize_default

It's [been deprecated](https://github.com/rust-lang/rust/pull/57656) for 15 releases.

3 years agoAuto merge of #77809 - nasso:master, r=jyn514,guillaumegomez
bors [Fri, 16 Oct 2020 09:58:45 +0000 (09:58 +0000)]
Auto merge of #77809 - nasso:master, r=jyn514,guillaumegomez

Add settings to rustdoc to use the system theme

This PR adds new settings to `rustdoc` to use the operating system color scheme.

![click](https://user-images.githubusercontent.com/11479594/95668052-bf604e80-0b6e-11eb-8a17-473aaae510c9.gif)

`rustdoc` actually had [basic support for this](https://github.com/rust-lang/rust/blob/b1af43bc63bc7417938df056f7f25d456cc11b0e/src/librustdoc/html/static/storage.js#L121), but the setting wasn't visible and couldn't be set back once the theme was explicitly set by the user. It also didn't update if the operating system theme preference changed while viewing a page.

I'm using [this method](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries#Receiving_query_notifications) to query and listen to changes to the `(prefers-color-scheme: dark)` media query. I kept the old method (based on `getComputedStyle`) as a fallback in case the user-agent doesn't support `window.matchMedia` (so like... [pretty much nobody](https://caniuse.com/?search=matchMedia)).

Since there's now more than one official ""dark"" theme in `rustdoc` (and also to support custom/third-party themes), the preferred dark and light themes can be configured in the settings page (the defaults are just "dark" and "light").

This is also my very first "proper" PR to Rust! Please let me know if I did anything wrong :).

3 years agostop relying on feature(untagged_unions) in stdlib
Ralf Jung [Mon, 5 Oct 2020 07:20:39 +0000 (09:20 +0200)]
stop relying on feature(untagged_unions) in stdlib

3 years agostabilize union with 'ManuallyDrop' fields and 'impl Drop for Union'
Ralf Jung [Sun, 4 Oct 2020 20:24:14 +0000 (22:24 +0200)]
stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union'

3 years agoRemove shrink_to_fit from default ToString::to_string implementation.
Mara Bos [Thu, 15 Oct 2020 21:36:26 +0000 (23:36 +0200)]
Remove shrink_to_fit from default ToString::to_string implementation.

Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
3 years agoAuto merge of #77666 - fusion-engineering-forks:vxworks-cleanup, r=dtolnay
bors [Fri, 16 Oct 2020 07:44:35 +0000 (07:44 +0000)]
Auto merge of #77666 - fusion-engineering-forks:vxworks-cleanup, r=dtolnay

Vxworks / Unix deduplication

`sys/vxworks` was almost entirely an (outdated) copy of `sys/unix`. I went through every file to check the differences and tried to figure out if they were simply outdated or intentional differences between `unix` and `vxworks`. Most of them did not have any `vxworks`-specific changes, so are deleted. I've added some minor `cfg(target_os = "vxworks")`-specific things to `sys/unix` to allow for deduplication.

Before this change, the vxworks target didn't compile because its outdated process implementation did not match the expected interface anymore. This also fixes that: `std` compiles again for `x86_64-wrs-vxworks`.

It's probably good to merge `sys/vxworks` entirely into `sys/unix`, but it might be better to to that in a follow-up PR.

`@rustbot` modify labels: +T-libs +C-cleanup

3 years agoAuto merge of #77962 - bugadani:arena2, r=Mark-Simulacrum
bors [Fri, 16 Oct 2020 04:40:53 +0000 (04:40 +0000)]
Auto merge of #77962 - bugadani:arena2, r=Mark-Simulacrum

Remove arena's dependency on `rustc_data_structures`

`rustc_arena` currently has a dependency on `rustc_data_structures` because of a trivial "don't inline me" function. This PR copies that function and removes the dependency.

3 years agoTake some of sys/vxworks/process/* from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take some of sys/vxworks/process/* from sys/unix instead.

3 years agoTake sys/vxworks/{os,path,pipe} from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/{os,path,pipe} from sys/unix instead.

3 years agoTake sys/vxworks/{fd,fs,io} from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/{fd,fs,io} from sys/unix instead.

3 years agoTake sys/vxworks/cmath from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/cmath from sys/unix instead.

3 years agoTake sys/vxworks/args from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/args from sys/unix instead.

3 years agoTake sys/vxworks/memchar from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/memchar from sys/unix instead.

3 years agoTake sys/vxworks/net from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/net from sys/unix instead.

3 years agoTake sys/vxworks/ext/* from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Take sys/vxworks/ext/* from sys/unix instead.

3 years agoAdd weak macro to vxworks.
Mara Bos [Wed, 7 Oct 2020 18:38:25 +0000 (20:38 +0200)]
Add weak macro to vxworks.

3 years agoTake sys/vxworks/alloc from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:09:07 +0000 (19:09 +0200)]
Take sys/vxworks/alloc from sys/unix instead.

3 years agoTake sys/vxworks/thread_local_key from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/thread_local_key from sys/unix instead.

3 years agoTake sys/vxworks/stdio from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/stdio from sys/unix instead.

3 years agoTake sys/vxworks/thread from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/thread from sys/unix instead.

3 years agoTake sys/vxworks/stack_overflow from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/stack_overflow from sys/unix instead.

3 years agoTake sys/vxworks/time from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/time from sys/unix instead.

3 years agoTake sys/vxworks/rwlock from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/rwlock from sys/unix instead.

3 years agoTake sys/vxworks/condvar from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:56 +0000 (19:01 +0200)]
Take sys/vxworks/condvar from sys/unix instead.

3 years agoTake sys/vxworks/mutex from sys/unix instead.
Mara Bos [Wed, 7 Oct 2020 17:01:27 +0000 (19:01 +0200)]
Take sys/vxworks/mutex from sys/unix instead.

3 years agoAuto merge of #77947 - tmiasko:promoted-scope, r=oli-obk
bors [Fri, 16 Oct 2020 02:27:49 +0000 (02:27 +0000)]
Auto merge of #77947 - tmiasko:promoted-scope, r=oli-obk

Create a single source scope for promoteds

A promoted inherits all scopes from the parent body.  At the same time,
almost all statements and terminators inside the promoted body so far
refer only to one of those scopes: the outermost one.

Instead of inheriting all scopes, inherit only a single scope
corresponding to the location of the promoted, making sure that there
are no references to other scopes.

3 years agoUpdate submodules for link fixes
Joshua Nelson [Fri, 16 Oct 2020 00:29:21 +0000 (20:29 -0400)]
Update submodules for link fixes

- [rust-embedded](https://github.com/rust-embedded/book/compare/79ab7776929c66db83203397958fa7037d5d9a30...ca8169e69b479f615855d0eece7e318138fcfc00)
- [cargo](https://github.com/rust-lang/cargo/compare/12db56cdedbc2c26a9aa18f994c0188cdcc67df5...79b397d72c557eb6444a2ba0dc00a211a226a35a)

3 years agoDeny broken intra-doc links in linkchecker
Joshua Nelson [Thu, 15 Oct 2020 13:25:30 +0000 (09:25 -0400)]
Deny broken intra-doc links in linkchecker

Since rustdoc isn't warning about these links, check for them manually.

3 years agoAuto merge of #78001 - Dylan-DPC:rollup-zq3kxth, r=Dylan-DPC
bors [Fri, 16 Oct 2020 00:18:13 +0000 (00:18 +0000)]
Auto merge of #78001 - Dylan-DPC:rollup-zq3kxth, r=Dylan-DPC

Rollup of 14 pull requests

Successful merges:

 - #75023 (ensure arguments are included in count mismatch span)
 - #75265 (Add `str::{Split,RSplit,SplitN,RSplitN,SplitTerminator,RSplitTerminator,SplitInclusive}::as_str` methods)
 - #75675 (mangling: mangle impl params w/ v0 scheme)
 - #76084 (Refactor io/buffered.rs into submodules)
 - #76119 (Stabilize move_ref_pattern)
 - #77493 (ICEs should always print the top of the query stack)
 - #77619 (Use futex-based thread-parker for Wasm32.)
 - #77646 (For backtrace, use StaticMutex instead of a raw sys Mutex.)
 - #77648 (Static mutex is static)
 - #77657 (Cleanup cloudabi mutexes and condvars)
 - #77672 (Simplify doc-cfg rendering based on the current context)
 - #77780 (rustc_parse: fix spans on cast and range exprs with attrs)
 - #77935 (BTreeMap: make PartialCmp/PartialEq explicit and tested)
 - #77980 (Fix intra doc link for needs_drop)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #77980 - Manishearth:needs-drop-intra, r=jyn514
Dylan DPC [Fri, 16 Oct 2020 00:10:25 +0000 (02:10 +0200)]
Rollup merge of #77980 - Manishearth:needs-drop-intra, r=jyn514

Fix intra doc link for needs_drop

It currently links to itself. Oops.

r? @jyn514

3 years agoRollup merge of #77935 - ssomers:btree_cleanup_1, r=Mark-Simulacrum
Dylan DPC [Fri, 16 Oct 2020 00:10:24 +0000 (02:10 +0200)]
Rollup merge of #77935 - ssomers:btree_cleanup_1, r=Mark-Simulacrum

BTreeMap: make PartialCmp/PartialEq explicit and tested

Follow-up on a topic raised in #77612

r? @Mark-Simulacrum

3 years agoRollup merge of #77780 - calebcartwright:cast-expr-attr-span, r=oli-obk
Dylan DPC [Fri, 16 Oct 2020 00:10:22 +0000 (02:10 +0200)]
Rollup merge of #77780 - calebcartwright:cast-expr-attr-span, r=oli-obk

rustc_parse: fix spans on cast and range exprs with attrs

Currently the span for cast and range expressions does not include the span of attributes associated to the lhs which is causing some issues for us in rustfmt.

```rust
fn foo() -> i64 {
    #[attr]
    1u64 as i64
}

fn bar() -> Range<i32> {
    #[attr]
    1..2
}
```

This corrects the span for cast and range expressions to fully include the span of child nodes

3 years agoRollup merge of #77672 - Nemo157:simplify-cfg, r=jyn514
Dylan DPC [Fri, 16 Oct 2020 00:10:19 +0000 (02:10 +0200)]
Rollup merge of #77672 - Nemo157:simplify-cfg, r=jyn514

Simplify doc-cfg rendering based on the current context

For sub-items on a page don't show cfg that has already been rendered on
a parent item. At its simplest this means not showing anything that is
shown in the portability message at the top of the page, but also for
things like fields of an enum variant if that variant itself is
cfg-gated then don't repeat those cfg on each field of the variant.

This does not touch trait implementation rendering, as that is more
complex and there are existing issues around how it deals with doc-cfg
that need to be fixed first.

### Screenshots, left is current, right is new:

![image](https://user-images.githubusercontent.com/81079/95387261-c2e6a200-08f0-11eb-90d4-0a9734acd922.png)

![image](https://user-images.githubusercontent.com/81079/95387458-06411080-08f1-11eb-81f7-5dd7f37695dd.png)

![image](https://user-images.githubusercontent.com/81079/95387702-6637b700-08f1-11eb-82f4-46b6cd9b24f2.png)

![image](https://user-images.githubusercontent.com/81079/95387905-b9aa0500-08f1-11eb-8d95-8b618d31d419.png)

![image](https://user-images.githubusercontent.com/81079/95388300-5bc9ed00-08f2-11eb-9ac9-b92cbdb60b89.png)

cc #43781

3 years agoRollup merge of #77657 - fusion-engineering-forks:cleanup-cloudabi-sync, r=dtolnay
Dylan DPC [Fri, 16 Oct 2020 00:10:17 +0000 (02:10 +0200)]
Rollup merge of #77657 - fusion-engineering-forks:cleanup-cloudabi-sync, r=dtolnay

Cleanup cloudabi mutexes and condvars

This gets rid of lots of unnecessary unsafety.

All the AtomicU32s were wrapped in UnsafeCell or UnsafeCell<MaybeUninit>, and raw pointers were used to get to the AtomicU32 inside. This change cleans that up by using AtomicU32 directly.

Also replaces a UnsafeCell<u32> by a safer Cell<u32>.

@rustbot modify labels: +C-cleanup

3 years agoRollup merge of #77648 - fusion-engineering-forks:static-mutex, r=dtolnay
Dylan DPC [Fri, 16 Oct 2020 00:10:15 +0000 (02:10 +0200)]
Rollup merge of #77648 - fusion-engineering-forks:static-mutex, r=dtolnay

Static mutex is static

StaticMutex is only ever used with as a static (as the name already suggests). So it doesn't have to be generic over a lifetime, but can simply assume 'static.

This 'static lifetime guarantees the object is never moved, so this is no longer a manually checked requirement for unsafe calls to lock().

@rustbot modify labels: +T-libs +A-concurrency +C-cleanup

3 years agoRollup merge of #77646 - fusion-engineering-forks:use-static-mutex, r=dtolnay
Dylan DPC [Fri, 16 Oct 2020 00:10:13 +0000 (02:10 +0200)]
Rollup merge of #77646 - fusion-engineering-forks:use-static-mutex, r=dtolnay

For backtrace, use StaticMutex instead of a raw sys Mutex.

The code used the very unsafe `sys::mutex::Mutex` directly, and built its own unlock-on-drop wrapper around it. The StaticMutex wrapper already provides that and is easier to use safely.

@rustbot modify labels: +T-libs +C-cleanup

3 years agoRollup merge of #77619 - fusion-engineering-forks:wasm-parker, r=dtolnay
Dylan DPC [Fri, 16 Oct 2020 00:10:11 +0000 (02:10 +0200)]
Rollup merge of #77619 - fusion-engineering-forks:wasm-parker, r=dtolnay

Use futex-based thread-parker for Wasm32.

This uses the existing `sys_common/thread_parker/futex.rs` futex-based thread parker (that was already used for Linux) for wasm32 as well (if the wasm32 atomics target feature is enabled, which is not the case by default).

Wasm32 provides the basic futex operations as instructions: https://webassembly.github.io/threads/syntax/instructions.html

These are now exposed from `sys::futex::{futex_wait, futex_wake}`, just like on Linux. So, `thread_parker/futex.rs` stays completely unmodified.