Commit Graph

12879 Commits

Author SHA1 Message Date
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
b-naber
bc698c73e9 deduplicate a lot of code 2022-04-21 23:11:06 +02: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
b-naber
28af967bb9 implement (as of now still unused) query for valtree -> constvalue conversion 2022-04-21 16:37:24 +02:00
b-naber
1157dc7167 implement valtree -> constvalue conversion 2022-04-21 15:53:26 +02:00
SparrowLii
3d256b3ecb access local_decls through ecx 2022-04-21 18:26:43 +08:00
b-naber
eaf8cdaa0b add helper methods on ValTree 2022-04-21 10:59:12 +02:00
b-naber
2bc59c7ae2 add some helper methods to ScalarInt 2022-04-21 10:59:11 +02: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
SparrowLii
38bd4fbdbd rename to BoundKind and add comments 2022-04-21 10:09:32 +08: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
Takayuki Maeda
5078b053b5 remove an unnecessary format arg 2022-04-20 21:16:56 +09:00
bors
0034bbca26 Auto merge of #96022 - martingms:inline-const-getters, r=nnethercote
Inline `ty::Const::ty()` and `ty::Const::val()` getters

These were not inlined into `super_relate_consts`, which is one of the hottest functions in a callgrind profile of compiling `bitmaps-3.1.0`.

Yields some small speedups across various benchmarks locally:

#### Primary benchmarks

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
unicode-normalization-0.1.19 | check | full | -0.56% | 2.78x
unicode-normalization-0.1.19 | check | incr-full | -0.43% | 2.15x
unicode-normalization-0.1.19 | opt | full | -0.35% | 1.77x
unicode-normalization-0.1.19 | debug | incr-full | -0.31% | 1.56x
unicode-normalization-0.1.19 | debug | full | -0.30% | 1.51x

#### Secondary benchmarks

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
bitmaps-3.1.0 | check | full | -1.88% | 9.39x
bitmaps-3.1.0 | debug | full | -1.79% | 8.96x
bitmaps-3.1.0 | opt | full | -1.69% | 8.43x
bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x
bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.27x
bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.96x
tt-muncher | opt | full | 1.28% | 6.38x
nalgebra-0.30.1 | check | full | -0.96% | 4.81x
nalgebra-0.30.1 | debug | full | -0.91% | 4.54x
nalgebra-0.30.1 | opt | full | -0.90% | 4.52x
nalgebra-0.30.1 | check | incr-full | -0.77% | 3.86x
nalgebra-0.30.1 | opt | incr-full | -0.76% | 3.79x
nalgebra-0.30.1 | debug | incr-full | -0.74% | 3.72x
hex-0.4.3 | check | full | -0.70% | 3.50x
hex-0.4.3 | debug | full | -0.59% | 2.95x
hex-0.4.3 | check | incr-full | -0.56% | 2.80x
hex-0.4.3 | opt | full | -0.56% | 2.78x
wf-projection-stress-65510 | opt | full | -0.48% | 2.42x
hex-0.4.3 | opt | incr-full | -0.48% | 2.40x
hex-0.4.3 | debug | incr-full | -0.45% | 2.24x
wf-projection-stress-65510 | check | full | -0.44% | 2.18x
wf-projection-stress-65510 | debug | full | -0.42% | 2.08x
wf-projection-stress-65510 | check | incr-full | -0.40% | 2.01x
deep-vector | debug | incr-patched: add vec item | -0.38% | 1.88x
wf-projection-stress-65510 | debug | incr-full | -0.37% | 1.86x
wf-projection-stress-65510 | opt | incr-full | -0.36% | 1.81x
deep-vector | debug | incr-patched: println | 0.33% | 1.63x

r? `@nnethercote`
2022-04-20 11:12:55 +00:00
SparrowLii
4375b36117 Add BoundCtxt in visit_param_bounds to check questions in bounds 2022-04-20 19:06:32 +08:00
Nikita Popov
6dc0bcc5db Stub out more PassManagerBuilder functions 2022-04-20 09:36:02 +02:00
Nikita Popov
890cabac8a Stub out various legacy PM functions with LLVM 15 2022-04-20 09:25:47 +02:00
Nikita Popov
7dc307fc7a Add missing include 2022-04-20 09:25:47 +02:00
Nikita Popov
25286dda2b Drop support for -Znew-llvm-pass-manager=no with LLVM 15 2022-04-20 09:25:47 +02:00
Nicholas Nethercote
880318c70a Remove Eof sanity check in Parser::inlined_bump_with.
A Google search of the error message fails to return any relevant
resuts, suggesting this has never occurred in practice. And removeing it
reduces instruction counts by up to 2% on some benchmarks.
2022-04-20 14:52:54 +10:00
Nicholas Nethercote
d2b9bbbf78 Inline Parser::nonterminal_may_begin_with. 2022-04-20 14:13:49 +10:00
Nicholas Nethercote
f9235db37e Inline Parser::parse_nonterminal. 2022-04-20 14:08:59 +10:00
Nicholas Nethercote
9e6879fdba Only record fallback_span when necessary. 2022-04-20 14:04:22 +10:00
bors
27af517549 Auto merge of #96082 - michaelwoerister:less_impl_stable_hash_via_hash, r=compiler-errors
incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.

Fixes https://github.com/rust-lang/rust/issues/96013.
2022-04-20 03:51:09 +00:00
Aaron Hill
611a06a375
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-19 23:42:20 -04:00
Nicholas Nethercote
5b653c1a43 Inline Cursor::next_with_spacing. 2022-04-20 12:43:25 +10:00
Nicholas Nethercote
b09522a634 Remove the loop from Parser::bump().
The loop is there to handle a `NoDelim` open/close token. This commit
changes `TokenCursor::inlined_next` so it never returns such a token.
This is a performance win because the conditional test in `bump()` is
removed.

If the parser needs changing in the future to handle `NoDelim` tokens,
then `inlined_next()` can easily be changed to return them.
2022-04-20 12:28:26 +10:00
Nicholas Nethercote
3cd5e34617 Remove TokenCursorFrame::open_delim.
Because it's now always true.
2022-04-20 12:28:26 +10:00
Nicholas Nethercote
86723d3d46 Use true for open_delim/close_delim in one spot.
The `DelimToken` here is `NoDelim`, which means the returned delim
tokens will just be ignored by `Parser::bump()`. This commit changes
things so the delim tokens won't be returned.
2022-04-20 12:26:49 +10:00
Nicholas Nethercote
804103b0ae Add a size assertion for Parser. 2022-04-20 11:48:07 +10:00
Nicholas Nethercote
f1c32c10c4 Move desugaring code into its own function.
It's not hot, so shouldn't be within the always inlined part.
2022-04-20 08:33:25 +10:00
Xavier Denis
eed91ee8b3 Make all thir types implement clone 2022-04-20 00:11:08 +02:00
Dylan DPC
9d9d5910af
Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obk
Miri provenance cleanup

Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here.

