Commit Graph

2036 Commits

Author SHA1 Message Date
bors
78fd0f633f Auto merge of #92244 - petrochenkov:alltraits, r=cjgillot
rustc_metadata: Encode list of all crate's traits into metadata

While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree.

This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-29 19:22:33 +00:00
Vadim Petrochenkov
90e371027e rustc_metadata: Encode list of all crate's traits into metadata 2021-12-28 19:31:51 +08:00
Krasimir Georgiev
9127f497be Bump gsgdt to 0.1.3
No functional changes intended.

The 0.1.2 -> 0.1.3 commit 3e1dcec539
renames `Node::new` to `Node::from_list`.
2021-12-24 13:46:37 +01:00
bors
59337cddd4 Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obk
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility

This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to
- determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI)
- impose further restrictions on whether caller and callee are consistent in how a given argument is passed

I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around.

I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;)
One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way.

r? `@oli-obk` `@eddyb`
Fixes https://github.com/rust-lang/rust/issues/56166
Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-24 04:59:05 +00:00
Matthias Krüger
8a61ae0479
Rollup merge of #92203 - Aaron1011:mir-adt-def, r=oli-obk
Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`

The `AggregateKind` enum ends up in the final mir `Body`. Currently,
any changes to `AdtDef` (regardless of how significant they are)
will legitimately cause the overall result of `optimized_mir` to change,
invalidating any codegen re-use involving that mir.

This will get worse once we start hashing the `Span` inside `FieldDef`
(which is itself contained in `AdtDef`).

To try to reduce these kinds of invalidations, this commit changes
`AggregateKind::Adt` to store just the `DefId`, instead of the full
`AdtDef`. This allows the result of `optimized_mir` to be unchanged
if the `AdtDef` changes in a way that doesn't actually affect any
of the MIR we build.
2021-12-23 17:48:31 +01:00
bors
c1d301bb29 Auto merge of #92167 - pierwill:chalk-update, r=jackh726
Update chalk to 0.75.0

- Compute flags in `intern_ty`
- Remove `tracing-serde` from `PERMITTED_DEPENDENCIES`
- Bump `tracing-tree` to 0.2.0
- Bump `tracing-subscriber` to 0.3.3
2021-12-23 08:59:55 +00:00
Aaron Hill
cac431ba75
Store a DefId instead of an AdtDef in AggregateKind::Adt
The `AggregateKind` enum ends up in the final mir `Body`. Currently,
any changes to `AdtDef` (regardless of how significant they are)
will legitimately cause the overall result of `optimized_mir` to change,
invalidating any codegen re-use involving that mir.

This will get worse once we start hashing the `Span` inside `FieldDef`
(which is itself contained in `AdtDef`).

To try to reduce these kinds of invalidations, this commit changes
`AggregateKind::Adt` to store just the `DefId`, instead of the full
`AdtDef`. This allows the result of `optimized_mir` to be unchanged
if the `AdtDef` changes in a way that doesn't actually affect any
of the MIR we build.
2021-12-22 14:36:34 -05:00
pierwill
8df9248591 Remove PartialOrd and Ord from LocalDefId
Implement `Ord`, `PartialOrd` for SpanData
2021-12-22 10:50:57 -06:00
pierwill
ea25b779eb Update chalk to 0.75.0
- Compute flags in `intern_ty`
- Remove tracing-serde from PERMITTED_DEPENDENCIES
- Disable `tracing-full` feature in `chalk-solve`
- Bump tracing-tree to 0.2.0
2021-12-22 10:07:44 -06:00
bors
8ad3c1dd1d Auto merge of #92149 - fee1-dead:cache-fix, r=oli-obk
Fix bad caching of `~const Drop` bounds

Fixes #92111.
2021-12-21 12:49:10 +00:00
Deadbeef
aaaad5b46b
Fix bad caching of ~const Drop bounds 2021-12-21 13:25:43 +08:00
Michael Goulet
c327627a68 Bail if printing item named _ in try_print_visible_def_path 2021-12-20 19:50:15 -08:00
Ralf Jung
56b7d5fc49 better name for AdjustForForeignAbiError error variant in InterpError 2021-12-20 22:37:15 +01:00
Ralf Jung
b815532674 try to fix ICE in fn_abi_of_instance 2021-12-20 22:37:14 +01:00
Ralf Jung
11fb22d83a CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility 2021-12-20 22:37:12 +01:00
bors
84f962a89b Auto merge of #91924 - Aaron1011:serialize-adt-def, r=michaelwoerister
Fully serialize AdtDef

This avoids needing to invoke the `adt_def` query during
the decoding of another query's result.

Split out from https://github.com/rust-lang/rust/pull/91919
See https://github.com/rust-lang/rust/issues/91696#issuecomment-993043710
2021-12-20 10:35:48 +00:00
Nicholas Nethercote
f09b1facd0 Eliminate ObligationCauseData.
This makes `Obligation` two words bigger, but avoids allocating a lot of
the time.

I previously tried this in #73983 and it didn't help much, but local
timings look more promising now.
2021-12-20 09:29:20 +11:00
bors
41c3017c82 Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts")
 - #91984 (Remove `in_band_lifetimes` from `rustc_middle`)
 - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets)
 - #92042 (Enable `#[thread_local]` for all windows-msvc targets)
 - #92071 (Update example code for Vec::splice to change the length)
 - #92077 (rustdoc: Remove unused `collapsed` field)
 - #92081 (rustdoc: Remove unnecessary `need_backline` function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-19 12:36:56 +00:00
