Commit Graph

12721 Commits

Author SHA1 Message Date
bors
d8e59edbfa Auto merge of #96359 - SparrowLii:drop_kind, r=oli-obk
make `classify_drop_access_kind` iterate

This PR:
1. fixes the FIXME of `classify_drop_access_kind` func in the borrowck part. The process of obtaining `StorageDeadOrDrop` has been changed from recursive to iterative.
2. gets `place_ty` in each iteration, avoid repeatedly getting the `ty` of the same place (O(n^2) => O(n))
2022-04-24 12:58:16 +00:00
SparrowLii
a34e1b58cb make classify_drop_access_kind iterate 2022-04-24 17:27:05 +08:00
Jeremy Fitzhardinge
9102edf208 Add support for nounused --extern flag
This adds `nounused` to the set of extern flags:
`--extern nounused:core=/path/to/core/libcore.rlib`.

The effect of this flag is to suppress `unused-crate-dependencies`
warnings relating to the crate.
2022-04-23 23:31:54 -07:00
bors
b21759f550 Auto merge of #96281 - SparrowLii:const_prop, r=wesleywiser
Optimize `const_prop` mir-opt by accessing `local_decls` through `ecx`

From the FIXME in the impl of `ConstPropagator`. Accessing `local_decls` and `scource_scopes` from `ecx` can reduce `clone` calls and save compile time.
Besides, according to #96213 , the FIXME about writing `layouts` to `ecx` in advance can also be removed.
2022-04-24 01:09:11 +00:00
bors
143eaa8d44 Auto merge of #93970 - cjgillot:novis, r=petrochenkov
Remove visibility information from HIR

The resolver exports all the necessary visibility information through the `tcx.visibility` query.
This PR stops having a dedicated visibility field in HIR, in order to use this query.
We keep a `vis_span` field for diagnostic purposes.
2022-04-23 22:25:51 +00:00
Camille GILLOT
c3276c6691 Hash visibilities in crate_hash. 2022-04-23 23:03:18 +02:00
Camille GILLOT
9861bc8d52 Compute has_pub_restricted in the resolver. 2022-04-23 23:03:18 +02:00
Camille GILLOT
423a712a16 Fix lints. 2022-04-23 23:01:19 +02:00
bors
de1026a67b Auto merge of #96326 - JakobDegen:relax-operand, r=oli-obk
Relax restrictions for copy operands

This was [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Removing.20requirement.20that.20.60Copy.60.20operands.20have.20.60Copy.60.20types/near/279102313). Details about motivation and such can be found there

r? `@oli-obk`
2022-04-23 19:32:05 +00:00
bors
c212fc4aa7 Auto merge of #96323 - bjorn3:sync_cg_clif-2022-04-22, r=bjorn3
Sync rustc_codegen_cranelift

Mostly fixing bugs this time, but also a Cranelift update.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-04-23 10:37:35 +00:00
Camille GILLOT
4bbe078d92 Drop vis in Item. 2022-04-23 09:59:24 +02:00
Camille GILLOT
a6e3124d2c Drop vis in ImplItem. 2022-04-23 09:57:00 +02:00
Camille GILLOT
2827007d32 Drop vis from ForeignItem. 2022-04-23 09:56:37 +02:00
Camille GILLOT
a62680d108 Drop vis in FieldDef. 2022-04-23 09:56:15 +02:00
Camille GILLOT
4e8046f67a Stop pretty-printing HIR visibility. 2022-04-23 09:55:25 +02:00
Camille GILLOT
10d10efb21 Stop visiting visibility. 2022-04-23 09:53:45 +02:00
bors
09064a21b0 Auto merge of #96316 - michaelwoerister:debuginfo-fix-unit-msvc, r=wesleywiser
debuginfo: Emit ZST struct debuginfo for unit type when CPP-like debuginfo is enabled

