Commit graph

4980 commits

Author SHA1 Message Date
bors
35aa636159 Auto merge of #83530 - Mark-Simulacrum:bootstrap-bump, r=Mark-Simulacrum
Bump bootstrap to 1.52 beta

This includes the standard bump, but also a workaround for new cargo behavior around clearing out the doc directory when the rustdoc version changes.
2021-04-04 22:45:56 +00:00
Dylan DPC
f8709ec962
Rollup merge of #83841 - Amanieu:asm_clobber_feature, r=nagisa
Allow clobbering unsupported registers in asm!

Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed.

cc #81092

r? ``@nagisa``
2021-04-05 00:24:34 +02:00
Dylan DPC
3c2e4ff525
Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Remove attribute `#[link_args]`

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

The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc.
Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-05 00:24:33 +02:00
Dylan DPC
0d12422f2d
Rollup merge of #80525 - devsnek:wasm64, r=nagisa
wasm64 support

There is still some upstream llvm work needed before this can land.
2021-04-05 00:24:23 +02:00
Gus Wynn
3965773ae7 use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
bors
c755ee4ce8 Auto merge of #82907 - petrochenkov:dercache, r=Aaron1011
resolve/expand: Cache intermediate results of `#[derive]` expansion

Expansion function for `#[derive]` (`rustc_builtin_macros::derive::Expander::expand`) may return an indeterminate result, and therefore can be called multiple times.
Previously we parsed the `#[derive(Foo, Bar)]`'s input and tried to resolve `Foo` and `Bar` on every such call.

Now we maintain a cache `Resolver::derive_data` and take all the necessary data from it if it was computed previously.
So `Foo, Bar` is now parsed at most once, and `Foo` and `Bar` are successfully resolved at most once.
2021-04-04 20:16:09 +00:00
Mark Rousskov
b3a4f91b8d Bump cfgs 2021-04-04 14:57:05 -04:00
Dylan DPC
a89eab9bca
Rollup merge of #83521 - sexxi-goose:quick-diagnostic-fix, r=nikomatsakis
2229: Fix diagnostic issue when using FakeReads in closures

This PR fixes a diagnostic issue caused by https://github.com/rust-lang/rust/pull/82536. A temporary work around was used in this merged PR which involved feature gating the addition of FakeReads introduced as a result of pattern matching in closures.

The fix involves adding an optional closure DefId to ForLet and ForMatchedPlace FakeReadCauses. This DefId will only be added if a closure pattern matches a Place starting with an Upvar.

r? ```@nikomatsakis```
2021-04-04 19:20:01 +02:00
Dylan DPC
a1c34493d4
Rollup merge of #73945 - est31:unused_externs, r=Mark-Simulacrum
Add an unstable --json=unused-externs flag to print unused externs

This adds an unstable flag to print a list of the extern names not used by cargo.

This PR will enable cargo to collect unused dependencies from all units and provide warnings.
The companion PR to cargo is: https://github.com/rust-lang/cargo/pull/8437

The goal is eventual stabilization of this flag in rustc as well as in cargo.

Discussion of this feature is mostly contained inside these threads: #57274 #72342 #72603

The feature builds upon the internal datastructures added by #72342

Externs are uniquely identified by name and the information is sufficient for cargo.
If the mode is enabled, rustc will print json messages like:

```
{"unused_extern_names":["byteorder","openssl","webpki"]}
```

For a crate that got passed byteorder, openssl and webpki dependencies but needed none of them.