Matthias Krüger
4d5ffc4870
Rollup merge of #91984 - Aaron1011:rustc-middle-lifetime, r=oli-obk
Remove `in_band_lifetimes` from `rustc_middle`

See #91867

This was mostly straightforward. In several places, I take advantage
of the fact that lifetimes are non-hygenic: a macro declares the
'tcx' lifetime, which is then used in types passed in as macro
arguments.
2021-12-19 10:45:51 +01:00
bors
a41a6925ba Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
Remove `SymbolStr`

This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.

Best reviewed one commit at a time.

r? `@oli-obk`
2021-12-19 09:31:37 +00:00
Matthias Krüger
6b62bf3814
Rollup merge of #91932 - Kixiron:randomize-seed, r=nagisa
Add user seed to `-Z randomize-layout`

Allows users of -`Z randomize-layout` to provide `-Z layout-seed=<seed>` in order to further randomizing type layout randomization. Extension of [compiler-team/#457](https://github.com/rust-lang/compiler-team/issues/457), allows users to change struct layouts without changing code and hoping that item path hashes change, aiding in detecting layout errors
2021-12-19 00:38:41 +01:00
Matthias Krüger
5e8f934149
Rollup merge of #92032 - petrochenkov:extblockpath, r=oli-obk
hir: Do not introduce dummy type names for `extern` blocks in def paths

Use a separate nameless `DefPathData` variant instead.

Extracted from https://github.com/rust-lang/rust/pull/91795.
2021-12-18 11:28:07 +01:00
Matthias Krüger
a391d545cf
Rollup merge of #92022 - woodenarrow:br_expected_bool, r=estebank
Eliminate duplicate codes of expected_found_bool

The function expected_found_bool is the same as ExpectedFound::new. So use ExpectedFound::new to replace expected_found_bool to eliminate duplicate codes.

![image](https://user-images.githubusercontent.com/95843988/146486722-c910eccd-a36c-4dc5-8b36-214aab058e38.png)
2021-12-18 11:28:06 +01:00
Vadim Petrochenkov
0d61852cc5 hir: Do not introduce dummy type names for extern blocks in def paths
Use a separate nameless `DefPathData` variant instead
2021-12-18 16:30:17 +08:00
Deadbeef
2f555dec4a
Add a temporary hack before env fix lands in bootstrap 2021-12-17 20:46:48 +08:00
lzh
a995462f9a Eliminate duplicate codes of expected_found_bool 2021-12-17 11:17:43 +08:00
bors
9b45f04414 Auto merge of #91672 - b-naber:merge-normalize-erasing-regions-queries, r=jackh726
Implement normalize_erasing_regions queries in terms of 'try' version

Attempt to lessen performance regression caused by https://github.com/rust-lang/rust/pull/91255

r? `@jackh726`
2021-12-17 02:03:10 +00:00
Aaron Hill
00ce6dc718
Only cache local adt_def results on disk
An `AdtDef` contains `Span`s, and we don't appear
to actually encode the `SourceFile` for foreign
spans in the incremental cache in some cases.
2021-12-16 18:32:00 -05:00
Aaron Hill
a5b3dfe453
Run x.py fmt 2021-12-15 19:50:43 -05:00
Aaron Hill
070bf94a6f
Remove in_band_lifetimes from rustc_middle
See #91867

This was mostly straightforward. In several places, I take advantage
of the fact that lifetimes are non-hygenic: a macro declares the
'tcx' lifetime, which is then used in types passed in as macro
arguments.
2021-12-15 19:50:43 -05:00
bors
69ac533527 Auto merge of #86986 - lcnr:simplify_type, r=nikomatsakis,oli-obk
extend `simplify_type`

might cause a slight perf inprovement and imo more accurately represents what types there are.

considering that I was going to use this in #85048 it seems like we might need this in the future anyways 🤷
2021-12-15 22:32:56 +00:00
Aaron Hill
70fba90412
Cache adt_def query result on disk 2021-12-15 17:01:09 -05:00
Aaron Hill
f5f90540c9
Fully serialize AdtDef
This avoids needing to invoke the `adt_def` query during
the decoding of another query's result.
2021-12-15 16:32:16 -05:00
Matthias Krüger
990cf5bca4
Rollup merge of #91920 - Aaron1011:pred-stable-cmp, r=oli-obk
Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp`

This avoids a needless query invocation
2021-12-15 10:57:04 +01:00
Matthias Krüger
b507174e82
Rollup merge of #91898 - compiler-errors:dont_suggest_closure_return_type, r=lcnr
Make `TyS::is_suggestable` check for non-suggestable types structually

Not sure if I went overboard checking substs in dyn types, etc. Let me know if I should simplify this function.

Fixes #91832
2021-12-15 10:57:00 +01:00
Matthias Krüger
9ca0bd518a
Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514
fix clippy::single_char_pattern perf findings
2021-12-15 10:56:58 +01:00
Nicholas Nethercote
b1c934ebb8 Remove unnecessary sigils around Ident::as_str() calls. 2021-12-15 17:32:42 +11:00
Nicholas Nethercote
056d48a2c9 Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
Nicholas Nethercote
8cddcd39ba Remove SymbolStr.
By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15 13:30:26 +11:00
Matthias Krüger
4e7497bda0
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15 01:28:08 +01:00
Matthias Krüger
272188eecd
Rollup merge of #90939 - estebank:wg-af-polish, r=tmandry
Tweak errors coming from `for`-loop, `?` and `.await` desugaring

 * Suggest removal of `.await` on non-`Future` expression
 * Keep track of obligations introduced by desugaring
 * Remove span pointing at method for obligation errors coming from desugaring
 * Point at called local sync `fn` and suggest making it `async`

```
error[E0277]: `()` is not a future
  --> $DIR/unnecessary-await.rs:9:10
   |
LL |     boo().await;
   |     -----^^^^^^ `()` is not a future
   |     |
   |     this call returns `()`
   |
   = help: the trait `Future` is not implemented for `()`
help: do not `.await` the expression
   |
LL -     boo().await;
LL +     boo();
   |
help: alternatively, consider making `fn boo` asynchronous
   |
LL | async fn boo () {}
   | +++++
```

Fix #66731.
2021-12-15 01:28:04 +01:00
PFPoitras
304ede6bcc Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
Chase Wilson
2af02abd93
Minor cleanup 2021-12-14 13:40:16 -06:00
Michael Goulet
f29fb4792b Make TyS::is_suggestable more structual 2021-12-14 11:32:06 -08:00
Chase Wilson
2b46c7c906
Added -Z layout_seed for allowing user-defined randomization seeds 2021-12-14 12:48:41 -06:00
Aaron Hill
4d1d66b812
Use tcx.def_path_hash in ExistentialPredicate.stable_cmp
This avoids a needless query invocation
2021-12-14 11:27:41 -05:00
lcnr
023b56572f add some comments 2021-12-14 13:32:42 +01:00
lcnr
992efa68b7 replace DefId with D in SimplifiedType 2021-12-14 13:32:42 +01:00
lcnr
dcd716fee2 extend simplify_type 2021-12-14 13:32:42 +01:00
Matthias Krüger
97e844a032 fix clippy::single_char_pattern perf findings 2021-12-14 12:40:28 +01:00