As already discovered in 24a728a8eb, PDB does not play well with custom basic types. This PR extends to the fix to `()`: Instead of a custom basic type, we treat it like an empty tuple (i.e. it is described as a struct which happens to have no fields).

Before this change anything with a `()` in it would cause trouble, which is especially bad for `*const ()` and `*mut ()` which are often used for opaque pointers. E.g. the test case added in this PR would look like:
```
0:000>  dx _ref
Error: Unable to bind name '_ref'
0:000>  dx _ptr
Error: Unable to bind name '_ptr'
0:000>  dx _local
Error: Unable to bind name '_local'
0:000>  dx _field,d
_field,d         [Type: unit_type::_TypeContainingUnitField]
    [+0x008] _a               : 123 [Type: unsigned int]
    [+0x000] _unit            : Unexpected failure to dereference object
    [+0x000] _b               : 456 [Type: unsigned __int64]
0:000>  dx ((__int64 *)_ptr),x
Error: Unable to bind name '_ptr'
```

With the PR it produces the expected output:
```
0:000>  dx _ref
_ref             : 0x7ff6f2012230 : () [Type: tuple$<> *]
0:000>  dx _ptr
_ptr             : 0x7e8ddffc20 : () [Type: tuple$<> *]
0:000>  dx _local
_local           : () [Type: tuple$<>]
0:000>  dx _field,d
_field,d         [Type: unit_type::_TypeContainingUnitField]
    [+0x008] _a               : 123 [Type: unsigned int]
    [+0x000] _unit            : () [Type: tuple$<>]
    [+0x000] _b               : 456 [Type: unsigned __int64]
0:000>  dx ((__int64 *)_ptr),x
((__int64 *)_ptr),x : 0x7e8ddffc20 : 0x1122334455667788 [Type: __int64 *]
```

r? `@wesleywiser`
2022-04-23 07:12:52 +00:00
bors
c2b4c2dffa Auto merge of #95739 - lqd:proc-macro-expansions, r=wesleywiser
self-profiler: record spans for proc-macro expansions

This PR is a follow-up to #95473, using the arg recorder feature from #95689:
- it adds support code to easily record spans in the event's arguments, when using `generic_activity_with_arg_recorder`.
- uses that to record the spans where proc-macro expansions happen in addition to their name.

As for the other 2 PRs, the goal here is to provide visibility into proc-macro expansion performance, so that users can diagnose which uses of proc-macros in their code could be causing compile time issues.

Some areas where I'd love feedback:
- [x] the API and names: the `SpannedEventArgRecorder` trait and its method, much like #95689 had the same question about the `EventArgRecorder` naming
- [x] we don't currently have a way to record the names of the event arguments, so should `record_arg_spanned` record the span as "location: {}" or similar ?
2022-04-22 22:12:32 +00:00
Jakob Degen
ae7d6facda Relax restrictions for copy operands 2022-04-22 16:45:15 -04:00
bjorn3
b70b01b112 Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_clif-2022-04-22 2022-04-22 21:11:38 +02:00
Matthias Krüger
eeed267215
Rollup merge of #96315 - SparrowLii:graph_lt, r=petrochenkov
Make the lifetime accurate which is used in the region constraints part

This PR fixes the FIXME about lifetime using in the region constraints part.
We cannot write `<'graph, 'tcx, D>` because the definition of `Successors<'0, '1, D>` requires `'1 : '0`.
We cannot add bound to `'graph` either because `'graph` is required to be an arbitrary value in the definition of `WithSuccessors`
So the most accurate way is to use `<'s, 'tcx, D>`.
cc `@Aaron1011` who added this FIXME in #85343
2022-04-22 18:56:26 +02:00
Matthias Krüger
b100c02fae
Rollup merge of #96273 - TaKO8Ki:make-E0117-error-clear, r=davidtwco
Make `E0117` error clear

