Commit Graph

686 Commits

Author SHA1 Message Date
bors
c524c7dd25 Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
Use only ty::Unevaluated<'tcx, ()> in type system

r? `@lcnr`
2022-09-17 03:04:22 +00:00
b-naber
6af8fb7936 address review again 2022-09-14 17:30:25 +02:00
Eric Holk
cf04547b0b Address code review comments 2022-09-13 14:50:12 -07:00
b-naber
29c0364c37 rebase 2022-09-13 17:48:05 +02:00
b-naber
a7735cd329 fixes/working version 2022-09-13 17:41:02 +02:00
b-naber
a4bbb8db5c use ty::Unevaluated<'tcx, ()> in type system 2022-09-13 17:40:59 +02:00
Michael Goulet
b2ed2dcaae Rename some variants 2022-09-12 16:55:59 -07:00
Michael Goulet
12ec2f0e34 Construct dyn* during const interp 2022-09-12 16:55:59 -07:00
Eric Holk
549c105bb3 dyn* through more typechecking and MIR 2022-09-12 16:55:56 -07:00
Eric Holk
6c01273a15 Plumb dyn trait representation through ty::Dynamic 2022-09-12 16:55:55 -07:00
bors
5197c96c49 Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead
The `<*const T>::guaranteed_*` methods now return an option for the unknown case

cc https://github.com/rust-lang/rust/issues/53020#issuecomment-1236932443

I chose `0` for "not equal" and `1` for "equal" and left `2` for the unknown case so backends can just forward to raw pointer equality and it works 

r? `@fee1-dead` or `@lcnr`

cc `@rust-lang/wg-const-eval`
2022-09-10 09:50:21 +00:00
Oli Scherer
f632dbe46f The <*const T>::guaranteed_* methods now return an option for the unknown case 2022-09-09 15:16:04 +00:00
bors
1120c5e01d Auto merge of #101437 - compiler-errors:erase-normalize-ordering, r=tmandry
Normalize before erasing late-bound regions in `equal_up_to_regions`

Normalize erasing regions **first**, before passing the type through a `BottomUpFolder` which erases late-bound regions too.

The root cause of this issue is due to 96d4137dee, which removes a `normalize_erasing_regions` that happens before this call to `equal_up_to_regions`. While reverting that commit might be a fix, I think it was suspicious to be erasing late-bound regions first _then_ normalizing types in the first place in `equal_up_to_regions`.

-----

I am tempted to ask the reviewer to review and `r+` this without a UI test, since the existing issues that I think this fixes are all incredibly difficult to minimize (anything hyper/warp related, given the nature of those libraries 😓) or impossible to reproduce locally (the miri test), namely:
* This recently reported issue with tokio + warp: #101430
* This issue from `@RalfJung` about Miri being broken: #101344
* This additional issue reported in a comment by `@tmandry` (issue with fuchsia + hyper): https://github.com/rust-lang/rust/issues/101344#issuecomment-1235974564

I have locally verified that the repro in #101430 is fixed with this PR, but after a couple of hours of attempting to minimize this error and either failing to actually repro the ICE, or being overwhelmed with the number of traits and functions I need to inline into a UI test, I have basically given up. Thoughts are appreciated on how best to handle this.

r? `@oli-obk` who is at the intersection of MIR and types-related stuff who may be able to give advice 😅
2022-09-08 19:01:39 +00:00
lcnr
e6660326a3 bound variables during ctfe are a bug 2022-09-08 11:41:00 +02:00
Michael Benfield
d7a750b504 Use niche-filling optimization even when multiple variants have data.
Fixes #46213
2022-09-07 20:12:45 +00:00
Michael Benfield
1a08b96a0b Change name of "dataful" variant to "untagged"
This is in anticipation of a new enum layout, in which the niche
optimization may be applied even when multiple variants have data.
2022-09-07 20:12:45 +00:00
Oli Scherer
104f97e5aa Move CTFE handling of nondiverging intrinsics to intrinsics.rs 2022-09-06 14:18:32 +00:00
Oli Scherer
b7413511dc Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
3f07645120 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
Yuki Okushi
957b44a13c
Rollup merge of #101402 - saethlin:inline-asm-hook, r=oli-obk
Add a Machine hook for inline assembly

