Commit graph

155879 commits

Author SHA1 Message Date
bors
44995f7afb Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisa
Turn vtable_allocation() into a query

This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query.

The change is pretty straightforward and should be backportable without too much effort.

Fixes https://github.com/rust-lang/rust/issues/89598.
2021-10-08 09:04:06 +00:00
bors
3013b26947 Auto merge of #89659 - workingjubilee:rollup-0vggc69, r=workingjubilee
Rollup of 8 pull requests

Successful merges:

 - #87918 (Enable AutoFDO.)
 - #88137 (On macOS, make strip="symbols" not pass any options to strip)
 - #88772 (Fixed confusing wording on Result::map_or_else.)
 - #89025 (Implement `#[link_ordinal(n)]`)
 - #89082 (Implement #85440 (Random test ordering))
 - #89288 (Wrapper for `-Z gcc-ld=lld` to invoke rust-lld with the correct flavor)
 - #89476 (Correct decoding of foreign expansions during incr. comp.)
 - #89622 (Use correct edition for panic in [debug_]assert!().)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-08 06:16:31 +00:00
Jubilee
30e068f58b
Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank
Use correct edition for panic in [debug_]assert!().

See https://github.com/rust-lang/rust/issues/88638#issuecomment-915472783
2021-10-07 20:26:15 -07:00
Jubilee
aed1801841
Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkov
Correct decoding of foreign expansions during incr. comp.

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

The original issue was due to a wrong assertion in `expn_hash_to_expn_id`.

The secondary issue was due to a mismatch between the encoding and decoding paths for expansions that are created after the TyCtxt is created.
2021-10-07 20:26:14 -07:00
Jubilee
1c1c6eda94
Rollup merge of #89288 - rusticstuff:lld_wrapper, r=Mark-Simulacrum
Wrapper for `-Z gcc-ld=lld` to invoke rust-lld with the correct flavor

This PR adds an `lld-wrapper` tool which is installed as `ld` and `ld64` in `lib\rustlib\<host_target>\bin\gcc-ld` directory and whose sole purpose is to invoke `rust-lld` in the parent directory with the correct flavor. Lld decides which flavor to use from either the first two commandline arguments or from the name of the executable (`ld` for GNU/ld flavor, `ld64` for Darwin/Macos/ld64 flavor and so on). Symbolic links could not be used as they are not supported by rustup and on Windows.

The wrapper replaces full copies of rust-lld which added some significant bloat. On UNIXish operating systems it exec rust-lld, on Windows it spawns it as a child process.

Fixes #88869.

r? ```@Mark-Simulacrum```
cc ```@nagisa``` ```@petrochenkov``` ```@1000teslas```
2021-10-07 20:26:13 -07:00
Jubilee
37f17bca7c
Rollup merge of #89082 - smoelius:master, r=kennytm
Implement #85440 (Random test ordering)

This PR adds `--shuffle` and `--shuffle-seed` options to `libtest`. The options are similar to the [`-shuffle` option](c894b442d1/src/testing/testing.go (L1482-L1499)) that was recently added to Go.

Here are the relevant parts of the help message:
```
        --shuffle       Run tests in random order
        --shuffle-seed SEED
                        Run tests in random order; seed the random number
                        generator with SEED
...
By default, the tests are run in alphabetical order. Use --shuffle or set
RUST_TEST_SHUFFLE to run the tests in random order. Pass the generated
"shuffle seed" to --shuffle-seed (or set RUST_TEST_SHUFFLE_SEED) to run the
tests in the same order again. Note that --shuffle and --shuffle-seed do not
affect whether the tests are run in parallel.
```
Is an RFC needed for this?
2021-10-07 20:26:12 -07:00
Jubilee
6c17601a2e
Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoerister
Implement `#[link_ordinal(n)]`

Allows the use of `#[link_ordinal(n)]` with `#[link(kind = "raw-dylib")]`, allowing Rust to link against DLLs that export symbols by ordinal rather than by name.  As long as the ordinal matches, the name of the function in Rust is not required to match the name of the corresponding function in the exporting DLL.