closes #96227
2022-04-22 18:56:25 +02:00
Rémy Rakic
c525396058 start tracking proc-macros expansion spans in the self-profiler 2022-04-22 18:35:31 +02:00
Rémy Rakic
215b377cc3 extend EventArgRecorder into span-aware SpannedEventArgRecorder
The self-profiler's `EventArgRecorder` is general-purpose in its ability to record Strings (and `rustc_span` depends on the crate its defined in, `rustc_data_structure`).

Some generic activities could use recording locations where they happen in the user's code: to allow e.g. to track macro expansions and diagnose performance issues there.

This adds a `SpannedEventArgRecorder` that can record an argument given as a span, rather than a String, since turning spans into Strings can be tricky if you're not happy with its default Debug output. This way the recorder can have a `record_arg_spanned` method which will do that.
2022-04-22 18:06:21 +02:00
bors
41ef767806 Auto merge of #96226 - xldenis:thir-clone, r=oli-obk
Make all thir types implement clone

This PR adds `Clone` impl to all of the `Thir<'tcx>` types.

I would like to be able to clone a `Thir` body so that I can make a copy in my rustc driver without breaking further compilation. Without this my driver is forced to run in the `after_expansion` callback and thus doesn't benefit from running all the safety checks that `rustc` usually does, instead i need to do them all myself.
2022-04-22 13:56:10 +00:00
Michael Woerister
8b230086fa debuginfo: Emit ZST struct debuginfo for unit type when CPP-like debuginfo is enabled (instead of custom basic type). 2022-04-22 14:59:35 +02:00
SparrowLii
343523cbf1 Make the lifetime accurate which is used in the region constraints part 2022-04-22 20:05:39 +08:00
bors
a8272f23cc Auto merge of #96197 - erikdesjardins:scalarpairenum, r=oli-obk
Mark payload fields of ScalarPair enums as Scalar::Union when they're not always initialized

Fixes #96158

r? `@RalfJung`
2022-04-22 10:50:23 +00:00
Takayuki Maeda
f5a8ee4dd8 remove an error for type params 2022-04-22 11:25:42 +09:00
SparrowLii
db23e773e3 use references to avoid function calls 2022-04-22 08:42:38 +08:00
bors
0b3404b01b Auto merge of #96261 - petrochenkov:doclink7, r=GuillaumeGomez
rustdoc: Resolve some more doc links early

Trying another subset of https://github.com/rust-lang/rust/pull/94857 that is not too expensive.
2022-04-22 00:05:17 +00:00
Dylan DPC
5ebb8b06d6
Rollup merge of #96289 - aDotInTheVoid:redundant-fmt, r=jackh726
Remove redundant `format!`s
2022-04-21 20:55:21 +02:00
Dylan DPC
35ef5c6e4c
Rollup merge of #96269 - davidtwco:diagnostic-translation-minor-changes, r=oli-obk
errors: minor translation-related changes

- For one error in typeck, specifying "suggestion" as the attribute for the only suggestion is unnecessary, it's the default of the derive.
- The documentation comment for the `SessionDiagnostic` derive is out-of-date, it should have been updated in #95512.

r? `@oli-obk`
2022-04-21 20:55:21 +02:00
Dylan DPC
18b6ad327f
Rollup merge of #96248 - TaKO8Ki:remove-unnecessary-format-args, r=compiler-errors
Stop using a string literal as a format argument
2022-04-21 20:55:19 +02:00
Dylan DPC
e50105e3f5
Rollup merge of #95434 - cjgillot:dump-dep-kind, r=oli-obk
Only output DepKind in dump-dep-graph.

When printing the whole DepNode, the output file is simply too massive to
be actually useful for profiling.

This trimmed down version mixes a lot of information together, but it also
allows to ask questions such that "why does this query ever access HIR?".
2022-04-21 20:55:18 +02:00
Nixon Enraght-Moony
8fa20e01a5 Remove redundant format!s 2022-04-21 16:46:20 +01:00
bors
b04c5329e1 Auto merge of #96210 - nnethercote:speed-up-TokenCursor, r=petrochenkov
Speed up `TokenCursor`