``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type.

r? ``@oli-obk``
2022-04-19 22:57:43 +02:00
Dylan DPC
f7d8f5b1e1
Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk
interpret: Fix writing uninit to an allocation

When calling `mark_init`, we need to also be mindful of what happens with the relocations! Specifically, when we de-init memory, we need to clear relocations in that range as well or else strange things will happen (and printing will not show the de-init, since relocations take precedence there).

Fixes https://github.com/rust-lang/miri/issues/2068.

Here's the Miri testcase that this fixes (requires `-Zmiri-disable-validation`):
```rust
use std::mem::MaybeUninit;

fn main() { unsafe {
    let mut x = MaybeUninit::<i64>::uninit();
    // Put in a ptr.
    x.as_mut_ptr().cast::<&i32>().write_unaligned(&0);
    // Overwrite parts of that pointer with 'uninit' through a Scalar.
    let ptr = x.as_mut_ptr().cast::<i32>();
    *ptr = MaybeUninit::uninit().assume_init();
    // Reading this back should hence work fine.
    let _c = *ptr;
} }
```
Previously this failed with
```
error: unsupported operation: unable to turn pointer into raw bytes
  --> ../miri/uninit.rs:11:14
   |
11 |     let _c = *ptr;
   |              ^^^^ unable to turn pointer into raw bytes
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

   = note: inside `main` at ../miri/uninit.rs:11:14
```
2022-04-19 22:57:42 +02:00
Dylan DPC
113f079a97
Rollup merge of #96029 - IsakNyberg:error-messages-fix, r=Dylan-DPC
Refactor loop into iterator; simplify negation logic.

is_dummy should return when a non-dummy is found, but instead is iterated until completion. With some inspiration from line 323 this was refactored to a single line that returns once a single counterexample is found.
2022-04-19 22:57:41 +02:00
Dylan DPC
69e45d73b9
Rollup merge of #95740 - Amanieu:kreg0, r=nagisa
asm: Add a kreg0 register class on x86 which includes k0

Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.

Fixes #94977
2022-04-19 22:57:39 +02:00
Vadim Petrochenkov
e2d3a4f631 rustc_metadata: Store a flag telling whether an item may have doc links in its attributes
This should be cheap on rustc side, but it's significant optimization for rustdoc that won't need to decode and process attributes unnecessarily
2022-04-19 22:53:46 +03:00
Kjetil Kjeka
352abbaade Fix a bug in the ptx-kernel calling convention where structs was passed indirectly
Structs being passed indirectly is suprpising and have a high chance not to work as the device and host usually do not share memory.
2022-04-19 18:03:36 +02:00
Amanieu d'Antras
b2bc46938c asm: Add a kreg0 register class on x86 which includes k0
Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.

Fixes #94977
2022-04-19 17:14:23 +02:00
bors
4ca19e09d3 Auto merge of #96214 - Dylan-DPC:rollup-a5b4fow, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #94493 (Improved diagnostic on failure to meet send bound on future in a foreign crate)
 - #95809 (Fix typo in bootstrap.py)
 - #96086 (Remove `--extern-location` and all associated code)
 - #96089 (`alloc`: make `vec!` unavailable under `no_global_oom_handling`)
 - #96122 (Fix an invalid error for a suggestion to add a slice in pattern-matching)
 - #96142 (Stop using CRATE_DEF_INDEX outside of metadata encoding.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-19 13:10:12 +00:00
Dylan DPC
9fad214593
Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov
Stop using CRATE_DEF_INDEX outside of metadata encoding.