Part of #58713.
2021-10-07 20:26:11 -07:00
Jubilee
2b6d7f75f7
Rollup merge of #88772 - orlp:result-map-or-else-docfix, r=yaahc
Fixed confusing wording on Result::map_or_else.

Fixes https://github.com/rust-lang/rust/issues/88195.
2021-10-07 20:26:11 -07:00
Jubilee
cbb561fdab
Rollup merge of #88137 - joshtriplett:osx-strip-symbols-no-option, r=michaelwoerister
On macOS, make strip="symbols" not pass any options to strip

This makes the output with `strip="symbols"` match the result of just
calling `strip` on the output binary, minimizing the size of the binary.
2021-10-07 20:26:10 -07:00
Jubilee
6c2d4bf3f7
Rollup merge of #87918 - mikebenfield:pr-afdo, r=nikic
Enable AutoFDO.

This largely involves implementing the options debug-info-for-profiling
and profile-sample-use and forwarding them on to LLVM.

AutoFDO can be used on x86-64 Linux like this:
rustc -O -Clink-arg='Wl,--no-rosegment' -Cdebug-info-for-profiling main.rs -o main
perf record -b ./main
create_llvm_prof --binary=main --out=code.prof
rustc -O -Cprofile-sample-use=code.prof main.rs -o main2

Now `main2` will have feedback directed optimization applied to it.

The create_llvm_prof tool can be obtained from this github repository:
https://github.com/google/autofdo

The option -Clink-arg='Wl,--no-rosegment' is necessary to avoid lld
putting an extra RO segment before the executable code, which would make
the binary silently incompatible with create_llvm_prof.
2021-10-07 20:26:09 -07:00
bors
c2171ee53e Auto merge of #89646 - camelid:miri-up, r=RalfJung
Update Miri

Fixes #89612.

r? `@RalfJung`
2021-10-08 03:14:19 +00:00
bors
2ee06e7372 Auto merge of #89638 - rust-lang:revert-88548-intersperse, r=Mark-Simulacrum
Revert "Stabilize `Iterator::intersperse()`"

Reverts rust-lang/rust#88548

First step in resolving https://github.com/rust-lang/rust/issues/88967
2021-10-07 23:50:54 +00:00
Noah Lev
9771803934 Update Miri 2021-10-07 13:47:00 -07:00
bors
485ced56b8 Auto merge of #89617 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2021-10-07 20:26:27 +00:00
Michael Woerister
b7cc99142a Turn tcx.vtable_allocation() into a query. 2021-10-07 20:03:00 +02:00
Jane Lusby
8965b5884a
Revert "Stabilize Iterator::intersperse()" 2021-10-07 10:39:36 -07:00
bors
5641481ad7 Auto merge of #89629 - GuillaumeGomez:rollup-s4r8me6, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #89298 (Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers )
 - #89461 (Add `deref_into_dyn_supertrait` lint.)
 - #89477 (Move items related to computing diffs to a separate file)
 - #89559 (RustWrapper: adapt for LLVM API change)
 - #89585 (Emit item no type error even if type inference fails)
 - #89596 (Make cfg imply doc(cfg))
 - #89615 (Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-07 17:17:25 +00:00
Hans Kratz
6162fc0c80 Add wrapper for -Z gcc-ld=lld to invoke rust-lld with the correct flavor
The wrapper is installed as `ld` and `ld64` in the `lib\rustlib\<host_target>\bin\gcc-ld`
directory and its sole purpose is to invoke `rust-lld` in the parent directory with
the correct flavor.
2021-10-07 16:59:13 +02:00
Guillaume Gomez
0fbb011eb4
Rollup merge of #89615 - willcrichton:fix-get-body-with-borrowck-facts, r=oli-obk
Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts

`mir_borrowck` uses `with_opaque_type_inference` before calling `do_mir_borrowck`: 0eabf25b90/compiler/rustc_borrowck/src/lib.rs (L132)

However `get_body_with_borrowck_facts` does not. Therefore I get an ICE eg when calling this function on the bodies of an async function as described here: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20ICE.20when.20using.20get_body_with_borrowck_facts.20with.20async