I'm sketching out some support in Miri to "execute" inline assembly. I want this because there are codebases which have very simple inline assembly like hand-written syscall wrappers, and it would be nice to test such code without modification.

r? ``@oli-obk``
2022-09-06 08:36:04 +09:00
Michael Goulet
76b494a9dd Normalize before erasing late-bound regions in equal_up_to_regions 2022-09-05 06:44:33 +00:00
Deadbeef
075084f772 Make const_eval_select a real intrinsic 2022-09-04 20:35:23 +08:00
Ben Kimock
563a75b6e3 Add a Machine hook for inline assembly 2022-09-03 18:05:02 -04:00
bors
06b72b06a2 Auto merge of #101154 - RalfJung:validation-perf, r=oli-obk
interpret: fix unnecessary allocation in validation visitor

Should fix the perf regression introduced by https://github.com/rust-lang/rust/pull/100043.

r? `@oli-obk`
2022-09-03 09:20:54 +00:00
Matthias Krüger
938897e2e4
Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obk
Try normalizing types without RevealAll in ParamEnv in MIR validation

Before, the MIR validator used RevealAll in its ParamEnv for type
checking. This could cause false negatives in some cases due to
RevealAll ParamEnvs not always use all predicates as expected here.

Since some MIR passes like inlining use RevealAll as well, keep using
it in the MIR validator too, but when it fails usign RevealAll, also
try the check without it, to stop false negatives.

Fixes #99866

cc ````````@compiler-errors```````` who nicely helped me on zulip
2022-09-02 18:21:58 +02:00
Oli Scherer
1fc9ef1edd tracing::instrument cleanup 2022-09-01 14:54:27 +00:00
Oli Scherer
d3b22c7267 Directly use the instrument macro instead of its full path 2022-09-01 14:53:46 +00:00
bors
b32223fec1 Auto merge of #100707 - dzvon:fix-typo, r=davidtwco
Fix a bunch of typo

This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-09-01 05:39:58 +00:00
Ralf Jung
d814d10069 interpret: use new OpTy::len for Len rvalue
This avoids a `force_allocation`
2022-08-31 15:22:44 +02:00
Dezhi Wu
b1430fb7ca Fix a bunch of typo
This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos
2022-08-31 18:24:55 +08:00
bors
f07d6e8c0a Auto merge of #99102 - JakobDegen:reorder-generators, r=oli-obk
Rework definition of MIR phases to more closely reflect semantic concerns

Implements most of rust-lang/compiler-team#522 .