`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.  We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-19 14:43:21 +02:00
Dylan DPC
036d200d1c
Rollup merge of #96122 - TaKO8Ki:fix-invalid-error-for-suggestion-to-add-slice-in-pattern-matching, r=nagisa
Fix an invalid error for a suggestion to add a slice in pattern-matching

closes #96103
2022-04-19 14:43:20 +02:00
Dylan DPC
5f10d1312d
Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwco
Remove `--extern-location` and all associated code

`--extern-location` was an experiment to investigate the best way to
generate useful diagnostics for unused dependency warnings by enabling a
build system to identify the corresponding build config.

While I did successfully use this, I've since been convinced the
alternative `--json unused-externs` mechanism is the way to go, and
there's no point in having two mechanisms with basically the same
functionality.

This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-19 14:43:17 +02:00
Dylan DPC
ab59516dfd
Rollup merge of #94493 - oribenshir:feature/ISSUE-78543_async_fn_in_foreign_crate_diag_2, r=davidtwco
Improved diagnostic on failure to meet send bound on future in a foreign crate

Provide a better diagnostic on failure to meet send bound on futures in a foreign crate.

fixes #78543
2022-04-19 14:43:15 +02:00
bors
c102c5cfc6 Auto merge of #96020 - martingms:optimize-relate_substs, r=nnethercote
Micro-optimize `ty::relate::relate_substs` by avoiding `match`

Was a top-20 hot function in a callgrind profile of compiling `bitmaps-3.1.0`.

Yields some small speedups on that crate and some others according to local benching:

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
bitmaps-3.1.0 | check | full | -1.88% | 9.42x
bitmaps-3.1.0 | debug | full | -1.80% | 8.99x
bitmaps-3.1.0 | opt | full | -1.70% | 8.49x
bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x
deep-vector | debug | full | 1.52% | 7.61x
bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.26x
bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.95x
nalgebra-0.30.1 | check | full | -0.68% | 3.42x
nalgebra-0.30.1 | debug | full | -0.64% | 3.22x
nalgebra-0.30.1 | opt | full | -0.64% | 3.20x
projection-caching | check | full | -0.61% | 3.05x
nalgebra-0.30.1 | check | incr-full | -0.56% | 2.78x
nalgebra-0.30.1 | opt | incr-full | -0.54% | 2.72x
nalgebra-0.30.1 | debug | incr-full | -0.54% | 2.69x
projection-caching | check | incr-full | -0.50% | 2.51x
tt-muncher | opt | full | -0.48% | 2.42x
projection-caching | opt | full | -0.47% | 2.37x
projection-caching | debug | full | -0.47% | 2.35x
projection-caching | opt | incr-full | -0.44% | 2.21x
projection-caching | debug | incr-full | -0.42% | 2.08x
deeply-nested-multi | check | incr-full | 0.37% | 1.87x
wf-projection-stress-65510 | opt | full | -0.37% | 1.84x
deep-vector | debug | incr-patched: add vec item | -0.32% | 1.61x
projection-caching | debug | incr-unchanged | -0.32% | 1.60x
wf-projection-stress-65510 | check | full | -0.31% | 1.55x
projection-caching | opt | incr-unchanged | -0.31% | 1.53x
wf-projection-stress-65510 | debug | incr-full | -0.30% | 1.51x
wf-projection-stress-65510 | opt | incr-full | -0.30% | 1.51x

r? `@nnethercote`
2022-04-19 10:53:53 +00:00
Michael Woerister
c0be619724 incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it. 2022-04-19 10:43:20 +02:00
Nicholas Nethercote
d235ac7801 Handle Delimited opening immediately.
Instead of letting the next iteration of the loop handle it.
2022-04-19 17:02:49 +10:00
Nicholas Nethercote
29c78cc086 Add {open,close}_delim arguments to TokenCursorFrame::new().
This will facilitate the change in the next commit.

`boolean` arguments aren't great, but the function is only used in three
places within this one file.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
02317542eb Rearrange TokenCursor::inlined_next().
In particular, avoid wrapping a token within `TokenTree::Token` and then
immediately matching it and returning the token within. Just return the
token immediately.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
b1e6dee596 Merge TokenCursor::{next,next_desugared}.
And likewise for the inlined variants.

I did this for simplicity, but interesting it was a performance win as
well.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
89ec75b0e9 Inline and remove Parser::next_tok().
It has a single call site.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
aefbbeec34 Inline and remove TokenTree::{open_tt,close_tt}.
They both have a single call site.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
ad566b78f2 Tweak Cursor::next_with_spacing.
This makes it more like `CursorRef::next_with_spacing`. There is no
performance effect, just a consistency improvement.
2022-04-19 17:02:48 +10:00
bors
e2661bac6d Auto merge of #95379 - icewind1991:suggest-associated-type-more, r=jackh726
show suggestion to replace generic bounds with associated types in more cases

Moves the hint to replace generic parameters with associated type bounds from the "not all associated type bounds are specified"(`E0191`) to "to many generic type parameters provided"(`E0107`).

Since `E0191` is only emitted in places where all associated types must be specified (when creating `dyn` types), the suggesting is currently not shown for other generic type uses (such as in generic type bounds). With this change the suggesting is always emitted when the number of excess generic parameters matches the number of unbound associated types.

Main motivation for the change was a lack of useful suggesting when doing

```rust
fn foo<I: Iterator<usize>>(i: I) {}
```
2022-04-19 01:59:35 +00:00
Erik Desjardins
1bbae507d4 mark payload fields of ScalarPair enums as Scalar::Union when they're not always initialized 2022-04-18 21:43:20 -04:00
est31
3c1e1661e7 Remove unused macro rules 2022-04-18 23:28:06 +02:00
Gary Guo
e2fdb84df7 Conditionally export msan symbols only if they are defined
* `__msan_keep_going` is defined when `-Zsanitizer-recover=memory`.
* `__msan_track_origins` is defined when `-Zsanitizer-memory-track-origins`.
2022-04-18 20:50:56 +01:00
Gary Guo
c475117ffb Refactor exported_symbols and linked_symbols for code reuse 2022-04-18 20:50:56 +01:00
Gary Guo
773f533eae Synthesis object file for #[used] and exported symbols 2022-04-18 20:50:56 +01:00
Gary Guo
a1dae4bc9d Make #[used] considered reachable 2022-04-18 20:50:56 +01:00
Gary Guo
49cc6d1f84 Add SymbolExportInfo
This is currently a wrapper to `SymbolExportLevel` but it allows
later addition of extra information.
2022-04-18 20:50:56 +01:00
ouz-a
5364c86e8e replace iter with into_iter() 2022-04-18 22:05:16 +03:00
Ralf Jung
55f0977a6b remove an unnecessary use of loc_place.ptr.into_pointer_or_addr 2022-04-18 12:47:38 -04:00
Ralf Jung
c83241a7f9 avoid an unnecessary call to Pointer::into_parts, and caution against into_pointer_or_addr 2022-04-18 12:30:17 -04:00
Ralf Jung
3236092503 add method to get absolute address of a pointer (useful only for Miri) 2022-04-18 12:30:17 -04:00
Ralf Jung
c9e568f72e avoid pairing up AllocId and PointerTag, which is redundant 2022-04-18 10:14:06 -04:00
Takayuki Maeda
5924ef874e stop using Autoderef 2022-04-18 12:51:12 +09:00
David Wood
b786345347 ssa: don't pack debuginfo on windows not only msvc
Small fix that prevents `thorin` from running on platforms where it
definitely shouldn't be running.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-18 03:47:51 +01:00
Ralf Jung
54ab357a5b ptr_get_alloc_id: don't return an actual Pointer 2022-04-17 22:27:14 -04:00
Ralf Jung
05489e7ec8 check Allocation invariant during printing 2022-04-17 21:08:58 -04:00
Ralf Jung
f3bdcfb8b0 downgrade really verbose logging to trace 2022-04-17 20:52:33 -04:00
Ralf Jung
989e7479d9 interpret: more debug logging for read_scalar and write_scalar 2022-04-17 20:52:30 -04:00
Ralf Jung
29cc8ec2d1 explain why prepare_relocation_copy works the way it does 2022-04-17 20:38:00 -04:00
Ralf Jung
3ec1febbf5 add caution to some comments 2022-04-17 19:32:13 -04:00
Ralf Jung
85ee04c44a when writing uninit to an allocation, also clear relocations like other writes do 2022-04-17 19:16:54 -04:00
Ralf Jung
5640304c63 add log warnings for when we overwrite parts of a pointer, and de-init the rest 2022-04-17 19:03:08 -04:00
ouz-a
70e67d6f55 fat vec 2022-04-17 22:16:12 +03:00
ouz-a
831ebfc961 format err 2022-04-17 17:11:54 +03:00
ouz-a
2d2c5e118a little changes 2022-04-17 16:52:18 +03:00
bors
1ec2c136b3 Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkov
Report undeclared lifetimes during late resolution.

First step in https://github.com/rust-lang/rust/pull/91557

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`
2022-04-17 12:56:19 +00:00
bors
af68f7182e Auto merge of #96016 - Aaron1011:hash-name-cleanup, r=cjgillot
Remove last vestiges of skippng ident span hashing

