Commit graph

1218 commits

Author SHA1 Message Date
Camille Gillot
3f32738628
Update compiler/rustc_middle/src/query/mod.rs 2021-06-05 20:40:58 +02:00
Camille GILLOT
507a1fdf13 Always go through the expn_that_defined query. 2021-06-04 21:37:34 +02:00
Yuki Okushi
2fddcfda7a
Rollup merge of #85934 - tmiasko:is-union, r=jackh726
Add `Ty::is_union` predicate
2021-06-03 14:35:41 +09:00
Yuki Okushi
a5466fc5ad
Rollup merge of #85911 - cjgillot:one-output, r=Aaron1011
Avoid a clone of output_filenames.

Part of #85153
2021-06-03 14:35:39 +09:00
Camille GILLOT
0e71283495 Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
2021-06-02 18:35:32 +02:00
Tomasz Miąsko
c898681a86 Add Ty::is_union predicate and use it 2021-06-02 17:09:17 +02:00
Tomasz Miąsko
012c323467 Implement Ty::is_enum using matches! 2021-06-02 17:09:13 +02:00
bors
1e13a9bb33 Auto merge of #85892 - tmiasko:i, r=oli-obk
Miscellaneous inlining improvements
2021-06-02 10:47:58 +00:00
bors
7350f655ef Auto merge of #85908 - cjgillot:private-dep-query, r=Aaron1011
Make is_private_dep a query.

Part of #85153

r? `@Aaron1011`
2021-06-02 08:06:45 +00:00
Tomasz Miąsko
c1f6495b8e Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
bors
d20b9add05 Auto merge of #85905 - cjgillot:one-trait-map, r=Aaron1011
Only compute the trait map once

Part of #85153

r? `@Aaron1011`
2021-06-02 05:25:41 +00:00
bors
625d5a693e Auto merge of #85829 - bjorn3:simplify_crate_num, r=jackh726
Remove CrateNum::ReservedForIncrCompCache

It's only use is easily replaceable with `Option<CrateNum>`.
2021-06-01 20:09:03 +00:00
Camille GILLOT
ba0ac88cd5 Avoid a clone of output_filenames. 2021-06-01 21:22:55 +02:00
Camille GILLOT
28afaeec17 Make is_private_dep a query. 2021-06-01 21:03:55 +02:00
Camille GILLOT
273778086c Remove StableVec. 2021-06-01 20:53:04 +02:00
Camille GILLOT
e291be3649 Only compute the trait_map once. 2021-06-01 20:43:50 +02:00
Camille Gillot
0f0f3138cb
Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
bors
41278062c8 Auto merge of #85153 - cjgillot:qresolve, r=Aaron1011
Reduce the amount of untracked state in TyCtxt

Access to untracked global state may generate instances of #84970.

The GlobalCtxt contains the lowered HIR, the resolver outputs and interners.
By wrapping the resolver inside a query, we make sure those accesses are properly tracked.
As a no_hash query, all dependent queries essentially become `eval_always`,
what they should have been from the beginning.
2021-06-01 00:51:00 +00:00
bors
d9feaaa548 Auto merge of #85704 - Aaron1011:const-panic-hard-err, r=RalfJung
Emit a hard error when a panic occurs during const-eval

Previous, a panic during const evaluation would go through the
`const_err` lint. This PR ensures that such a panic always causes
compilation to fail.
2021-05-31 12:41:55 +00:00
bors
91ddf3e76a Auto merge of #85266 - cjgillot:hir-dep-clean, r=michaelwoerister
Remove obsolete workaround.

The regression test for #62649 appears to pass even without the workaround.
2021-05-31 10:13:46 +00:00
Camille GILLOT
2543028161 Drop metadata_encoding_version. 2021-05-30 20:05:46 +02:00
Camille GILLOT
1119b48e02 Correct comments about untracked accesses. 2021-05-30 20:04:37 +02:00
Camille GILLOT
f0e5e22806 Make is_private_dep a query. 2021-05-30 20:04:22 +02:00
Camille GILLOT
ee94fbb607 Make allocator_kind a query. 2021-05-30 19:58:01 +02:00
Camille GILLOT
e1e6949558 Avoid a clone of output_filenames. 2021-05-30 19:57:13 +02:00
Camille GILLOT
ee567fe1b1 Remove StableVec. 2021-05-30 19:54:21 +02:00
Camille GILLOT
10fb4b2fe5 Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
2021-05-30 19:54:04 +02:00
Camille GILLOT
5d9f96ab27 Make resolutions a query. 2021-05-30 19:47:00 +02:00
Camille GILLOT
139f7ad637 Only compute the trait_map once. 2021-05-30 19:37:53 +02:00
Aaron Hill
2779fc1c47
Emit a hard error when a panic occurs during const-eval
Previous, a panic during const evaluation would go through the
`const_err` lint. This PR ensures that such a panic always causes
compilation to fail.
2021-05-30 11:59:54 -05:00
bjorn3
1ef98856c7 Remove CrateNum::ReservedForIncrCompCache 2021-05-30 14:33:16 +02:00
bjorn3
d0ec85d3fb Merge CrateDisambiguator into StableCrateId 2021-05-30 12:51:34 +02:00
bors
9a72afa7dd Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrum
Make `Step` trait safe to implement