This change fixes that bug.

r? `@nikomatsakis`
2021-10-07 16:24:54 +02:00
Guillaume Gomez
e32328bdc5
Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514
Make cfg imply doc(cfg)

This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):

 * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc.
 * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation.
 * I updated the version for the feature.

There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624)

> I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different.

How/why should they differ?

EDIT: this part has been solved, the current code was fine, just needed a little simplification.

cc `@Nemo157`
r? `@jyn514`

Original PR description:

This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like:

```rust
#[cfg(unix)]
#[doc(cfg(all()))]
pub struct Unix;
```

By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-07 16:24:53 +02:00
Guillaume Gomez
de0b4f9444
Rollup merge of #89585 - nbdd0121:issue-89574, r=estebank
Emit item no type error even if type inference fails

Fix #89574

The stashed error should be emitted regardless whether ty references error or not.
2021-10-07 16:24:52 +02:00
Guillaume Gomez
110d289846
Rollup merge of #89559 - krasimirgg:llvm-14-fatal_error_handler_t, r=nagisa
RustWrapper: adapt for LLVM API change

No functional changes intended.

The LLVM commit
e463b69736
changed an argument of fatal_error_handler_t from std::string to char*.
This adapts RustWrapper accordingly.
2021-10-07 16:24:51 +02:00
Guillaume Gomez
48548c91d6
Rollup merge of #89477 - Nicholas-Baron:compute_diff_rs, r=Mark-Simulacrum
Move items related to computing diffs to a separate file

Work towards #89475.
2021-10-07 16:24:50 +02:00
Guillaume Gomez
ab276b82b0
Rollup merge of #89461 - crlf0710:dyn_upcasting_lint, r=nikomatsakis
Add `deref_into_dyn_supertrait` lint.

Initial implementation of #89460. Resolves #89190.
Maybe also worth a beta backport if necessary.

r? `@nikomatsakis`
2021-10-07 16:24:49 +02:00
Guillaume Gomez
1584b6a796
Rollup merge of #89298 - gcohara:issue89193, r=workingjubilee
Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers

closes #89193
r? `@workingjubilee`
2021-10-07 16:24:48 +02:00
bors
0157cc977f Auto merge of #89534 - camsteffen:diag-name, r=oli-obk
Introduce `tcx.get_diagnostic_name`

Introduces a "reverse lookup" for diagnostic items. This is mainly intended for `@rust-lang/clippy` which often does a long series of `is_diagnostic_item` calls for the same `DefId`.

r? `@oli-obk`
2021-10-07 14:22:16 +00:00
Mara Bos
fcd9fa9099 Add tests for panic and [debug_]assert in Rust 2021. 2021-10-07 14:27:08 +02:00
Mara Bos
afe5335b97 Use correct edition for panic in [debug_]assert!() etc. 2021-10-07 14:27:08 +02:00
bors
680ff86391 Auto merge of #86525 - shamatar:array_len_opt, r=oli-obk
Array `.len()` MIR optimization pass

This pass kind-of works back the `[T; N].len()` call that at the moment is first coerced as `&[T; N]` -> `&[T]` and then uses `&[T].len()`. Depends on #86383
2021-10-07 11:34:40 +00:00
Michael Woerister
a1e2c0f0ad Remove untracked vtable-const-allocation cache from tcx 2021-10-07 11:27:35 +02:00
flip1995
333a06af42
Merge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup 2021-10-07 11:21:30 +02:00
bors
b7f3f7f608 Auto merge of #7783 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

Finally an easy, conflict free rustup again 🎉

changelog: none
2021-10-07 09:18:25 +00:00
flip1995
8f9ef87f75
Bump nightly version -> 2021-10-07 2021-10-07 11:12:27 +02:00
flip1995
9613df9c85
Allow invalid-paths for regex paths 2021-10-07 11:12:02 +02:00
flip1995
1f955158dd
Merge remote-tracking branch 'upstream/master' into rustup 2021-10-07 11:11:23 +02:00
bors
ca8078d7b2 Auto merge of #89495 - Mark-Simulacrum:add-inlines, r=michaelwoerister
Add two inline annotations for hot functions