This removes a comment that no longer applies, and properly hashes
the full ident for path segments.
2022-04-17 10:31:52 +00:00
Camille GILLOT
07ee031763 Stop using CRATE_DEF_INDEX.
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17 12:14:42 +02:00
Martin Gammelsæter
19dedf3a4b Split relate_substs into two functions
One for the case with variances, and one without.
All callers use an explicit Option for the variable anyway.
2022-04-17 11:04:58 +02:00
Camille GILLOT
a9e13fa553 Lint elided lifetimes in path on the AST. 2022-04-17 11:03:34 +02:00
Camille GILLOT
fc9f25531a Report undeclared lifetimes on AST. 2022-04-17 11:03:34 +02:00
Camille GILLOT
4cfceeabdc Remove is_in_fn_syntax. 2022-04-17 11:03:33 +02:00
Camille GILLOT
e47f66dc0d Visit generics inside visit_fn. 2022-04-17 11:03:33 +02:00
Camille GILLOT
aa2b5ef635 Count number of lifetime parameters in a separate pass. 2022-04-17 11:03:33 +02:00
bors
edba282770 Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillot
Refactor HIR item-like traversal (part 1)

Issue  #95004

- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems
- use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId
- use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel;

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>

cc `@cjgillot`
2022-04-17 08:06:53 +00:00
bors
ac8b11810f Auto merge of #96010 - eduardosm:Unique-on-top-of-NonNull, r=m-ou-se,tmiasko
Implement `core::ptr::Unique` on top of `NonNull`

Removes the use `rustc_layout_scalar_valid_range_start` and some `unsafe` blocks.
2022-04-17 05:26:08 +00:00
bors
2c28b0eaf9 Auto merge of #96134 - Dylan-DPC:rollup-ejug3yq, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #95346 (Stablize `const_extern_fn` for "Rust" and "C")
 - #95933 (htmldocck: Compare HTML tree instead of plain text html)
 - #96105 (Make the debug output for `TargetSelection` less verbose)
 - #96112 (Strict provenance lint diagnostics improvements)
 - #96119 (update Miri)
 - #96124 (to_digit tweak)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-17 00:44:53 +00:00
Robin Appelman
decc04dbfb show suggestion to replace generic bounds with associated types in more cases 2022-04-17 00:44:36 +02:00
Jakob Degen
4534188d4b Address nits 2022-04-16 18:44:27 -04:00
Jakob Degen
f280a839a7 Add support for MIR opt unit tests 2022-04-16 18:23:59 -04:00
Dylan DPC
99437b303a
Rollup merge of #96112 - niluxv:strict-provenance-lint-improvements, r=nagisa
Strict provenance lint diagnostics improvements

Use `multipart_suggestion` instead of `span_suggestion` and getting a snippet for the expression. Also don't suggest unnecessary parenthesis in `lossy_provenance_casts`.
cc ``@estebank``
``@rustbot`` label A-diagnostics
2022-04-17 00:07:26 +02:00
Dylan DPC
bd334984e2
Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelix
Stablize `const_extern_fn` for "Rust" and "C"

All other ABIs are left unstable for now.

cc #64926
2022-04-17 00:07:23 +02:00
bors
563ef23529 Auto merge of #95899 - petrochenkov:modchild2, r=cjgillot
rustc_metadata: Do not encode unnecessary module children

This should remove the syntax context shift and the special case for `ExternCrate` in decoder in https://github.com/rust-lang/rust/pull/95880.

This PR also shifts some work from decoding to encoding, which is typically useful for performance (but probably not much in this case).
r? `@cjgillot`
2022-04-16 22:04:10 +00:00
Isak Nyberg
657ae03f60
Update compiler/rustc_error_messages/src/lib.rs
Co-authored-by: Janusz Marcinkiewicz <virrages@gmail.com>
2022-04-16 23:52:18 +02:00
Dylan DPC
9905774762
Rollup merge of #96058 - euclio:flock-impls, r=nagisa
separate flock implementations into separate modules

The main benefit of doing this is that rustfmt will now format each of these modules.
2022-04-16 19:42:05 +02:00
Dylan DPC
a84a811943
Rollup merge of #95908 - compiler-errors:shallow_resolve_ty-inline, r=oli-obk
Inline `shallow_resolve_ty` into `ShallowResolver`

addresses fixme I found in infcx
2022-04-16 19:42:04 +02:00
Dylan DPC
1dc672a766
Rollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obk
Include Refs in Valtree Creation

This adds references to `const_to_valtree`, which isn't used in the compiler yet, but after the previous changes we made to the thir and mir representations and this change we should be able to finally introduce them in the next PR.

I wasn't able to properly test this code, except indirectly by including a call of `const_to_valtree` in the code that currently creates constants (`turn_into_const_value`).

r? `@lcnr`

cc `@oli-obk` `@RalfJung`
2022-04-16 19:42:03 +02:00
Dylan DPC
3dced80298
Rollup merge of #95006 - tmiasko:thread-local-static, r=wesleywiser
Reject `#[thread_local]` attribute on non-static items
2022-04-16 19:42:02 +02:00
Dylan DPC
22d554657d
Rollup merge of #94985 - dtolnay:constattr, r=pnkfelix
Parse inner attributes on inline const block

According to https://github.com/rust-lang/rust/pull/84414#issuecomment-826150936, inner attributes are intended to be supported *"in all containers for statements (or some subset of statements)"*.