This PR makes a few modifications to the `Step` trait that I believe better position it for stabilization in the short term. In particular,

1. `unsafe trait TrustedStep` is introduced, indicating that the implementation of `Step` for a given type upholds all stated invariants (which have remained unchanged). This is gated behind a new `trusted_step` feature, as stabilization is realistically blocked on min_specialization.
2. The `Step` trait is internally specialized on the `TrustedStep` trait, which avoids a serious performance regression.
3. `TrustedLen` is implemented for `T: TrustedStep` as the latter's invariants subsume the former's.
4. The `Step` trait is no longer `unsafe`, as the invariants must not be relied upon by unsafe code (unless the type implements `TrustedStep`).
5. `TrustedStep` is implemented for all types that implement `Step` in the standard library and compiler.
6. The `step_trait_ext` feature is merged into the `step_trait` feature. I was unable to find any reasoning for the features being split; the `_unchecked` methods need not necessarily be stabilized at the same time, but I think it is useful to have them under the same feature flag.

All existing implementations of `Step` will be broken, as it is not possible to `unsafe impl` a safe trait. Given this trait only exists on nightly, I feel this breakage is acceptable. The blanket `impl<T: Step> TrustedLen for T` will likely cause some minor breakage, but this should be covered by the equivalent impl for `TrustedStep`.

Hopefully these changes are sufficient to place `Step` in decent position for stabilization, which would allow user-defined types to be used with `a..b` syntax.
2021-05-30 01:21:39 +00:00
Camille GILLOT
4f8e34cbf8 Merge fields and comment. 2021-05-28 21:14:11 +02:00
bors
0e44ca6dba Auto merge of #85789 - ptrojahn:generator_typo, r=nagisa
Fix typo
2021-05-28 17:44:47 +00:00
bors
ce0d64e03e Auto merge of #85546 - hyd-dev:unwind, r=RalfJung
const-eval: disallow unwinding across functions that `!fn_can_unwind()`

Following https://github.com/rust-lang/miri/pull/1776#discussion_r633074343, so r? `@RalfJung`

This PR turns `unwind` in `StackPopCleanup::Goto` into a new enum `StackPopUnwind`, with a `NotAllowed` variant to indicate that unwinding is not allowed. This variant is chosen based on `rustc_middle::ty::layout::fn_can_unwind()` in `eval_fn_call()` when pushing the frame. A check is added in `unwind_to_block()` to report UB if unwinding happens across a `StackPopUnwind::NotAllowed` frame.