Plus a few related clean-ups.

r? `@petrochenkov`
2022-04-21 15:42:50 +00:00
SparrowLii
3d256b3ecb access local_decls through ecx 2022-04-21 18:26:43 +08:00
Takayuki Maeda
547cb2722b make E0117 error clear 2022-04-21 16:47:01 +09:00
bors
5176945ad4 Auto merge of #95612 - davidtwco:split-debuginfo-in-bootstrap, r=Mark-Simulacrum
bootstrap: add split-debuginfo config

Replace `run-dysutil` option with more general `split-debuginfo` option that works on all platforms.

r? `@Mark-Simulacrum`
2022-04-21 05:24:48 +00:00
Nicholas Nethercote
643e9f707e Introduced Cursor::next_with_spacing_ref.
This lets us clone just the parts within a `TokenTree` that need
cloning, rather than the entire thing. This is a surprisingly large
performance win, up to 4% on `async-std-1.10.0`.
2022-04-21 13:49:40 +10:00
David Wood
f79d5e9458 macros: update doc comment for diagnostic derive
The documentation comment for this derive is out-of-date, it should have
been updated in #95512.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-21 04:22:18 +01:00
David Wood
437468daf7 typeck: remove unnecessary fluent attr
Specifying "suggestion" as the attribute for the only suggestion is
unnecessary, it's the default of the derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-21 04:03:13 +01:00
Nicholas Nethercote
cc4e3443ec Produce CloseDelim and pop the stack at the same time.
This makes `CloseDelim` handling more like `OpenDelim` handling, which
produces `OpenDelim` and pushes the stack at the same time. It requires
some adjustment to `parse_token_tree` now that we don't remain within
the frame after getting the `CloseDelim`.
2022-04-21 12:34:38 +10:00
Nicholas Nethercote
7a89255b20 Avoid some tuple destructuring.
Surprisingly, this is a non-trivial performance win.
2022-04-21 09:21:45 +10:00
Dylan DPC
463c94a780
Rollup merge of #96236 - Aaron1011:constraint-debug, r=jackh726
Add an explicit `Span` field to `OutlivesConstraint`

Previously, we would retrieve the span from the `Body` using
the `locations` field. However, we may end up changing the
`locations` field when moving a constraint from a promoted
to a different body.

We now store the original `Span` in a dedication field, so that
changes to the `locations` do not affect the quality of our
diagnostics.
2022-04-21 01:14:17 +02:00
Vadim Petrochenkov
e0b71fff2a [WIP] rustdoc: Resolve some more doc links early 2022-04-21 01:18:02 +03:00
Dylan DPC
72cb094611
Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obk
Miri/interpreter debugging tweaks

Some changes I made to make debugging Miri with trace logging less terrible.

r? ``@oli-obk``
2022-04-20 18:26:02 +02:00
Dylan DPC
38e3f523c0
Rollup merge of #93313 - tmiasko:uninhabited, r=tmandry
Check if call return type is visibly uninhabited when building MIR

The main motivation behind the change is to expose information about diverging
calls to the generator transform and match the precision of drop range tracking
which already understands that call expressions with visibly uninhabited types
diverges.

This change should also accept strictly more programs than before. That is
programs that were previously rejected due to errors raised by control-flow
sensitive checks in a code that is no longer considered reachable.

Fixes #93161.
2022-04-20 18:26:01 +02:00
bors
d39864d64e Auto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez
rustdoc: Optimize and refactor doc link resolution

One more subset of https://github.com/rust-lang/rust/pull/94857 that should bring perf improvements rather than regressions + a couple more optimizations on top of it.
It's better to read individual commits and their descriptions to understand the changes.
The `may_have_doc_links` optimization is not *very* useful here, but it's much more important for https://github.com/rust-lang/rust/pull/94857.

Closes https://github.com/rust-lang/rust/issues/96079
2022-04-20 13:34:48 +00:00