This PR adds inner attribute parsing and pretty-printing for inline const blocks (https://github.com/rust-lang/rust/issues/76001), which contain statements just like an unsafe block or a loop body.

```rust
let _ = const {
    #![allow(...)]

    let x = ();
    x
};
```
2022-04-16 19:42:00 +02:00
Takayuki Maeda
a59cc5774b fix an invalid error for a suggestion to add a slice in pattern-matching 2022-04-17 01:20:11 +09:00
Martin Gammelsæter
041121a184 Optimize relate_substs by extracting match
There was no need to keep doing the match inside the iterator.
2022-04-16 17:42:27 +02:00
bors
d9b3ff7d34 Auto merge of #96117 - Dylan-DPC:rollup-5traczf, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #95887 (resolve: Create dummy bindings for all unresolved imports)
 - #96023 (couple of clippy::perf fixes)
 - #96035 (Update GitHub Actions actions/checkout Version v2 -> v3)
 - #96038 (docs: add link from zip to unzip)
 - #96047 (⬆️ rust-analyzer)
 - #96059 (clarify doc(cfg) wording)
 - #96081 (Make some `usize`-typed masks definitions agnostic to the size of `usize`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-16 14:24:14 +00:00
ouz-a
aada74b28f Make derefer work everwhere
Co-Authored-By: Oli Scherer <332036+oli-obk@users.noreply.github.com>
2022-04-16 16:03:14 +03:00
Dylan DPC
91847c43cc
Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnr
couple of clippy::perf fixes
2022-04-16 14:25:56 +02:00
Dylan DPC
0a8acac7a3
Rollup merge of #95887 - petrochenkov:doclink5, r=cjgillot
resolve: Create dummy bindings for all unresolved imports

Apparently such bindings weren't previously created for all unresolved imports, causing issues like https://github.com/rust-lang/rust/issues/95879.
In this PR I'm trying to create such dummy bindings in a more centralized way by calling `import_dummy_binding` once for all imports in `finalize_imports`.

Fixes https://github.com/rust-lang/rust/issues/95879.
2022-04-16 14:25:55 +02:00
bors
febce1fc31 Auto merge of #95689 - lqd:self-profiler, r=wesleywiser
Allow self-profiler to only record potentially costly arguments when argument recording is turned on

As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns/near/277304909) with `@wesleywiser,` I'd like to record proc-macro expansions in the self-profiler, with some detailed data (per-expansion spans for example, to follow #95473).

At the same time, I'd also like to avoid doing expensive things when tracking a generic activity's arguments, if they were not specifically opted into the event filter mask, to allow the self-profiler to be used in hotter contexts.

This PR tries to offer:
- a way to ensure a closure to record arguments will only be called in that situation, so that potentially costly arguments can still be recorded when needed. With the additional requirement that, if possible, it would offer a way to record non-owned data without adding many `generic_activity_with_arg_{...}`-style methods. This lead to the `generic_activity_with_arg_recorder` single entry-point, and the closure parameter would offer the new methods, able to be executed in a context where costly argument could be created without disturbing the profiled piece of code.
- some facilities/patterns allowing to record more rustc specific data in this situation, without making `rustc_data_structures`  where the self-profiler is defined, depend on other rustc crates (causing circular dependencies): in particular, spans. They are quite tricky to turn into strings (if the default `Debug` impl output does not match the context one needs them for), and since I'd also like to avoid the allocation there when arg recording is turned off today, that has turned into another flexibility requirement for the API in this PR (separating the span-specific recording into an extension trait). **edit**: I've removed this from the PR so that it's easier to review, and opened https://github.com/rust-lang/rust/pull/95739.
- allow for extensibility in the future: other ways to record arguments, or additional data attached to them could be added in the future (e.g. recording the argument's name as well as its data).

Some areas where I'd love feedback:
- the API and names: the `EventArgRecorder` and its method for example. As well as the verbosity that comes from the increased flexibility.
- if I should convert the existing `generic_activity_with_arg{s}` to just forward to `generic_activity_with_arg_recorder` + `recorder.record_arg` (or remove them altogether ? Probably not): I've used the new API in the simple case I could find of allocating for an arg that may not be recorded, and the rest don't seem costly.
- [x] whether this API should panic if no arguments were recorded by the user-provided closure (like this PR currently does: it seems like an error to use an API dedicated to record arguments but not call the methods to then do so) or if this should just record a generic activity without arguments ?
- whether the `record_arg` function should be `#[inline(always)]`, like the `generic_activity_*` functions ?

As mentioned, r? `@wesleywiser` following our recent discussion.
2022-04-16 11:43:28 +00:00
oribenshir
ebe3c56c6e Provide a better diagnostic on failure to meet send bound on futures in a foreign crate
Adding diagnostic data on generators to the crate metadata and using it to provide
a better diagnostic on failure to meet send bound on futures originated from a foreign crate
2022-04-16 14:09:40 +03:00
bors
c8422403f7 Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used)
 - #94605 (Add missing links in platform support docs)
 - #95372 (make unaligned_references lint deny-by-default)
 - #95859 (Improve diagnostics for unterminated nested block comment)
 - #95961 (implement SIMD gather/scatter via vector getelementptr)
 - #96004 (Consider lifetimes when comparing types for equality in MIR validator)
 - #96050 (Remove some now-dead code that was only relevant before deaggregation.)
 - #96070 ([test] Add test cases for untested functions for BTreeMap)
 - #96099 (MaybeUninit array cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-16 09:19:26 +00:00
niluxv
1d63d6db55 Improve fuzzy_provenance_casts lint diagnostics
Use `multipart_suggestion` instead of getting a snippet.
2022-04-16 10:40:06 +02:00
niluxv
02d12bc30c Improve lossy_provenance_casts lint diagnostics
Use `multipart_suggestion` and don't suggested unnecessary parenthesis.
2022-04-16 10:32:37 +02:00
bors
07bb916d44 Auto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, r=estebank
Better method call error messages

Rebase/continuation of #71827

~Based on #92360~
~Based on #93118~

There's a decent description in #71827 that I won't copy here (for now at least)

In addition to rebasing, I've tried to restore most of the original suggestions for invalid arguments. Unfortunately, this does make some of the errors a bit verbose. To fix this will require a bit of refactoring to some of the generalized error suggestion functions, and I just don't have the time to go into it right now.

I think this is in a state that the error messages are overall better than before without a reduction in the suggestions given.

~I've tried to split out some of the easier and self-contained changes into separate commits (mostly in #92360, but also one here). There might be more than can be done here, but again just lacking time.~

r? `@estebank` as the original reviewer of #71827
2022-04-16 06:55:28 +00:00
Jack Huey
b6c87c555f Implementation for 65853
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes.

The algorithm is inspired by Levenshtein distance and longest common sub-sequence.   In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other.

We then modify that algorithm to detect 4 cases:

 - A function input is missing
 - An extra argument was provided
 - The type of an argument is straight up invalid
 - Two arguments have been swapped
 - A subset of the arguments have been shuffled

(We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.)

It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site.

The basic sketch of the algorithm is as follows:

 - Construct a boolean grid, with a row for each argument, and a column for each input.  The cell [i, j] is true if the i'th argument could satisfy the j'th input.
 - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type".
 - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument.
 - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input
 - Swapped / Permuted arguments are identified with a cycle detection algorithm.

As each issue is found, we remove the relevant inputs / arguments and check for more issues.  If we find no issues, we match up any "valid" arguments, and start again.

