Commit graph

156253 commits

Author SHA1 Message Date
b-naber
3215403dde tests 2021-10-08 10:55:48 +02:00
b-naber
cbf91532a7 dont normalize return type during candidate assembly in method probing 2021-10-08 10:55:44 +02:00
Tim McNamara
6a52fb7303 Add documentation to boxed conversions
Among other changes, documents whether allocations are necessary
to complete the type conversion.

Part of #51430

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>

Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-10-08 21:40:25 +13:00
Michael Woerister
61c5a6d644 Create more accurate debuginfo for vtables.
Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.
2021-10-08 10:33:47 +02:00
Hans Kratz
7b5f1b5028 CI: Use mirror for downloads.
Crosstool-ng 1.22 used by those docker dist builds only allows one
mirror for all downloads.
2021-10-08 08:44:40 +02: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
Gary Guo
d7f8a06780 Add regression test 2021-10-08 04:00:38 +01:00
Gary Guo
5481201160 Ignore projection type when determining upvar ancestory 2021-10-08 04:00:10 +01:00
Taylor Yu
df03b083c9 move implicit Sized predicate to end of list
In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.
2021-10-07 20:24:56 -05: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
Taylor Yu
8e467421de bootstrap: add error messages re shallow history
Exit with an error if we can't find a commit hash for downloading
LLVM or rustc snapshots.
2021-10-07 18:47:43 -05:00
Taylor Yu
6ff72045de bootstrap: don't use --merges to find commits
Shallow clones can cause `git rev-list --merges` to miss merge
commits. Omit it, because the most recent bors commit is
almost always a merge commit.
2021-10-07 18:41:19 -05:00
Ibraheem Ahmed
5f7e7d2e93 revert stabilization of core::task::ready! 2021-10-07 18:44:48 -04:00
John Kugelman
a990c76d84 Optimize File::read_to_end and read_to_string
Reading a file into an empty vector or string buffer can incur
unnecessary `read` syscalls and memory re-allocations as the buffer
"warms up" and grows to its final size. This is perhaps a necessary evil
with generic readers, but files can be read in smarter by checking the
file size and reserving that much capacity.

`std::fs::read` and `read_to_string` already perform this optimization:
they open the file, reads its metadata, and call `with_capacity` with
the file size. This ensures that the buffer does not need to be resized
and an initial string of small `read` syscalls.

However, if a user opens the `File` themselves and calls
`file.read_to_end` or `file.read_to_string` they do not get this
optimization.

```rust
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
```

I searched through this project's codebase and even here are a *lot* of
examples of this. They're found all over in unit tests, which isn't a
big deal, but there are also several real instances in the compiler and
in Cargo. I've documented the ones I found in a comment here:

https://github.com/rust-lang/rust/issues/89516#issuecomment-934423999

Most telling, the `Read` trait and the `read_to_end` method both show
this exact pattern as examples of how to use readers. What this says to
me is that this shouldn't be solved by simply fixing the instances of it
in this codebase. If it's here it's certain to be prevalent in the wider
Rust ecosystem.

To that end, this commit adds specializations of `read_to_end` and
`read_to_string` directly on `File`. This way it's no longer a minor
footgun to start with an empty buffer when reading a file in.

A nice side effect of this change is that code that accesses a `File` as
a bare `Read` constraint or via a `dyn Read` trait object will benefit.
For example, this code from `compiler/rustc_serialize/src/json.rs`:

```rust
pub fn from_reader(rdr: &mut dyn Read) -> Result<Json, BuilderError> {
    let mut contents = Vec::new();
    match rdr.read_to_end(&mut contents) {
```

Related changes:

- I also added specializations to `BufReader` to delegate to
  `self.inner`'s methods. That way it can call `File`'s optimized
  implementations if the inner reader is a file.

- The private `std::io::append_to_string` function is now marked
  `unsafe`.

- `File::read_to_string` being more efficient means that the performance
  note for `io::read_to_string` can be softened. I've added @camelid's
  suggested wording from:

  https://github.com/rust-lang/rust/issues/80218#issuecomment-936806502
2021-10-07 18:42:02 -04:00
Noble-Mushtak
8fc329f5d2 Add check that region is live in sanitize_promoted 2021-10-07 18:20:23 -04:00
Noah Lev
9771803934 Update Miri 2021-10-07 13:47:00 -07:00
Camille GILLOT
a3f98a7501 Fix inherent impl overlap check. 2021-10-07 22:42:18 +02:00
Matthias Krüger
ff6601e0fc some clippy::perf fixes 2021-10-07 22:31:33 +02:00
bors
485ced56b8 Auto merge of #89617 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2021-10-07 20:26:27 +00:00
Ibraheem Ahmed
a57c18b5e1 add Poll::ready 2021-10-07 15:47:28 -04:00
asquared31415
271da7d8bc make #[target_feature] work with asm register classes 2021-10-07 15:42:18 -04:00
Eliza Weisman
0e79545c30
lol i forgot the syntax for my own crate's macros
T_____T

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 12:03:15 -07:00
Eliza Weisman
b6f09a19b2
comma-related changes
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 11:29:47 -07:00
Michael Woerister
b7cc99142a Turn tcx.vtable_allocation() into a query. 2021-10-07 20:03:00 +02:00
Eliza Weisman
e00eac8b9c
use structured fields in some existing warnings
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:48:48 -07:00
Eliza Weisman
928c787fce
make them structured while i'm here
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:46:47 -07:00
Eliza Weisman
01803025d2
demote rustc_peek traces look not user-facing
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:45:39 -07: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
Eliza Weisman
eb67bf9368
Update compiler/rustc_driver/src/lib.rs
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-10-07 09:52:51 -07:00
Eliza Weisman
e7f04857ef
rustc_driver: Enable the WARN log level by default
This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.

Fixes #76824
Closes #89623

cc @eddyb, @oli-obk
2021-10-07 09:23:42 -07:00
Cameron Steffen
848d627edc Remove unused clippy bootstrap env vars 2021-10-07 10:25:02 -05: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