I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.
2022-08-30 23:43:33 +00:00
Jakob Degen
aad14c701e Refactor MIR phases 2022-08-30 01:40:14 -07:00
bors
0631ea5d73 Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #95376 (Add `vec::Drain{,Filter}::keep_rest`)
 - #100092 (Fall back when relating two opaques by substs in MIR typeck)
 - #101019 (Suggest returning closure as `impl Fn`)
 - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`)
 - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information)
 - #101123 (Remove `register_attr` feature)
 - #101175 (Don't --bless in pre-push hook)
 - #101176 (rustdoc: remove unused CSS selectors for `.table-display`)
 - #101180 (Add another MaybeUninit array test with const)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-30 08:29:42 +00:00
Dylan DPC
81f3841cfb
Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk
interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``
2022-08-30 11:26:51 +05:30
bors
a0d07093f8 Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrum
Revert let_chains stabilization

This is the revert against master, the beta revert was already done in #100538.

Bumps the stage0 compiler which already has it reverted.
2022-08-30 05:48:22 +00:00
bors
9f4d5d2a28 Auto merge of #101167 - matthiaskrgr:rollup-yt3jdmp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #100898 (Do not report too many expr field candidates)
 - #101056 (Add the syntax of references to their documentation summary.)
 - #101106 (Rustdoc-Json: Retain Stripped Modules when they are imported, not when they have items)
 - #101131 (CTFE: exposing pointers and calling extern fn is just impossible)
 - #101141 (Simplify `get_trait_ref` fn used for `virtual_function_elimination`)
 - #101146 (Various changes to logging of borrowck-related code)
 - #101156 (Remove `Sync` requirement from lint pass objects)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-29 22:49:04 +00:00
Matthias Krüger
cd53b4dba5
Rollup merge of #101131 - RalfJung:ctfe-no-needs-rfc, r=oli-obk
CTFE: exposing pointers and calling extern fn is just impossible

The remaining "needs RFC" errors are just needlessly confusing, I think -- time to get rid of that error variant. They are anyway only reachable with miri-unleashed (if at all).

r? `@oli-obk`
2022-08-29 21:12:57 +02:00
Nilstrieb
d1ef8180f9 Revert let_chains stabilization
This reverts commit 3266460749.

This is the revert against master, the beta revert was already done in #100538.
2022-08-29 19:34:11 +02:00
Nilstrieb
96d4137dee Only normalize once in mir validator typechecker
Before, it called `normalize_erasing_regions` twice since
`equal_up_to_regions` called it as well for both types.
2022-08-29 16:29:53 +02:00
Nilstrieb
81a583c21e Try normalizing types without RevealAll in ParamEnv in mir validation
Before, the MIR validator used RevealAll in its ParamEnv for type
checking. This could cause false negatives in some cases due to
RevealAll ParamEnvs not always use all predicates as expected here.

Since some MIR passes like inlining use RevealAll as well, keep using
it in the MIR validator too, but when it fails usign RevealAll, also
try the check without it, to stop false negatives.
2022-08-29 16:27:52 +02:00
Ralf Jung
8b53abd602 interpret: fix unnecessary allocation in validation visitor 2022-08-29 08:05:20 -04:00
Dylan DPC
3ea5456366
Rollup merge of #100239 - RalfJung:const-prop-uninit, r=oli-obk
remove an ineffective check in const_prop

Based on https://github.com/rust-lang/rust/pull/100043, only the last two commits are new.

ConstProp has a special check when reading from a local that prevents reading uninit locals. However, if that local flows into `force_allocation`, then no check fires and evaluation proceeds. So this check is not really effective at preventing accesses to uninit locals.

With https://github.com/rust-lang/rust/pull/100043, `read_immediate` and friends always fail when reading uninit locals, so I don't see why ConstProp would need a separate check. Thus I propose we remove it. This is needed to be able to do https://github.com/rust-lang/rust/pull/100085.
2022-08-29 16:49:40 +05:30
Matthias Krüger
d814fdd3f9
Rollup merge of #100897 - RalfJung:const-not-to-mutable, r=lcnr
extra sanity check against consts pointing to mutable memory

This should be both unreachable and redundant (since we already ensure that validation only reads from read-only memory, when validating consts), but I feel like we cannot be paranoid enough here, and also if this ever fails it'll be a nicer error than the "cannot read from mutable memory" error.
2022-08-29 06:34:46 +02:00
Matthias Krüger
d182081de1
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
2022-08-29 06:34:43 +02:00
Ralf Jung
f29c3c421b entirely get rid of NeedsRfc CTFE errors 2022-08-28 13:40:24 -04:00
Ralf Jung
a9f9145b09 CTFE: exposing pointers and calling extern fn doesn't need an RFC, it is just impossible 2022-08-28 13:32:48 -04:00
Ralf Jung
1a1220c5e4 validation should only catch UB errors 2022-08-28 11:49:32 -04:00
Matthias Krüger
5b8081490f
Rollup merge of #101038 - RalfJung:interning-alignment, r=oli-obk
no alignment check during interning

This should fix https://github.com/rust-lang/rust/issues/101034
r? `@oli-obk`

Unfortunately we don't have a self-contained testcase for this problem. I am not sure how it can be triggered...
2022-08-28 09:35:19 +02:00
Ralf Jung
2e172473da interpret: make read-pointer-as-bytes *always* work in Miri
and show some extra information when it happens in CTFE
2022-08-27 18:37:44 -04:00
Ralf Jung
e63a625711 interpret: rename relocation → provenance 2022-08-27 14:11:19 -04:00