Note that there's a lot of extra complexity:
 - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix.
 - Closure arguments are wrapped in a tuple and need to be unwrapped
 - We need to resolve closure types after the rest, to allow the most specific type constraints
 - We need to handle imported C functions that might be variadic in their inputs.

I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-16 02:26:56 -04:00
Dylan DPC
ab7fb29878
Rollup merge of #96050 - oli-obk:deaggregator_cleanup, r=RalfJung
Remove some now-dead code that was only relevant before deaggregation.

The code was broken anyway, if the deaggregator is disabled, it would have ICEd on any non-enum Adt

r? ```@RalfJung```
2022-04-16 07:12:47 +02:00
Dylan DPC
fd7a1f153d
Rollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkov
Consider lifetimes when comparing types for equality in MIR validator

Closes #95978 .
2022-04-16 07:12:46 +02:00
Dylan DPC
ea131bca17
Rollup merge of #95961 - RalfJung:gather-scatter, r=workingjubilee
implement SIMD gather/scatter via vector getelementptr

Fixes https://github.com/rust-lang/portable-simd/issues/271

However, I don't *really* know what I am doing here... Cc ``@workingjubilee`` ``@calebzulawski``

I didn't do anything for cranelift -- ``@bjorn3`` not sure if it's okay for that backend to temporarily break. I'm happy to cherry-pick a patch that adds cranelift support. :)
2022-04-16 07:12:45 +02:00
Dylan DPC
946d76ec0e
Rollup merge of #95859 - rainy-me:unterminated-nested-block-comment, r=petrochenkov
Improve diagnostics for unterminated nested block comment

close #95283

(This is my first time try to messing around with rust compiler and might get a lot of things wrong... 🙇 )
2022-04-16 07:12:44 +02:00
Dylan DPC
49a31cdc1d
Rollup merge of #95372 - RalfJung:unaligned_references, r=oli-obk
make unaligned_references lint deny-by-default