These two functions are essentially no-ops (and compile to just a load and
return), but show up in process_obligations profiles with a high call count --
so worthwhile to try and inline them. This is not normally possible as they're
non-generic, so they don't get offered for inlining by our current algorithm.
2021-10-07 06:23:23 +00:00
bors
01ea06acb7 Auto merge of #7780 - mikerite:update_lints_mod_revert, r=llogiq
Revert `update_lints` module list generating code

This commit reverts the module list generation code to what it was
before the change to `include!` it and generates better output.

changelog: none
2021-10-07 05:00:53 +00:00
Michael Wright
8f075ec961 Revert update_lints module list generating code
This commit reverts the module list generation code to what it was
before the change to `include!` it and generates better output.
2021-10-07 06:42:21 +02:00
bors
d3e6770efb Auto merge of #89454 - erikdesjardins:perfattrcheck, r=nikomatsakis
perf: only check for `rustc_trivial_field_reads` attribute on traits, not items, impls, etc.

The checks that are removed in this PR (originally added in #85200) caused a small perf regression: https://github.com/rust-lang/rust/pull/88824#issuecomment-932664761

Since the attribute is currently only applied to traits, I don't think it's worth keeping the additional checks for now.
If/when we decide to apply the attribute somewhere else, we can (partially) revert this and reevaluate the perf impact.

r? `@nikomatsakis` cc `@FabianWolff`
2021-10-07 03:42:05 +00:00
Will Crichton
549a68b73e Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts 2021-10-06 19:07:56 -07:00
bors
0eabf25b90 Auto merge of #89608 - Manishearth:rollup-m7kd76f, r=Manishearth
Rollup of 12 pull requests

Successful merges:

 - #87601 (Add functions to add unsigned and signed integers)
 - #88523 (Expand documentation for `FpCategory`.)
 - #89050 (refactor: VecDeques Drain fields to private)
 - #89245 (refactor: make VecDeque's IterMut fields module-private, not just crate-private)
 - #89324 (Rename `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`)
 - #89329 (print-type-sizes: skip field printing for primitives)
 - #89501 (Note specific regions involved in 'borrowed data escapes' error)
 - #89506 (librustdoc: Use correct heading levels.)
 - #89528 (Fix suggestion to borrow when casting from pointer to reference)
 - #89531 (library std, libc dependency update)
 - #89588 (Add a test for generic_const_exprs)
 - #89591 (fix: alloc-optimisation is only for rust llvm)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-06 20:17:28 +00:00
Michael Benfield
a17193dbb9 Enable AutoFDO.
This largely involves implementing the options debug-info-for-profiling
and profile-sample-use and forwarding them on to LLVM.

AutoFDO can be used on x86-64 Linux like this:
rustc -O -Cdebug-info-for-profiling main.rs -o main
perf record -b ./main
create_llvm_prof --binary=main --out=code.prof
rustc -O -Cprofile-sample-use=code.prof main.rs -o main2

Now `main2` will have feedback directed optimization applied to it.

The create_llvm_prof tool can be obtained from this github repository:
https://github.com/google/autofdo

Fixes #64892.
2021-10-06 19:36:52 +00:00
Manish Goregaokar
f31c805038
Rollup merge of #89591 - infinity0:master, r=Amanieu
fix: alloc-optimisation is only for rust llvm

As discussed at the bottom of #83485.

On a separate note I'll take this chance ask, is it worth pulling in that patch (to recognise `__rust_dealloc`) into Debian's system LLVM? The main factors for us to consider would be (1) is the optimisation significant and (2) is there not any significant negative impact to non-rust packages that use LLVM.
2021-10-06 12:33:24 -07:00
Manish Goregaokar
eb7da35d84
Rollup merge of #89588 - BoxyUwU:add_a_test_uwu, r=lcnr
Add a test for generic_const_exprs

Test that const_eval_resolve evaluates consts with unused inference vars in substs

r? ``@lcnr``
2021-10-06 12:33:23 -07:00
Manish Goregaokar
79a1fc8419
Rollup merge of #89531 - devnexen:stack_overflow_bsd_libc_upd, r=dtolnay
library std, libc dependency update

to solve #87528 build.
2021-10-06 12:33:22 -07:00
Manish Goregaokar
f5bfa3450a
Rollup merge of #89528 - FabianWolff:issue-89497, r=jackh726
Fix suggestion to borrow when casting from pointer to reference

Fixes #89497.
2021-10-06 12:33:21 -07:00
Manish Goregaokar
7d6feb421e
Rollup merge of #89506 - yaymukund:docblock-headings, r=GuillaumeGomez
librustdoc: Use correct heading levels.

Closes #89309

This fixes the `<h#>` header tags throughout the docs to reflect a semantic hierarchy.

- I ran a script to manually check that we don't have any files with multiple `<h1>` tags.
- Also checked that we never incorrectly nest e.g. a `<h2>` under an `<h3>`.
- I also spot-checked a bunch of pages (`trait.Read`, `enum.Ordering`, `primitive.isize`, `trait.Iterator`).
2021-10-06 12:33:20 -07:00
Manish Goregaokar
b01594051c
Rollup merge of #89501 - Aaron1011:escaping-name-regions, r=davidtwco
Note specific regions involved in 'borrowed data escapes' error

Fixes #67007

Currently, a 'borrowed data escapes' error does not mention
the specific lifetime involved (except indirectly through a suggestion
about adding a lifetime bound). We now explain the specific lifetime
relationship that failed to hold, which improves otherwise vague
error messages.
2021-10-06 12:33:19 -07:00
Manish Goregaokar
b87a9a8a7c
Rollup merge of #89329 - tmiasko:print-type-sizes-no-fields, r=jackh726
print-type-sizes: skip field printing for primitives

Fixes #86528.
2021-10-06 12:33:18 -07:00
Manish Goregaokar
b4615b5bf9
Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se
Rename `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`

_Tracking issue: https://github.com/rust-lang/rust/issues/74479_

This PR renames  `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`.

## Rationale

The API was initially named `std:🧵:hardware_concurrency`, mirroring the [C++ API of the same name](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency). We eventually decided to omit any reference to the word "hardware" after [this comment](https://github.com/rust-lang/rust/pull/74480#issuecomment-662045841). And so we ended up with `available_concurrency` instead.

---

For a talk I was preparing this week I was reading through ["Understanding and expressing scalable concurrency" (A. Turon, 2013)](http://aturon.github.io/academic/turon-thesis.pdf), and the following passage stood out to me (emphasis mine):

> __Concurrency is a system-structuring mechanism.__ An interactive system that deals with disparate asynchronous events is naturally structured by division into concurrent threads with disparate responsibilities. Doing so creates a better fit between problem and solution, and can also decrease the average latency of the system by preventing long-running computations from obstructing quicker ones.

> __Parallelism is a resource.__ A given machine provides a certain capacity for parallelism, i.e., a bound on the number of computations it can perform simultaneously. The goal is to maximize throughput by intelligently using this resource. For interactive systems, parallelism can decrease latency as well.

_Chapter 2.1: Concurrency is not Parallelism. Page 30._

---

_"Concurrency is a system-structuring mechanism. Parallelism is a resource."_ — It feels like this accurately captures the way we should be thinking about these APIs. What this API returns is not "the amount of concurrency available to the program" which is a property of the program, and thus even with just a single thread is effectively unbounded. But instead it returns "the amount of _parallelism_ available to the program", which is a resource hard-constrained by the machine's capacity (and can be further restricted by e.g. operating systems).

That's why I'd like to propose we rename this API from `available_concurrency` to `available_parallelism`. This still meets the criteria we previously established of not attempting to define what exactly we mean by "hardware", "threads", and other such words. Instead we only talk about "concurrency" as an abstract resource available to our program.

r? `@joshtriplett`
2021-10-06 12:33:17 -07:00