Commit Graph

129677 Commits

Author SHA1 Message Date
Yuki Okushi
57e38dd4fb
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.
2020-10-18 04:11:11 +09:00
Yuki Okushi
407bba4676
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'`
2020-10-18 04:11:09 +09:00
Yuki Okushi
a0242e73bb
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
2020-10-18 04:11:07 +09:00
Yuki Okushi
83ee319822
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.
2020-10-18 04:11:05 +09:00
Yuki Okushi
d10b98d7a5
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
2020-10-18 04:11:03 +09:00
Jacob Hughes
3e2121cb4a Appease the almightly lord clippy, hallowed be thy name 2020-10-17 13:48:54 -04:00
bors
6af9846fcc 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`
2020-10-17 14:44:51 +00:00
bors
dda2b5e3e2 Auto merge of #78039 - tmiasko:unreachable-block, r=Mark-Simulacrum
Remove unused cached_unreachable_block from MIR builder
2020-10-17 12:36:32 +00:00
Jan Verbeek
e701ae376a 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.
2020-10-17 13:36:59 +02:00
Vadim Petrochenkov
3522add318 resolve: Do not put nonexistent crate meta into prelude 2020-10-17 14:04:49 +03:00
bors
6f0ea299cf 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`
2020-10-17 10:28:52 +00:00
Will Crozier
786e3ea31a Fix grammar in note for orphan-rule error [E0210] 2020-10-17 11:03:45 +01:00
bors
03687f8ffa 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
2020-10-17 08:19:12 +00:00
bors
4cb7ef0f94 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]: 5f72f9800b/posix/execvpe.c (L81)
2020-10-17 06:16:00 +00:00
Ivan Tham
e96ca1b2ba
Fix some double quote that cause CI failure
Co-authored-by: Oliver Middleton <olliemail27@gmail.com>
2020-10-17 13:53:51 +08:00
bors
66e37b65bf 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.
2020-10-17 04:09:08 +00:00
bors
3f50dea4d0 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`
2020-10-17 01:41:43 +00:00
Dylan DPC
b9c45d1e78
Rollup merge of #77985 - cuviper:systemz-agr-clobbers-cc, r=nikic
llvm: backport SystemZ fix for AGR clobbers

Fixes #77382.
2020-10-17 03:27:22 +02:00
Dylan DPC
55f9676c47
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.
2020-10-17 03:27:20 +02:00
Dylan DPC
16b878fd0f
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
2020-10-17 03:27:18 +02:00
Dylan DPC
446686f59b
Rollup merge of #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27
Remove compiler-synthesized reexports when documenting

Fixes #77567

r? @ollie27
2020-10-17 03:27:17 +02:00
Dylan DPC
f40ecff964
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.
2020-10-17 03:27:15 +02:00
Dylan DPC
496e2feed6
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](c0f587de34) 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.
2020-10-17 03:27:12 +02:00
Tomasz Miąsko
a65a283332 Remove unused cached_unreachable_block from MIR builder 2020-10-17 00:00:00 +00:00
bors
f1b97ee7f8 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`
2020-10-16 22:53:50 +00:00
Santiago Pastorino
03321b8cca
Add inline const to INCOMPLETE_FEATURES 2020-10-16 18:15:57 -03:00
bors
e3051d8c24 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`
2020-10-16 20:43:27 +00:00
Yuki Okushi
001fcd96d5
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
2020-10-17 05:36:54 +09:00
Yuki Okushi
d334059696
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.
2020-10-17 05:36:52 +09:00
Yuki Okushi
b4282b37f1
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`.
2020-10-17 05:36:50 +09:00
Yuki Okushi
050eb4d7e4
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.
2020-10-17 05:36:49 +09:00
Yuki Okushi
9600fda7ba
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
2020-10-17 05:36:47 +09:00
Yuki Okushi
9abf81afa8
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
2020-10-17 05:36:45 +09:00
Yuki Okushi
75ef735d4a
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
2020-10-17 05:36:43 +09:00
Yuki Okushi
8c4d8555f3
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
2020-10-17 05:36:41 +09:00
Yuki Okushi
3356ad7c26
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
2020-10-17 05:36:38 +09:00
Yuki Okushi
7581bb7c02
Rollup merge of #75209 - Hirrolot:suggest-macro-imports, r=estebank
Suggest imports of unresolved macros

Closes https://github.com/rust-lang/rust/issues/75191.
2020-10-17 05:36:32 +09:00
Santiago Pastorino
547e5eb498
Do not check unused braces on inline consts 2020-10-16 17:14:37 -03:00
Santiago Pastorino
03defb627c
Add check_generic_arg early pass 2020-10-16 17:14:36 -03:00
Santiago Pastorino
27411d6d2b
Handle ExprKind::ConstBlock on clippy 2020-10-16 17:14:34 -03:00
Santiago Pastorino
54596c9b56
Add inline const tests 2020-10-16 17:14:31 -03:00
Jack Huey
f6a53b4c69 Review comments 2020-10-16 15:14:38 -04:00
Eric Huss
031d2b0658 Bump bootstrap compiler 2020-10-16 11:54:16 -07:00
Vojtech Kral
c7a787a327 liballoc: VecDeque: Simplify binary_search_by() 2020-10-16 20:49:19 +02:00
Simonas Kazlauskas
8436cfe71d 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.
2020-10-16 21:46:41 +03:00
Jack Huey
eba10270c6 map_bound_ref -> rebind 2020-10-16 14:29:21 -04:00
Santiago Pastorino
85b5ce2643
Typeck inline consts 2020-10-16 15:21:20 -03:00
Santiago Pastorino
fe922e567f
Lower inline const down to MIR 2020-10-16 15:21:18 -03:00
Santiago Pastorino
66e254314d
Lower inline const's AST to HIR 2020-10-16 15:21:16 -03:00
Santiago Pastorino
59d07c3ae5
Parse inline const patterns 2020-10-16 15:15:34 -03:00