This lint has been warn-by-default for a year now (since https://github.com/rust-lang/rust/pull/82525), so I think it is time to crank it up a bit. Code that triggers the lint causes UB (without `unsafe`) when executed, so we really don't want people to write code like this.
2022-04-16 07:12:43 +02:00
Dylan DPC
d14bda48d5
Rollup merge of #93969 - bjorn3:codegen_backend_dep_info, r=pnkfelix
Only add codegen backend to dep info if -Zbinary-dep-depinfo is used

I am currently migrating the cg_clif build system from using a binary linked to the codegen backend as rustc replacement to passing `-Zcodegen-backend` instead. Without this PR this would force cargo to rebuild the sysroot on any change to the codegen backend even if I explicitly specify that I want it to be preserved, which would make development of cg_clif a lot slower. If you still want to have changes to the codegen backend invalidate the cargo build cache you can explicitly specify `-Zbinary-dep-depinfo`.

cc ``@eddyb`` as the codegen backend was initially added to the depinfo for rust-gpu.
2022-04-16 07:12:42 +02:00
bors
080d5452e1 Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisa
Implement sym operands for global_asm!

Tracking issue: #93333

This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
  - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
  - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
  - On Mach-O, all symbols have a leading underscore.
  - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
  - No mangling is needed on other platforms.

r? `@nagisa`
cc `@eddyb`
2022-04-16 04:46:01 +00:00
Dylan DPC
fa281fdf65
Rollup merge of #96065 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nested-blocks, r=compiler-errors
Refactor: Use `format-args-capture` and remove unnecessary nested blocks in rustc_typeck
2022-04-15 20:50:52 +02:00
Dylan DPC
937b0a04cd
Rollup merge of #96027 - matthiaskrgr:clippy_rec, r=fee1-dead
remove function parameters only used in recursion
2022-04-15 20:50:48 +02:00
Dylan DPC
ba9c3a13ee
Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPC
couple of clippy::complexity fixes
2022-04-15 20:50:47 +02:00
Dylan DPC
747829428b
Rollup merge of #95749 - compiler-errors:ambig, r=oli-obk
only downgrade selection Error -> Ambiguous if type error is in predicate

That is, we don't care if there's a TypeError type in the ParamEnv.

Fixes #95408
2022-04-15 20:50:46 +02:00
Dylan DPC
bdbf0998f3
Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelix
remove find_use_placement

A more robust solution to finding where to place use suggestions was added in #94584.
The algorithm uses the AST to find the span for the suggestion so we pass this span
down to the HIR during lowering and use it instead of calling `find_use_placement`

Fixes #94941
2022-04-15 20:50:45 +02:00
Dylan DPC
a32e0f3041
Rollup merge of #94849 - ouz-a:master4, r=oli-obk
Check var scope if it exist

Fixes #92893.

Added helper function to check the scope of a variable, if it doesn't have a scope call delay_span_bug, which avoids us trying to get a block/scope that doesn't exist.

Had to increase `ROOT_ENTRY_LIMIT` was getting tidy error
2022-04-15 20:50:44 +02:00
Dylan DPC
20bf34f8c5
Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix
Create (unstable) 2024 edition

[On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition.

This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024.

For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical.

````@rustbot```` label +T-lang +S-waiting-on-review

Not sure on the relevant team, to be honest.
2022-04-15 20:50:43 +02:00
Dylan DPC
27e2d811e6
Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwco
Stabilize `derive_default_enum`

This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility).

```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-15 20:50:43 +02:00
Jeremy Fitzhardinge
1be1157d75 Remove --extern-location and all associated code
`--extern-location` was an experiment to investigate the best way to
generate useful diagnostics for unused dependency warnings by enabling a
build system to identify the corresponding build config.

While I did successfully use this, I've since been convinced the
alternative `--json unused-externs` mechanism is the way to go, and
there's no point in having two mechanisms with basically the same
functionality.

This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-15 11:19:06 -07:00
Amanieu d'Antras
547405e801 Add codegen for global_asm! sym operands 2022-04-15 14:36:30 +01:00
Takayuki Maeda
f9188ccef6 use format-args-capture and remove unnecessary nested block 2022-04-15 15:56:32 +09:00
Ralf Jung
1a6c2ff4fd make unaligned_reference warning visible in future compat report 2022-04-14 22:15:56 -04:00
Ralf Jung
e30d6d9096 make unaligned_references lint deny-by-default 2022-04-14 21:16:42 -04:00
Andy Russell
219d81f19b
separate flock implementations into separate modules 2022-04-14 18:30:53 -04:00
ouz-a
c20bb1d59f Update issue-92893.stderr 2022-04-14 23:42:15 +03:00
b-naber
d8205cd3fe handle arrays and slices uniformly in valtree creation 2022-04-14 22:01:40 +02:00
Vadim Petrochenkov
5bee741a08 library: Move CStr to libcore, and CString to liballoc 2022-04-14 21:53:11 +03:00
Eduardo Sánchez Muñoz
c58af72a03 Add additional extract_field / project_field to take into account extra level of struct nesting. 2022-04-14 19:35:40 +02:00
bors
e7575f9670 Auto merge of #95315 - compiler-errors:pointee-fix, r=pnkfelix
when checking pointee metadata, canonicalize the `Sized` check

Use `infcx.predicate_must_hold_modulo_regions` with a `Sized` obligation instead of just calling `ty.is_sized`, because the latter does not canonicalize region and type vars (and in the test case I added in this PR, there's a region var in the `ParamEnv`).

Fixes #95311
2022-04-14 14:37:34 +00:00
Amanieu d'Antras
dc345d8bff Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
Oli Scherer
48029aba2c Remove some now-dead code that was only relevant before deaggregation.
The code was broken anyway, if the deaggregator is disabled, it would have ICE on any non-enum Adt
2022-04-14 13:31:21 +00:00
rainy-me
1b7008dc77 refactor: change to use peekable 2022-04-14 21:18:27 +09:00
Matthias Krüger
6511976515 remove redundant function param in check_for_self_assign_helper() 2022-04-14 11:55:37 +02:00
Matthias Krüger
15abc81967 remove reudndant function param in check_matcher_core() 2022-04-14 11:55:35 +02:00
Matthias Krüger
75287dd73d remove function param that is only used in recursive of fn inner() 2022-04-14 11:54:28 +02:00
bors
f9d4d12b6a Auto merge of #95928 - nnethercote:rm-TokenTree-Clone, r=petrochenkov
Remove `<mbe::TokenTree as Clone>`

`mbe::TokenTree` doesn't really need to implement `Clone`, and getting rid of that impl leads to some speed-ups.

r? `@petrochenkov`
2022-04-14 06:36:04 +00:00
bors
f387c930ee Auto merge of #95981 - martingms:invert-line-offset-parsing, r=nnethercote
Optimize `<SourceFile as Decodable>::decode`

It showed up as a hot-ish function in a callgrind profile of the `await-call-tree` benchmark crate.

Provides some moderate speedups to compilation of some of the smaller benchmarks:

#### Primary benchmarks

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
helloworld | check | full | -1.81% | 9.03x
helloworld | check | incr-unchanged | -1.80% | 8.99x
helloworld | check | incr-full | -1.59% | 7.97x
helloworld | check | incr-patched: println | -1.57% | 7.86x

#### Secondary benchmarks
<div class="category-title"></div>

Benchmark | Profile | Scenario | % Change | Significance Factor?
-- | -- | -- | -- | --
unify-linearly | check | incr-unchanged | -1.55% | 7.74x
unify-linearly | check | incr-patched: dummy fn | -1.42% | 7.08x
await-call-tree | check | incr-unchanged | -1.27% | 6.35x
await-call-tree | debug | incr-unchanged | -1.19% | 5.95x
await-call-tree | opt | incr-unchanged | -1.19% | 5.94x
issue-46449 | check | incr-unchanged | -1.08% | 5.39x
issue-46449 | check | incr-patched: u8 3072 | -1.00% | 5.00x
structopt-0.3.26 | check | incr-unchanged | -0.94% | 4.72x
structopt-0.3.26 | opt | incr-unchanged | -0.92% | 4.60x
structopt-0.3.26 | debug | incr-unchanged | -0.92% | 4.59x
issue-46449 | check | full | -0.89% | 4.46x
structopt-0.3.26 | check | full | -0.83% | 4.17x
structopt-0.3.26 | debug | full | -0.78% | 3.88x
structopt-0.3.26 | opt | full | -0.76% | 3.81x
unify-linearly | check | full | -0.75% | 3.74x
projection-caching | check | incr-unchanged | -0.74% | 3.70x
issue-46449 | check | incr-patched: u32 3072 | -0.70% | 3.50x
issue-46449 | check | incr-patched: empty 3072 | -0.68% | 3.41x
structopt-0.3.26 | check | incr-full | -0.68% | 3.40x
wf-projection-stress-65510 | check | incr-unchanged | -0.68% | 3.39x
issue-46449 | check | incr-patched: static str 6144 | -0.67% | 3.37x
wf-projection-stress-65510 | debug | incr-unchanged | -0.67% | 3.33x
wf-projection-stress-65510 | opt | incr-unchanged | -0.66% | 3.31x
issue-46449 | check | incr-patched: io error 6144 | -0.66% | 3.29x
unify-linearly | check | incr-full | -0.65% | 3.26x
issue-46449 | check | incr-full | -0.65% | 3.25x
structopt-0.3.26 | debug | incr-full | -0.64% | 3.18x
structopt-0.3.26 | opt | incr-full | -0.63% | 3.17x
issue-46449 | debug | incr-unchanged | -0.61% | 3.06x
issue-46449 | opt | incr-unchanged | -0.61% | 3.03x
await-call-tree | check | full | -0.60% | 2.99x
issue-88862 | check | incr-unchanged | -0.58% | 2.91x
deep-vector | debug | full | 0.57% | 2.83x
await-call-tree | check | incr-full | -0.52% | 2.59x
tt-muncher | opt | full | -0.52% | 2.58x
issue-58319 | check | incr-unchanged | -0.50% | 2.52x
await-call-tree | debug | full | -0.50% | 2.49x
await-call-tree | opt | full | -0.49% | 2.45x
deep-vector | debug | incr-patched: println | 0.47% | 2.37x
await-call-tree | debug | incr-full | -0.45% | 2.26x
await-call-tree | opt | incr-full | -0.44% | 2.18x
issue-88862 | check | full | -0.41% | 2.06x
mockall-0.11.0 | check | incr-unchanged | -0.38% | 1.90x
regression-31157 | check | incr-unchanged | -0.37% | 1.86x
wf-projection-stress-65510 | opt | full | -0.36% | 1.80x
deunicode-1.3.1 | check | incr-unchanged | -0.35% | 1.76x
unify-linearly | debug | incr-patched: dummy fn | -0.35% | 1.74x
mockall-0.11.0 | check | full | -0.35% | 1.73x
unify-linearly | debug | incr-unchanged | -0.34% | 1.69x
deunicode-1.3.1 | check | full | -0.33% | 1.63x
token-stream-stress | check | full | -0.32% | 1.62x
token-stream-stress | check | incr-full | -0.32% | 1.59x
token-stream-stress | check | incr-unchanged | -0.32% | 1.59x
regression-31157 | check | incr-patched: println | -0.31% | 1.57x
wf-projection-stress-65510 | check | full | -0.31% | 1.54x
deeply-nested-multi | check | incr-unchanged | -0.31% | 1.53x
mockall-0.11.0 | opt | incr-unchanged | -0.30% | 1.50x

r? `@nnethercote`
2022-04-13 23:18:33 +00:00
Nicholas Nethercote
dd9028a8c4 mbe::TokenTree: remove Lrc around Delimited and SequenceRepetition. 2022-04-14 09:01:27 +10:00
Nicholas Nethercote
75fd391aaa Introduce TtHandle and use it in TokenSet.
This removes the last use of `<mbe::TokenTree as Clone>`. It also
removes two trivial methods on `Delimited`.
2022-04-14 09:01:23 +10:00
Isak Nyberg
53b2aca9da Refactor loop into iterator; simplify negation logic. 2022-04-14 00:22:08 +02:00
bors
34a6c9f26e Auto merge of #95968 - davidtwco:translation-lazy-fallback, r=oli-obk
errors: lazily load fallback fluent bundle

Addresses (hopefully) https://github.com/rust-lang/rust/pull/95667#issuecomment-1094794087.

Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required.

r? `@ghost` (just for perf initially)
2022-04-13 21:04:19 +00:00
Matthias Krüger
7c2d57e0fa couple of clippy::complexity fixes 2022-04-13 22:51:34 +02:00
Matthias Krüger
bbd7ce6904 couple of clippy::perf fixes 2022-04-13 22:18:28 +02:00
rainy-me
4a0f8d5175 improve diagnostics for unterminated nested block comment 2022-04-14 03:22:02 +09:00
Dylan DPC
648d65ac7b
Rollup merge of #95991 - PoorlyDefinedBehaviour:fix/issue_95898, r=fee1-dead
fix: wrong trait import suggestion for T:

The suggestion to bound `T` had an extra `:`.

```rust
fn foo<T:>(t: T) {
  t.clone();
}
```

```
error[E0599]: no method named `clone` found for type parameter `T` in the current scope
 --> src/lib.rs:2:7
  |
2 |     t.clone();
  |       ^^^^^ method not found in `T`
  |
  = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `clone`, perhaps you need to restrict type parameter `T` with it:
  |
1 | fn foo<T: Clone:>(t: T) {
  |        ~~~~~~~~
 ```

Fixes: #95898
2022-04-13 17:35:34 +02:00
Aaron Hill
002a4e1bd5
Remove last vestiges of skippng ident span hashing
This removes a comment that no longer applies, and properly hashes
the full ident for path segments.
2022-04-13 11:25:22 -04:00
Bruno Felipe Francisco
9b9f677104 fix: wrong trait import suggestion for T: 2022-04-13 11:02:01 -03:00
Martin Gammelsæter
692bba64e6 Inline Const::ty() and Const::val() getters 2022-04-13 14:10:37 +02:00
bors
f38c5c8e5d Auto merge of #95656 - cjgillot:no-id-hashing-mode, r=Aaron1011
Remove NodeIdHashingMode.

r? `@ghost`
2022-04-13 11:27:17 +00:00
Jakob Degen
d5f3863204 Consider lifetimes when comparing types for equality in MIR validator 2022-04-13 05:51:08 -04:00
bors
e3c43e64ec Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obk
Use mir constant in thir instead of ty::Const

This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
2022-04-13 07:50:56 +00:00
Martin Gammelsæter
5f2c6b92d1 Use .extend(..) instead of push()-ing in loop
A bit less readable but more compact, and maybe faster? We'll see.
2022-04-13 08:44:20 +02:00
David Wood
9bfe0e39e4 errors: lazily load fallback fluent bundle
Loading the fallback bundle in compilation sessions that won't go on to
emit any errors unnecessarily degrades compile time performance, so
lazily create the Fluent bundle when it is first required.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-13 02:44:59 +01:00
Nicholas Nethercote
2657d8f7b3 Pass a slice instead of a Vec to transcribe.
It avoids some unnecessary allocations.
2022-04-13 11:17:31 +10:00
Nicholas Nethercote
1a7006482e Avoid use of Lrc in mbe::Frame.
This is a nice performance win on some crates.
2022-04-13 11:17:31 +10:00
Nicholas Nethercote
769e2edb78 SequenceRepetition and Delimited don't need to be Clone. 2022-04-13 11:17:31 +10:00
Vadim Petrochenkov
233fa659f4 rustc_metadata: Do not encode unnecessary module children 2022-04-13 01:35:27 +03:00
Dylan DPC
e96304b73d
Rollup merge of #95973 - oli-obk:tait_ub3, r=compiler-errors
prevent opaque types from appearing in impl headers

cc `@lqd`

opaque types are not distinguishable from their hidden type at the codegen stage. So we could either end up with cases where the hidden type doesn't implement the trait (which will thus ICE) or where the hidden type does implement the trait (so we'd be using its impl instead of the one written for the opaque type). This can even lead to unsound behaviour without unsafe code.

Fixes https://github.com/rust-lang/rust/issues/86411.
Fixes https://github.com/rust-lang/rust/issues/84660.

rebase of #87382 plus some diagnostic tweaks
2022-04-12 23:17:01 +02:00
Dylan DPC
d63a46ad28
Rollup merge of #95970 - WaffleLapkin:nicer_trait_suggestions, r=compiler-errors
Fix suggestions in case of `T:` bounds

This PR fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions.

For the following functions:
```rust
fn a<T:>(t: T) { [t, t]; }
fn b<T>(t: T) where T: { [t, t]; }
```

We previously suggested the following:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy:>(t: T) { [t, t]; }
  |       ++++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: + Copy { [t, t]; }
  |                        ++++++
```

Note that neither `T: Copy:` not `where T: + Copy` is a correct bound.

With this commit the suggestions are correct:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy>(t: T) { [t, t]; }
  |         ++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: Copy { [t, t]; }
  |                        ++++
```

r? `@compiler-errors`

I've tried fixing #95898 here too, but got too confused with how `suggest_traits_to_import` works and what it does 😅
2022-04-12 23:17:00 +02:00
Dylan DPC
91813a7175
Rollup merge of #95918 - compiler-errors:issue-95878, r=cjgillot
Delay a bug when we see SelfCtor in ref pattern

Fixes #95878
2022-04-12 23:16:59 +02:00