### Q: Why not pass -Wunused-crate-dependencies?
A: See [ehuss's comment here](https://github.com/rust-lang/rust/issues/57274#issuecomment-624839355)
   TLDR: it's cleaner. Rust's warning system wasn't built to be filtered or edited by cargo.
   Even a basic implementation of the feature would have to change the "n warnings emitted" line that rustc prints at the end.
   Cargo ideally wants to synthesize its own warnings anyways. For example, it would be hard for rustc to emit warnings like
   "dependency foo is only used by dev targets", suggesting to make it a dev-dependency instead.

### Q: Make rustc emit used or unused externs?
A: Emitting used externs has the advantage that it simplifies cargo's collection job.
   However, emitting unused externs creates less data to be communicated between rustc and cargo.
   Often you want to paste a cargo command obtained from `cargo build -vv` for doing something
   completely unrelated. The message is emitted always, even if no warning or error is emitted.
   At that point, even this tiny difference in "noise" matters. That's why I went with emitting unused externs.

### Q: One json msg per extern or a collective json msg?
A: Same as above, the data format should be concise. Having 30 lines for the 30 crates a crate uses would be disturbing to readers.
   Also it helps the cargo implementation to know that there aren't more unused deps coming.

### Q: Why use names of externs instead of e.g. paths?
A: Names are both sufficient as well as neccessary to uniquely identify a passed `--extern` arg.
   Names are sufficient because you *must* pass a name when passing an `--extern` arg.
   Passing a path is optional on the other hand so rustc might also figure out a crate's location from the file system.
   You can also put multiple paths for the same extern name, via e.g. `--extern hello=/usr/lib/hello.rmeta --extern hello=/usr/local/lib/hello.rmeta`,
   but rustc will only ever use one of those paths.
   Also, paths don't identify a dependency uniquely as it is possible to have multiple different extern names point to the same path.
   So paths are ill-suited for identification.

### Q: What about 2015 edition crates?
A: They are fully supported.
   Even on the 2015 edition, an explicit `--extern` flag is is required to enable `extern crate foo;` to work (outside of sysroot crates, which this flag doesn't warn about anyways).
   So the lint would still fire on 2015 edition crates if you haven't included a dependency specified in Cargo.toml using `extern crate foo;` or similar.
   The lint won't fire if your sole use in the crate is through a `extern crate foo;`   statement, but that's not its job.
   For detecting unused `extern crate foo` statements, there is the `unused_extern_crates` lint
   which can be enabled by `#![warn(unused_extern_crates)]` or similar.

cc ```@jsgf``` ```@ehuss``` ```@petrochenkov``` ```@estebank```
2021-04-04 19:19:58 +02:00
Gus Caplan
da66a31572
wasm64 2021-04-04 11:29:34 -05:00
Vadim Petrochenkov
b96584485a resolve: Stable order for derive helper attributes 2021-04-04 17:51:41 +03:00
Vadim Petrochenkov
fbf1bec482 resolve/expand: Cache intermediate results of #[derive] expansion 2021-04-04 17:51:41 +03:00
bors
b1ea2618d3 Auto merge of #83839 - ldm0:deref, r=petrochenkov
Remove unneeded type resolving

small optimization.
2021-04-04 11:15:17 +00:00
Amanieu d'Antras
ddc53f809b Allow clobbering unsupported registers in asm!
Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed.
2021-04-04 10:42:32 +01:00
bors
2616ab1c57 Auto merge of #83811 - JohnTitor:rollup-hnw1xwz, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #82487 (Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`)
 - #83756 (rustdoc: Rename internal uses of `spotlight`)
 - #83780 (Document "standard" conventions for error messages)
 - #83787 (Monomorphization doc fix)
 - #83803 (add fp-armv8 for ARM_ALLOWED_FEATURES)
 - #83804 (Remove nightly features in rustc_type_ir)
 - #83810 (Fix rustc_lint_defs documentation typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-03 23:17:58 +00:00
Yuki Okushi
81f00c98a6 Trigger unused_doc_comments on macros at once 2021-04-04 05:06:51 +09:00
Vadim Petrochenkov
5839bff0ba Remove attribute #[link_args] 2021-04-03 21:25:53 +03:00
liudingming
3982ac2249 Optimize out unneeded type resolving 2021-04-04 01:40:47 +08:00
Vadim Petrochenkov
cd22425990 expand: Do not ICE when a legacy AST-based macro attribute produces and empty expression 2021-04-03 19:42:09 +03:00
liudingming
8eed8ed967 Move log's short part to first 2021-04-04 00:05:17 +08:00
Yuki Okushi
b2daca745d
Rollup merge of #83810 - benmezger:update-builtin-docs-typo, r=jonas-schievink
Fix rustc_lint_defs documentation typo

Found a typo while reading the documentation. This PR fixes it.
2021-04-04 00:19:41 +09:00
Yuki Okushi
d636b0aa6e
Rollup merge of #83804 - detrumi:build-type-ir-on-stable, r=petrochenkov
Remove nightly features in rustc_type_ir

`rustc_type_ir` will be used as a type library by Chalk, which we want to be able to build on stable, so this PR removes the current nightly features used.
2021-04-04 00:19:40 +09:00
Yuki Okushi
d0266e3c1b
Rollup merge of #83803 - surechen:add_target_feature, r=petrochenkov
add fp-armv8 for ARM_ALLOWED_FEATURES

For fixing err in https://github.com/rust-lang/stdarch/pull/1105.
2021-04-04 00:19:39 +09:00
Yuki Okushi
6a436aaabf
Rollup merge of #83787 - digama0:patch-1, r=bjorn3
Monomorphization doc fix

Only public items are monomorphization roots. This can be confirmed by noting that this program compiles:
```rust
fn foo<T>() { if true { foo::<Option<T>>() } }
fn bar() { foo::<()>() }
```
See also the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Why.20are.20non.20public.20items.20monomorphization.20roots.3F).
2021-04-04 00:19:38 +09:00
Ben Mezger
7b05cffa18 Fix rustc_lint_defs documentation typo 2021-04-03 12:00:28 -03:00
bors
97717a5618 Auto merge of #83682 - bjorn3:mmap_wrapper, r=cjgillot
Add an Mmap wrapper to rustc_data_structures

This wrapper implements StableAddress and falls back to directly reading the file on wasm32.

Taken from #83640, which I will close due to the perf regression.
2021-04-03 13:23:42 +00:00
bjorn3
bda6d1f158 Add safety comment to StableAddress impl for Mmap 2021-04-03 14:51:05 +02:00
Wilco Kusee
3ea7c90a94 Add fixme comment to revert change once const_panic is stable 2021-04-03 13:07:03 +02:00
Wilco Kusee
3cfa0a0dff Remove nightly features in rustc_type_ir 2021-04-03 10:00:09 +02:00
surechen
944b53eb75 add fp-armv8 for ARM_ALLOWED_FEATURES 2021-04-03 15:50:59 +08:00
bors
836c317426 Auto merge of #83774 - richkadel:zero-based-counters, r=tmandry
Translate counters from Rust 1-based to LLVM 0-based counter ids

A colleague contacted me and asked why Rust's counters start at 1, when
Clangs appear to start at 0. There is a reason why Rust's internal
counters start at 1 (see the docs), and I tried to keep them consistent
when codegenned to LLVM's coverage mapping format. LLVM should be
tolerant of missing counters, but as my colleague pointed out,
`llvm-cov` will silently fail to generate a coverage report for a
function based on LLVM's assumption that the counters are 0-based.

See:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L170

Apparently, if, for example, a function has no branches, it would have
exactly 1 counter. `CounterValues.size()` would be 1, and (with the
1-based index), the counter ID would be 1. This would fail the check
and abort reporting coverage for the function.

It turns out that by correcting for this during coverage map generation,
by subtracting 1 from the Rust Counter ID (both when generating the
counter increment intrinsic call, and when adding counters to the map),
some uncovered functions (including in tests) now appear covered! This
corrects the coverage for a few tests!

r? `@tmandry`
FYI: `@wesleywiser`
2021-04-03 06:27:03 +00:00
bors
cb17136405 Auto merge of #83599 - jyn514:unorderable, r=Aaron1011
Avoid sorting by DefId for `necessary_variants()`

Follow-up to https://github.com/rust-lang/rust/pull/83074. Originally I tried removing `impl Ord for DefId` but that hit *lots* of errors 😅 so I thought I would start with easy things.

I am not sure whether this could actually cause invalid query results, but this is used from `MarkSymbolVisitor::visit_arm` so it's at least feasible.

r? `@Aaron1011`
2021-04-03 04:11:35 +00:00
Rich Kadel
7ceff6835a Translate counters from Rust 1-based to LLVM 0-based counter ids
A colleague contacted me and asked why Rust's counters start at 1, when
Clangs appear to start at 0. There is a reason why Rust's internal
counters start at 1 (see the docs), and I tried to keep them consistent
when codegenned to LLVM's coverage mapping format. LLVM should be
tolerant of missing counters, but as my colleague pointed out,
`llvm-cov` will silently fail to generate a coverage report for a
function based on LLVM's assumption that the counters are 0-based.

See:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L170

Apparently, if, for example, a function has no branches, it would have
exactly 1 counter. `CounterValues.size()` would be 1, and (with the
1-based index), the counter ID would be 1. This would fail the check
and abort reporting coverage for the function.

It turns out that by correcting for this during coverage map generation,
by subtracting 1 from the Rust Counter ID (both when generating the
counter increment intrinsic call, and when adding counters to the map),
some uncovered functions (including in tests) now appear covered! This
corrects the coverage for a few tests!
2021-04-02 17:16:36 -07:00
bors
9b6c9b638e Auto merge of #81866 - nagisa:nagisa/sanitizer-support-target-prop, r=tmiasko
Maintain supported sanitizers as a target property

In an effort to remove a hard-coded allow-list for target-sanitizer support correspondence, this PR moves the configuration to the target options.

Perhaps the one notable change made in this PR is this doc-comment:

```rust
    /// The sanitizers supported by this target
    ///
    /// Note that the support here is at a codegen level. If the machine code with sanitizer
    /// enabled can generated on this target, but the necessary supporting libraries are not
    /// distributed with the target, the sanitizer should still appear in this list for the target.
```

Previously the target would typically be added to the allow-list at the same time as the supporting runtime libraries are shipped for the target. However whether we ship the runtime libraries or not needn't be baked into the compiler; and if we don't users will receive a significantly more directed error about library not being found.

Fixes #81802
2021-04-02 23:33:01 +00:00
Roxane
0a97eee8df Reduce size of statements 2021-04-02 19:11:50 -04:00
Roxane
2fb1fb7634 Fix diagnostic issue when using FakeReads in closures 2021-04-02 19:11:50 -04:00
Simonas Kazlauskas
41875c82c7 rm target specific logic in link_sanitizer_runtime 2021-04-03 00:37:49 +03:00
Simonas Kazlauskas
a3c0f0a3df (De-)serialize the supported_sanitizers 2021-04-03 00:37:49 +03:00
Simonas Kazlauskas
16c1d0ae06 Maintain supported sanitizers as a target property
This commit adds an additional target property – `supported_sanitizers`,
and replaces the hardcoded allowlists in argument parsing to use this
new property.

Fixes #81802
2021-04-03 00:37:49 +03:00
Simonas Kazlauskas
64af7eae1e Move SanitizerSet to rustc_target 2021-04-03 00:37:49 +03:00
Simonas Kazlauskas
2f000a78bf Manually set dso_local when its valid to do so
This should have no real effect in most cases, as e.g. `hidden`
visibility already implies `dso_local` (or at least LLVM IR does not
preserve the `dso_local` setting if the item is already `hidden`), but
it should fix `-Crelocation-model=static` and improve codegen in
executables.

Note that this PR does not exhaustively port the logic in [clang]. Only
the obviously correct portion and what is necessary to fix a regression
from LLVM 12 that relates to `-Crelocation_model=static`.

Fixes #83335

[clang]: 3001d080c8/clang/lib/CodeGen/CodeGenModule.cpp (L945-L1039)
2021-04-03 00:00:29 +03:00
bors
138fd56cf9 Auto merge of #83790 - Dylan-DPC:rollup-p6ep8jo, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #83065 (Rework `std::sys::windows::alloc`)
 - #83478 (rustdoc: Add unstable option to only emit shared/crate-specific files)
 - #83629 (Fix double-drop in `Vec::from_iter(vec.into_iter())` specialization when items drop during panic)
 - #83673 (give full path of constraint in suggest_constraining_type_param)
 - #83755 (Simplify coverage tests)
 - #83757 (2229: Support migration via rustfix)
 - #83771 (Fix stack overflow detection on FreeBSD 11.1+)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-02 20:06:11 +00:00
Dylan DPC
eed73c6e4d
Rollup merge of #83757 - sexxi-goose:migrations_out, r=nikomatsakis
2229: Support migration via rustfix

- Adds support of machine applicable suggestions for `disjoint_capture_drop_reorder`.
- Doesn't migrate in the case of pre-existing bugs in user code

r? ``@nikomatsakis``
2021-04-02 19:57:34 +02:00
Dylan DPC
6cb74ad99f
Rollup merge of #83673 - hi-rustin:rustin-patch-suggestion, r=estebank
give full path of constraint in suggest_constraining_type_param

close https://github.com/rust-lang/rust/issues/83513
2021-04-02 19:57:32 +02:00
LeSeulArtichaut
fb7cf0982b Don't suggest dereferencing an else if expression 2021-04-02 19:50:06 +02:00
bors
23fa536050 Auto merge of #76881 - hameerabbasi:issue-53325, r=oli-obk
Add allocation information to undefined behaviour errors.

So far I'm looking on information on whether the error messages are suitable.

Fixes #53325.
2021-04-02 17:38:57 +00:00
Mario Carneiro
99f3e889b1
fix 2021-04-02 10:21:23 -07:00
Mario Carneiro
e01c3b8211
clarify wording 2021-04-02 09:55:23 -07:00
Mario Carneiro
3166e0857d
Monomorphization doc fix
Only public items are monomorphization roots. This can be confirmed by noting that this program compiles:
```rust
fn foo<T>() { if true { foo::<Option<T>>() } }
fn bar() { foo::<()>() }
```
2021-04-02 09:33:34 -07:00
bors
36bcf40697 Auto merge of #83468 - hi-rustin:rustin-patch-lint, r=nikomatsakis
add OR_PATTERNS_BACK_COMPAT lint

close https://github.com/rust-lang/rust/issues/83318
2021-04-02 15:14:48 +00:00
bors
a207871d5c Auto merge of #83781 - JohnTitor:rollup-1vm3dxo, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #83535 (Break when there is a mismatch in the type count)
 - #83721 (Add a button to copy the "use statement")
 - #83740 (Fix comment typo in once.rs)
 - #83745 (Add my new email address to .mailmap)
 - #83754 (Add test to ensure search tabs behaviour)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-02 12:51:41 +00:00
Yuki Okushi
03ba8ab606
Rollup merge of #83535 - MidasLamb:mir-type-count-mismatch, r=nikomatsakis
Break when there is a mismatch in the type count

When other errors are generated, there can be a mismatch between the
amount of input types in MIR, and the amount in the function itself.
Break from the comparative loop if this is the case to prevent
out-of-bounds.
Fixes #83499
2021-04-02 21:28:20 +09:00
mibac138
e603f994b1 Address review comments
Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
2021-04-02 12:42:46 +02:00
mibac138
98ad0af60b Properly suggest deref in else block 2021-04-02 12:42:44 +02:00
bors
0978a9eb99 Auto merge of #83207 - oli-obk:valtree2, r=lcnr
normalize mir::Constant differently from ty::Const in preparation for valtrees

Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation.

In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system.

cc `@rust-lang/wg-const-eval`

r? `@lcnr`
2021-04-02 10:28:12 +00:00
bors
5662d9343f Auto merge of #80965 - camelid:rename-doc-spotlight, r=jyn514
Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`

Fixes #80936.

"spotlight" is not a very specific or self-explaining name.
Additionally, the dialog that it triggers is called "Notable traits".
So, "notable trait" is a better name.

* Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`
* Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]`
* Update documentation
* Improve documentation

r? `@Manishearth`
2021-04-02 07:04:58 +00:00
bors
4fa76a4a77 Auto merge of #80828 - SNCPlay42:opaque-projections, r=estebank
Fix expected/found order on impl trait projection mismatch error

fixes #68561

This PR adds a new `ObligationCauseCode` used when checking the concrete type of an impl trait satisfies its bounds, and checks for that cause code in the existing test to see if a projection's normalized type should be the "expected" or "found" type.

The second commit adds a `peel_derives` to that test, which appears to be necessary in some cases (see projection-mismatch-in-impl-where-clause.rs, which would still give expected/found in the wrong order otherwise). This caused some other changes in diagnostics not involving impl trait, but they look correct to me.
2021-04-02 03:39:32 +00:00
Kevin Jiang
e433f55852 Fixed diagnostic and added test for issue 81508 2021-04-01 22:55:47 -04:00
Aman Arora
1b9620d75f Make the diagnostic message more readable 2021-04-01 21:33:11 -04:00
Aman Arora
a721957a3d Don't introduce a block if a block exists 2021-04-01 21:08:04 -04:00
bors
d1065e6cef Auto merge of #83663 - AngelicosPhosphoros:simplify_binary_and_to_get_better_asm, r=nagisa
Simplify logical operations CFG

This is basically same commit as e38e954a0d which was reverted later in 676953fde9
In both cases, this changes weren't benchmarked.
e38e954a0d leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/62993)
676953fde9 leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/83623)
2021-04-02 00:48:31 +00:00
hi-rustin
aa987c2f57 address comments 2021-04-02 08:08:02 +08:00
Aman Arora
18af989c06 Update lint message 2021-04-01 16:49:31 -04:00
bors
d474075a8f Auto merge of #82780 - cjgillot:dep-stream, r=michaelwoerister
Stream the dep-graph to a file instead of storing it in-memory.

This is a reimplementation of #60035.

Instead of storing the dep-graph in-memory, the nodes are encoded as they come
into the a temporary file as they come. At the end of a successful the compilation,
this file is renamed to be the persistent dep-graph, to be decoded during the next
compilation session.

This two-files scheme avoids overwriting the dep-graph on unsuccessful or crashing compilations.

The structure of the file is modified to be the sequence of `(DepNode, Fingerprint, EdgesVec)`.
The deserialization is responsible for going to the more compressed representation.
The `node_count` and `edge_count` are stored in the last 16 bytes of the file,
in order to accurately reserve capacity for the vectors.

At the end of the compilation, the encoder is flushed and dropped.
The graph is not usable after this point: any creation of a node will ICE.

I had to retrofit the debugging options, which is not really pretty.
2021-04-01 16:29:33 +00:00
AngelicosPhosphoros
4464cc2256 Simplify logical operations CFG
This is basically same commit as e38e954a0d which was reverted later in 676953fde9
In both cases, this changes weren't benchmarked.
e38e954a0d leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/62993)
676953fde9 leads to missed optimization described in [this issue](https://github.com/rust-lang/rust/issues/83623)

Also it changes some src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump* files automatically.
2021-04-01 18:34:11 +03:00
hi-rustin
2c66e15468 add OR_PATTERNS_BACK_COMPAT lint
test: add more cases

test: add comments

refine msg
2021-04-01 23:14:14 +08:00
Oli Scherer
c6676db7ae Some more fine-grained forced inlining 2021-04-01 10:40:50 +00:00
Oli Scherer
d81f5ab100 Inline some functions that suddenly show up more in traces 2021-04-01 09:22:12 +00:00
bors
49e1ec0995 Auto merge of #83736 - JohnTitor:fix-unsafe_block_in_unsafe_fn-stabilized-version, r=jyn514
Fix the `unsafe_block_in_unsafe_fn`s stabilized version

Fixes #83735
2021-04-01 05:34:54 +00:00
Yuki Okushi
fe9c4fbb9e Fix the unsafe_block_in_unsafe_fns stabilized version 2021-04-01 10:56:51 +09:00
Yuki Okushi
b5782bad74 Catch a bad placeholder type error for statics in externs 2021-04-01 10:45:42 +09:00
Dylan DPC
1ef52ac5f5
Rollup merge of #83711 - JohnTitor:more-friendly-unknown-target-error, r=davidtwco
Clarify `--print target-list` is a rustc's option

Fixes #68238
2021-04-01 02:41:47 +02:00
b-naber
3194b26ab0 prevent very long compilation runtimes in LateBoundRegionNameCollector 2021-03-31 23:28:01 +02:00
JohnTitor
82c6709d6f Clarify --print target-list is a rustc's option 2021-04-01 01:59:50 +09:00
Camille GILLOT
f3dde45d2a Enable debugging the dep-graph without debug-assertions.
It may also be useful in these cases,
and some CI configurations test without debug assertions.
2021-03-31 17:12:06 +02:00
Jack Huey
7108918db6 Cleanups and comments 2021-03-31 10:16:37 -04:00
Jack Huey
0c98dc66fd Fix tests and AstConv -> dyn AstConv 2021-03-31 10:16:37 -04:00
Jack Huey
4ff65ec782 Fmt and test revert 2021-03-31 10:16:37 -04:00
Jack Huey
8ad7e5685e Fix new problem from rebase and a little cleanup 2021-03-31 10:16:37 -04:00
Jack Huey
6d5efa9f04 Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
Jack Huey
666859a6f8 Make late and late_anon regions track the bound var position 2021-03-31 10:15:56 -04:00
Jack Huey
84f82d348c Revert explicit lifetimes 2021-03-31 10:15:56 -04:00
Jack Huey
30187c81f6 Track bound vars 2021-03-31 10:15:27 -04:00
Jack Huey
62a49c3bb8 Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
Jack Huey
74851f4cf3 count bound vars 2021-03-31 10:11:47 -04:00
Jack Huey
97a22a4f9c Add u32 for bound variables to Binder 2021-03-31 10:05:32 -04:00
Jack Huey
4955d755d3 Some rebinds and dummys 2021-03-31 10:05:32 -04:00
Oli Scherer
d139968d19 bail out early when substituting mir constants that don't need substituting 2021-03-31 10:40:45 +00:00
Oli Scherer
4e8edfb5c2 Forward some layouts to prevent recomputation 2021-03-31 10:40:45 +00:00
Oli Scherer
dbacfbc368 Add a new normalization query just for mir constants 2021-03-31 10:40:42 +00:00
Oli Scherer
c7c39ce6d0 We should never see unevaluated type-level constants after monomorphization unless errors occurred 2021-03-31 09:13:45 +00:00
Oli Scherer
1d56b8a2bc Make unevaluated DefId rendering deterministic 2021-03-31 09:13:45 +00:00
Aman Arora
e78fac5601 Handle the case of partially captured drop type 2021-03-31 04:40:31 -04:00
bors
a5029ac0ab Auto merge of #83684 - cjgillot:csp, r=petrochenkov
Remove hir::CrateItem.

The crate span is exactly the crate module's inner span. There is no need to store it twice.
2021-03-31 08:34:40 +00:00
Hameer Abbasi
c3ec0add8b Add allocation information to undefined behaviour errors. 2021-03-31 07:21:08 +00:00
bjorn3
5773e51678 Inline a few methods 2021-03-31 09:19:29 +02:00
bors
2a32abbcde Auto merge of #83681 - jyn514:blanket-impls-tweaks, r=Aaron1011
rustdoc: Only look at blanket impls in `get_blanket_impls`

The idea here is that all the work in 16156fb278/compiler/rustc_middle/src/ty/trait_def.rs (L172-L186) doesn't matter for `get_blanket_impls` - Rustdoc will already pick up on those blocks when it documents the item.
2021-03-31 05:47:22 +00:00
bors
6ff482bde5 Auto merge of #83666 - Amanieu:instrprof-order, r=tmandry
Run LLVM coverage instrumentation passes before optimization passes

This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.

Fixes #83429

cc `@richkadel`

r? `@tmandry`
2021-03-31 03:20:33 +00:00
hi-rustin
8f77356249 give full path of constraint in suggest_constraining_type_param
revert file

bless with nll mode
2021-03-31 09:47:31 +08:00
Dylan DPC
7d888d100f
Rollup merge of #83654 - JohnTitor:issue-83606, r=estebank
Do not emit a suggestion that causes the E0632 error

Fixes #83606
2021-03-31 01:14:46 +02:00
Camille GILLOT
9d8f833e05 Remove hir::CrateItem. 2021-03-30 20:31:06 +02:00
bors
926ec1cb8b Auto merge of #83639 - osa1:issue83638, r=estebank
Replace tabs in err messages before rendering

This is done in other call sites, but was missing in one place.

Fixes #83638
2021-03-30 17:07:19 +00:00
bjorn3
8331dbe6d0 Add an Mmap wrapper to rustc_data_structures
This wrapper implements StableAddress and falls back to directly reading
the file on wasm32
2021-03-30 18:57:03 +02:00
Joshua Nelson
6f06b761b9 Only look at blanket impls in get_blanket_impls 2021-03-30 12:28:33 -04:00
Camille GILLOT
8ee9322c10 Also profile finishing the encoding. 2021-03-30 18:10:08 +02:00
Camille GILLOT
df24315ddf Adjust profiling. 2021-03-30 18:10:08 +02:00
Camille GILLOT
fe89f3236c Address review. 2021-03-30 18:10:08 +02:00
Camille GILLOT
65a8681a17 Add documentation. 2021-03-30 18:10:07 +02:00
Camille GILLOT
c5c935af92 Simplify tracking the encoder state. 2021-03-30 18:10:07 +02:00
Camille GILLOT
e1c99e5fcc Remove the parallel version. 2021-03-30 18:10:06 +02:00
Camille GILLOT
8208872fa2 Fix parallel compiler. 2021-03-30 18:10:06 +02:00
Camille GILLOT
cfe786e5e0 Fix tests.
Avoid invoking queries inside `check_paths`, since we are holding a lock
to the reconstructed graph.
2021-03-30 18:10:06 +02:00
Camille GILLOT
39b306a53d Do not allocate in decoder. 2021-03-30 18:10:05 +02:00
Camille GILLOT
6bfaf3a9cb Stream the dep-graph to a file. 2021-03-30 18:09:59 +02:00
Dylan DPC
5b467787b6
Rollup merge of #83667 - estebank:cool-bears-hot-tip, r=lcnr
Suggest box/pin/arc ing receiver on method calls

_Extracted from https://fasterthanli.me/articles/pin-and-suffering_
2021-03-30 11:34:30 +02:00
bors
a0e229abad Auto merge of #83649 - bjorn3:dedup_providers, r=petrochenkov
Don't duplicate the extern providers once for each crate

This should give a small perf improvement for small crates by avoiding a memcpy of a pretty big struct for each loaded crate. In addition would be useful for replacing the sequential `CrateNum` everywhere with the hash based `StableCrateId` introduced in #81635, which would allow avoiding remapping of `CrateNum`'s when loading crate metadata. While this PR is not strictly needed for that, it is necessary to prevent a performance loss due to it.

I think this duplication was done in https://github.com/rust-lang/rust/pull/40008 (which introduced the query system) to make it possible to compile multiple crates in a single session in the future. I think this is unlikely to be implemented any time soon. In addition this PR can easily be reverted if necessary to implement this.
2021-03-30 06:22:29 +00:00
Amanieu d'Antras
cad9b6b695 Apply review feedback 2021-03-30 07:03:41 +01:00
Esteban Küber
0195f8d375 Hide unnecessary reference to trait
When the problem for a method not being found in its receiver is due to
arbitrary self-types, we don't want to mention importing or implementing
the trait, instead we suggest wrapping.
2021-03-29 20:39:42 -07:00
Esteban Küber
6f2d8a018e Suggest box/pin/arc ing receiver on method calls 2021-03-29 18:14:44 -07:00
Amanieu d'Antras
26d260bfa4 Run LLVM coverage instrumentation passes before optimization passes
This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.
2021-03-30 02:10:28 +01:00
Aman Arora
f2e52fffc2 2229: Produce a rustfix migration suggestion 2021-03-29 19:52:59 -04:00
Dylan DPC
fca8e7dd88
Rollup merge of #83643 - JohnTitor:is-freeze-no-longer-uses-span, r=RalfJung
Remove a FIXME resolved by #73578

r? ``@RalfJung``
2021-03-30 00:32:24 +02:00
bors
48691ea6e6 Auto merge of #83185 - jyn514:remove-dead-code, r=oli-obk
Remove (lots of) dead code

Builds on
- [ ] https://github.com/rust-lang/rust/pull/83161
- [x] https://github.com/rust-lang/rust/pull/83230
- [x] https://github.com/rust-lang/rust/pull/83197.

Found with https://github.com/est31/warnalyzer.
See https://github.com/rust-lang/rust/pull/77739 for a similar change in the past.

Dubious changes:
- Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future?

TODO:
- [ ] check if any of the comments on the deleted code should be kept.
- [x] update the compiler documentation; right now it fails to build
- [x] finish moving `cfg(test)` changes into https://github.com/rust-lang/rust/pull/83197

cc `@est31`
2021-03-29 19:44:27 +00:00
JohnTitor
7e6fd40614 Do not emit a suggestion that causes the E0632 error 2021-03-30 03:00:25 +09:00
Joshua Nelson
526bb10701 Revert changes to sync data structures
There isn't currently a good reviewer for these, and I don't want to
remove things that will just be added again. I plan to make a separate
PR for these changes so the rest of the cleanup can land.
2021-03-29 13:50:40 -04:00
bjorn3
cd7a011f37 Don't duplicate the extern providers once for each crate 2021-03-29 18:03:07 +02:00
JohnTitor
48f9f0864b Remove a FIXME resolved by #73578 2021-03-29 21:41:50 +09:00
Oli Scherer
5582b19559 Only emit a discrimiant tag for enums 2021-03-29 12:30:55 +00:00
Oli Scherer
c0e1191807 Don't build a ty::Const just to take it apart again 2021-03-29 12:30:55 +00:00
Oli Scherer
5b6ddd5026 Convert a closure into a method 2021-03-29 12:30:55 +00:00
Ömer Sinan Ağacan
8d7432af7b Replace tabs in err messages before rendering
This is done in other call sites, but was missing in one place.

Fixes #83638
2021-03-29 13:38:36 +03:00
bjorn3
5444b46234 Merge commit '0969bc6dde001e01e7e1f58c8ccd7750f8a49ae1' into sync_cg_clif-2021-03-29 2021-03-29 10:45:09 +02:00
JohnTitor
960b6992d6 Do not emit the advanced diagnostics on macros 2021-03-29 17:12:03 +09:00
bors
cc4103089f Auto merge of #83605 - RalfJung:unaligned, r=petrochenkov
unaligned_references: align(N) fields in packed(N) structs are fine

This removes some false positives from the unaligned_references lint: in a `repr(packed(2))` struct, fields of alignment 2 (and less) are guaranteed to be properly aligned, so we do not have to consider them "disaligned".
2021-03-29 00:17:23 +00:00
Vadim Petrochenkov
cc5392e76b linker: Use data execution prevention options by default when linker supports them 2021-03-28 23:44:40 +03:00
Ralf Jung
ee1caae33c unaligned_references: align(N) fields in packed(N) structs are fine 2021-03-28 12:54:19 +02:00
bors
505ed7fb1b Auto merge of #83593 - petrochenkov:nounwrap, r=nagisa
rustc_target: Avoid unwraps when adding linker flags

These `unwrap`s assume that some linker flags were already added by `*_base::opts()` methods, but that's doesn't necessarily remain the case when we are reducing the number of flags hardcoded in targets, as https://github.com/rust-lang/rust/pull/83587 shows.

r? `@nagisa`
2021-03-28 08:53:51 +00:00
Joshua Nelson
a0957c9d26 Avoid sorting by DefId for necessary_variants() 2021-03-28 01:13:16 -04:00
Joshua Nelson
f3523544f1 Address more review comments
- Add back various diagnostic methods on `Session`.

  It seems unfortunate to duplicate these in so many places, but in the
  meantime, making the API inconsistent between `Session` and `Diagnostic`
  also seems unfortunate.

- Add back TyCtxtAt methods

  These will hopefully be used in the near future.

- Add back `with_const`, it would need to be added soon after anyway.
- Add back `split()` and `get_mut()`, they're useful.
2021-03-27 22:19:32 -04:00
Joshua Nelson
230e396a76 Fix compiler docs 2021-03-27 22:16:34 -04:00
Joshua Nelson
de0fda9558 Address review comments
- Add back `HirIdVec`, with a comment that it will soon be used.
- Add back `*_region` functions, with a comment they may soon be used.
- Remove `-Z borrowck_stats` completely. It didn't do anything.
- Remove `make_nop` completely.
- Add back `current_loc`, which is used by an out-of-tree tool.
- Fix style nits
- Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
2021-03-27 22:16:34 -04:00
Joshua Nelson
441dc3640a Remove (lots of) dead code
Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.
2021-03-27 22:16:33 -04:00
Joshua Nelson
785aeac521 Remove unused DiagnosticBuilder::sub function
`Diagnostic::sub` is only ever used directly; it doesn't need to be
included in the builder.
2021-03-27 22:16:33 -04:00
bors
3bfc85149e Auto merge of #83587 - petrochenkov:asneeded, r=nagisa
linker: Use `--as-needed` by default when linker supports it

Do it in a centralized way in `link.rs` instead of individual target specs.
Majority of relevant target specs were already passing it.
2021-03-28 01:00:25 +00:00
Vadim Petrochenkov
049a49b911 rustc_target: Avoid unwraps when adding linker flags 2021-03-28 02:28:48 +03:00
Vadim Petrochenkov
6615ee89be linker: Use --as-needed by default when linker supports it 2021-03-28 01:49:15 +03:00
bors
8cd7d86ce2 Auto merge of #83103 - petrochenkov:unilex, r=Aaron1011
resolve: Partially unify early and late scope-relative identifier resolution

Reuse `early_resolve_ident_in_lexical_scope` instead of a chunk of code in `resolve_ident_in_lexical_scope` doing the same job.

`early_resolve_ident_in_lexical_scope`/`visit_scopes` had to be slightly extended to be able to 1) start from a specific module instead of the current parent scope and 2) report one deprecation lint.
`early_resolve_ident_in_lexical_scope` still doesn't support walking through "ribs", that part is left in `resolve_ident_in_lexical_scope` (moreover, I'm pretty sure it's buggy, but that's a separate issue, cc https://github.com/rust-lang/rust/issues/52389 at least).
2021-03-27 22:19:17 +00:00
Vadim Petrochenkov
ee0357af3b resolve: Partially unify early and late scope-relative ident resolution 2021-03-27 23:38:17 +03:00
Dylan DPC
1115accccc
Rollup merge of #83548 - Aaron1011:capture-none-delims, r=petrochenkov
Always preserve `None`-delimited groups in a captured `TokenStream`

Previously, we would silently remove any `None`-delimiters when
capturing a `TokenStream`, 'flattenting' them to their inner tokens.
This was not normally visible, since we usually have
`TokenKind::Interpolated` (which gets converted to a `None`-delimited
group during macro invocation) instead of an actual `None`-delimited
group.

However, there are a couple of cases where this becomes visible to
proc-macros:
1. A cross-crate `macro_rules!` macro has a `None`-delimited group
   stored in its body (as a result of being produced by another
   `macro_rules!` macro). The cross-crate `macro_rules!` invocation
   can then expand to an attribute macro invocation, which needs
   to be able to see the `None`-delimited group.
2. A proc-macro can invoke an attribute proc-macro with its re-collected
   input. If there are any nonterminals present in the input, they will
   get re-collected to `None`-delimited groups, which will then get
   captured as part of the attribute macro invocation.

Both of these cases are incredibly obscure, so there hopefully won't be
any breakage. This change will allow more agressive 'flattenting' of
nonterminals in #82608 without losing `None`-delimited groups.
2021-03-27 20:37:12 +01:00
Dylan DPC
b2e254318d
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27 20:37:07 +01:00