Tested with Miri `HEAD` with [minor changes](https://github.com/rust-lang/miri/compare/HEAD..9cf3c7f0d86325a586fbcbf2acdc9232b861f1d8) and the rust-lang/miri#1776 branch with [these changes](d866c1c52f..626638fbfe).
2021-05-28 08:49:48 +00:00
bors
d854c3c0e9 Auto merge of #85729 - LeSeulArtichaut:thir-no-hash, r=nikomatsakis
Don't hash `thir_body`

Experiment to see if/how much this helps negate the perf impact of #85273.
r? `@ghost`
2021-05-27 15:46:48 +00:00
Niko Matsakis
9385be7a0c
Update compiler/rustc_middle/src/query/mod.rs
Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
2021-05-27 10:31:47 -04:00
Dylan DPC
e7c9469786
Rollup merge of #85583 - cjgillot:no-previous-dg, r=petrochenkov
Get rid of PreviousDepGraph.

Its only role is to access the `SerializedDepGraph`.
2021-05-27 03:02:09 +02:00
Jacob Pratt
bc2f0fb5a9
Specialize implementations
Implementations in stdlib are now optimized as they were before.
2021-05-26 18:07:09 -04:00
LeSeulArtichaut
fdc15ef823 Don't hash thir_body 2021-05-26 22:34:42 +02:00
Paul Trojahn
119bff1247 Fix typo 2021-05-26 19:19:47 +02:00
Dylan DPC
4b0014e3bb
Rollup merge of #85633 - lqd:stackless_span_stacks, r=oli-obk
Post-monomorphization errors traces MVP

This PR works towards better diagnostics for the errors encountered in #85155 and similar.

We can encounter post-monomorphization errors (PMEs) when collecting mono items. The current diagnostics are confusing for these cases when they happen in a dependency (but are acceptable when they happen in the local crate).

These kinds of errors will be more likely now that `stdarch` uses const generics for its intrinsics' immediate arguments, and validates these const arguments with a mechanism that triggers such PMEs.

(Not to mention that the errors happen during codegen, so only when building code that actually uses these code paths. Check builds don't trigger them, neither does unused code)

So in this PR, we detect these kinds of errors during the mono item graph walk: if any error happens while collecting a node or its neighbors, we print a diagnostic about the current collection step, so that the user has at least some context of which erroneous code and dependency triggered the error.

The diagnostics for issue #85155 now have this note showing the source of the erroneous const argument:
```
note: the above error was encountered while instantiating `fn std::arch::x86_64::_mm_blend_ps::<51_i32>`
  --> issue-85155.rs:11:24
   |
11 |         let _blended = _mm_blend_ps(a, b, 0x33);
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
```

Note that #85155 is a reduced version of a case happening in the wild, to indirect users of the `rustfft` crate, as seen in https://github.com/ejmahler/RustFFT/issues/74. The crate had a few of these out-of-range immediates. Here's how the diagnostics in this PR would have looked on one of its examples before it was fixed:

<details>

```
error[E0080]: evaluation of constant value failed
 --> ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
8 |         assert!(IMM >= MIN && IMM <= MAX, "IMM value not in expected range");
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'IMM value not in expected range', ./stdarch/crates/core_arch/src/macros.rs:8:9
  |
  = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

note: the above error was encountered while instantiating `fn _mm_blend_ps::<51_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1314:23
     |
1314 |         let blended = _mm_blend_ps(rows[0], rows[2], 0x33);
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

note: the above error was encountered while instantiating `fn _mm_permute_pd::<5_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1859:9
     |
1859 |         _mm_permute_pd(self, 0x05)
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

note: the above error was encountered while instantiating `fn _mm_permute_pd::<15_i32>`
    --> /tmp/RustFFT/src/avx/avx_vector.rs:1863:32
     |
1863 |         (_mm_movedup_pd(self), _mm_permute_pd(self, 0x0F))
     |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
error: could not compile `rustfft`

To learn more, run the command again with --verbose.
```

</details>

I've developed and discussed this with them, so maybe r? `@oli-obk` -- but feel free to redirect to someone else of course.

(I'm not sure we can say that this PR definitely closes issue 85155, as it's still unclear exactly which diagnostics and information would be interesting to report in such cases -- and we've discussed printing backtraces before. I have prototypes of some complete and therefore noisy backtraces I showed Oli, but we decided to not include them in this PR for now)
2021-05-26 13:32:08 +02:00
Rémy Rakic
d14dd9f763 emit diagnostic after post-monomorphization errors
Emit a diagnostic when the monomorphized item collector
encounters errors during a step of the recursive item collection.

These post-monomorphization errors otherwise only show the
erroneous expression without a trace, making them very obscure
and hard to pinpoint whenever they happen in dependencies.
2021-05-25 18:39:50 +02:00
Guillaume Gomez
aa8c37d2c9
Rollup merge of #85650 - scottmcm:adjust-adjustment-docs, r=jyn514
Add some backticks to the `rustc_middle::ty::adjustment::Adjustment` docs

A few `[i32]`s are getting picked up as intra-doc links, rather than showing as slices, making the sentence quite confusing.

See https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/adjustment/struct.Adjustment.html
2021-05-25 13:05:16 +02:00
Guillaume Gomez
ad72247833
Rollup merge of #85605 - ptrojahn:closure_struct, r=matthewjasper
Replace Local::new(1) with CAPTURE_STRUCT_LOCAL
2021-05-25 13:05:14 +02:00
bors
a7890c7952 Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrum
Bump bootstrap compiler to beta 1.53.0

This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected).

The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html).

r? `@Mark-Simulacrum`
2021-05-25 05:48:00 +00:00
bors
d568d63b1f Auto merge of #85273 - LeSeulArtichaut:thir-query, r=nikomatsakis
Make building THIR a stealable query

This PR creates a stealable `thir_body` query so that we can build the THIR only once for THIR unsafeck and MIR build.

Blocked on #83842.
r? `@nikomatsakis`
2021-05-25 03:07:03 +00:00
Scott McMurray
bc2c3dca55 Add some backticks to the rustc_middle::ty::adjustment::Adjustment docs
A few `[i32]`s are getting picked up as intra-doc links, rather than showing as slices, making the sentence quite confusing.
2021-05-24 15:47:28 -07:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00