about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/interpret
AgeCommit message (Collapse)AuthorLines
2021-03-27Address more review commentsJoshua Nelson-0/+5
- Add back various diagnostic methods on `Session`. It seems unfortunate to duplicate these in so many places, but in the meantime, making the API inconsistent between `Session` and `Diagnostic` also seems unfortunate. - Add back TyCtxtAt methods These will hopefully be used in the near future. - Add back `with_const`, it would need to be added soon after anyway. - Add back `split()` and `get_mut()`, they're useful.
2021-03-27Address review commentsJoshua Nelson-0/+12
- Add back `HirIdVec`, with a comment that it will soon be used. - Add back `*_region` functions, with a comment they may soon be used. - Remove `-Z borrowck_stats` completely. It didn't do anything. - Remove `make_nop` completely. - Add back `current_loc`, which is used by an out-of-tree tool. - Fix style nits - Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
2021-03-27Remove (lots of) dead codeJoshua Nelson-28/+0
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-20extract `ConstKind::Unevaluated` into a structlcnr-1/+1
2021-03-19Auto merge of #82951 - sexxi-goose:wr-mir-replace-methods2, r=nikomatsakisbors-10/+13
Replace closures_captures and upvar_capture with closure_min_captures Removed all uses of closures_captures and upvar_capture and refactored code to work with closure_min_captures. This also involved removing functions that were no longer needed like the bridge. Closes https://github.com/rust-lang/project-rfc-2229/issues/18 r? `@nikomatsakis`
2021-03-18Replace closures_captures and upvar_capture with closure_min_capturesJennifer Wills-10/+13
make changes to liveness to use closure_min_captures use different span borrow check uses new structures rename to CapturedPlace stop using upvar_capture in regionck remove the bridge cleanup from rebase + remove the upvar_capture reference from mutability_errors.rs remove line from livenes test make our unused var checking more consistent update tests adding more warnings to the tests move is_ancestor_or_same_capture to rustc_middle/ty update names to reflect the closures add FIXME check that all captures are immutable borrows before returning add surrounding if statement like the original move var out of the loop and rename Co-authored-by: Logan Mosier <logmosier@gmail.com> Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2021-03-18Remove unwrap_none/expect_none from compiler/.Mara Bos-3/+11
2021-03-15s/ConstantSource/ConstantKind/Oli Scherer-3/+3
2021-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-15/+33
2021-03-12Implement valtreeOli Scherer-1/+1
valtree is a version of constants that is inherently safe to be used within types. This is in contrast to ty::Const which can have different representations of the same value. These representation differences can show up in hashing or equality comparisons, breaking type equality of otherwise equal types. valtrees do not have this problem.
2021-03-10Auto merge of #82982 - Dylan-DPC:rollup-mt497z7, r=Dylan-DPCbors-1/+4
Rollup of 9 pull requests Successful merges: - #81309 (always eagerly eval consts in Relate) - #82217 (Edition-specific preludes) - #82807 (rustdoc: Remove redundant enableSearchInput function) - #82924 (WASI: Switch to crt1-command.o to enable support for new-style commands) - #82949 (Do not attempt to unlock envlock in child process after a fork.) - #82955 (fix: wrong word) - #82962 (Treat header as first paragraph for shortened markdown descriptions) - #82976 (fix error message for copy(_nonoverlapping) overflow) - #82977 (Rename `Option::get_or_default` to `get_or_insert_default`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-10Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieubors-3/+3
Implement RFC 2945: "C-unwind" ABI ## Implement RFC 2945: "C-unwind" ABI This branch implements [RFC 2945]. The tracking issue for this RFC is #74990. The feature gate for the issue is `#![feature(c_unwind)]`. This RFC was created as part of the ffi-unwind project group tracked at rust-lang/lang-team#19. ### Changes Further details will be provided in commit messages, but a high-level overview of the changes follows: * A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`, and `Thiscall` variants, marking whether unwinding across FFI boundaries is acceptable. The cases where each of these variants' `unwind` member is true correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings introduced in RFC 2945 [3]. * This commit adds a `c_unwind` feature gate for the new ABI strings. Tests for this feature gate are included in `src/test/ui/c-unwind/`, which ensure that this feature gate works correctly for each of the new ABIs. A new language features entry in the unstable book is added as well. * We adjust the `rustc_middle::ty::layout::fn_can_unwind` function, used to compute whether or not a `FnAbi` object represents a function that should be able to unwind when `panic=unwind` is in use. * Changes are also made to `rustc_mir_build::build::should_abort_on_panic` so that the function ABI is used to determind whether it should abort, assuming that the `panic=unwind` strategy is being used, and no explicit unwind attribute was provided. [RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
2021-03-10fix error message for copy(_nonoverlapping) overflowRalf Jung-1/+4
2021-03-10fix copy_nonoverlappingRalf Jung-7/+8
2021-03-09rustc_target: add "unwind" payloads to `Abi`katelyn a. martin-3/+3
### Overview This commit begins the implementation work for RFC 2945. For more information, see the rendered RFC [1] and tracking issue [2]. A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`, and `Thiscall` variants, marking whether unwinding across FFI boundaries is acceptable. The cases where each of these variants' `unwind` member is true correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings introduced in RFC 2945 [3]. ### Feature Gate and Unstable Book This commit adds a `c_unwind` feature gate for the new ABI strings. Tests for this feature gate are included in `src/test/ui/c-unwind/`, which ensure that this feature gate works correctly for each of the new ABIs. A new language features entry in the unstable book is added as well. ### Further Work To Be Done This commit does not proceed to implement the new unwinding ABIs, and is intentionally scoped specifically to *defining* the ABIs and their feature flag. ### One Note on Test Churn This will lead to some test churn, in re-blessing hash tests, as the deleted comment in `src/librustc_target/spec/abi.rs` mentioned, because we can no longer guarantee the ordering of the `Abi` variants. While this is a downside, this decision was made bearing in mind that RFC 2945 states the following, in the "Other `unwind` Strings" section [3]: > More unwind variants of existing ABI strings may be introduced, > with the same semantics, without an additional RFC. Adding a new variant for each of these cases, rather than specifying a payload for a given ABI, would quickly become untenable, and make working with the `Abi` enum prone to mistakes. This approach encodes the unwinding information *into* a given ABI, to account for the future possibility of other `-unwind` ABI strings. ### Ignore Directives `ignore-*` directives are used in two of our `*-unwind` ABI test cases. Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases ignore architectures that do not support `stdcall` and `thiscall`, respectively. These directives are cribbed from `src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and `src/test/ui/extern/extern-thiscall.rs` for `thiscall`. This would otherwise fail on some targets, see: https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60 ### Footnotes [1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md [2]: https://github.com/rust-lang/rust/issues/74990 [3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2021-03-09Clean up todoskadmin-25/+8
Also add some span_bugs where it is unreachable
2021-03-09Switch to changing cp_non_overlap in tformkadmin-34/+34
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09Update craneliftkadmin-14/+22
2021-03-09Update interpret stepkadmin-3/+11
2021-03-09Update match brancheskadmin-0/+17
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
2021-03-09Rollup merge of #82841 - hvdijk:x32, r=joshtriplettMara Bos-8/+8
Change x64 size checks to not apply to x32. Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-06Change x64 size checks to not apply to x32.Harald van Dijk-8/+8
Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-05Shrink the size of Rvalue by 16 bytesOli Scherer-2/+2
2021-02-27Add a getter for Frame.locbjorn3-0/+10
This is necessary for Priroda.
2021-02-25Auto merge of #82338 - RalfJung:interp-error-allocs, r=oli-obkbors-8/+0
all InterpError allocate now, so adjust alloc-error-check Cc https://github.com/rust-lang/rust/pull/82116#discussion_r578310770 r? `@oli-obk`
2021-02-22New mir-opt pass to simplify gotos with const valuesSimon Vandel Sillesen-0/+1
Fixes #77355
2021-02-21rustc_mir: remove redundant wrapping of return type in numeric_intrinsic()Matthias Krüger-7/+3
2021-02-20Rollup merge of #82176 - RalfJung:mir-fn-ptr-pretty, r=oli-obkGuillaume Gomez-1/+1
fix MIR fn-ptr pretty-printing An uninitialized function pointer would get printed as `{{uninit fn()}` (notice the unbalanced parentheses), and a dangling fn ptr would ICE. This fixes both of that. However, I have no idea how to add tests for this. Also, I don't understand this MIR pretty-printing code. Somehow the print function `pretty_print_const_scalar` actually *returns* a transformed form of the const (but there is no doc comment explaining what is being returned); some match arms do `p!` while others do `self =`, and there's a wild mixture of `p!` and `write!`... all very mysterious and confusing.^^ r? ``@oli-obk``
2021-02-20all InterpError allocate now, so adjust alloc-error-checkRalf Jung-8/+0
2021-02-20Auto merge of #82124 - tmiasko:op-ty-ref, r=oli-obkbors-303/+346
Pass large interpreter types by reference, not value r? `@ghost`
2021-02-17remove useless ?s (clippy::needless_question_marks)Matthias Krüger-1/+1
Example code: ``` fn opts() -> Option<String> { let s: Option<String> = Some(String::new()); Some(s?) // this can just be "s" } ```
2021-02-17Reduce size of InterpErrorInfo to 8 bytesTomasz Miąsko-13/+16
2021-02-16./x.py fmtTomasz Miąsko-23/+31
2021-02-16Pass MPlaceTy by reference not valueTomasz Miąsko-59/+66
2021-02-16Pass ImmTy by reference not valueTomasz Miąsko-10/+10
2021-02-16Pass PlaceTy by reference not valueTomasz Miąsko-74/+78
2021-02-16Pass OpTy by reference not valueTomasz Miąsko-159/+159
2021-02-16Add size assertions for interpreter data structuresTomasz Miąsko-0/+24
2021-02-16fix MIR fn-ptr pretty-printingRalf Jung-1/+1
2021-02-16validation: fix invalid-fn-ptr error messageRalf Jung-1/+4
2021-02-13CTFE validation: catch ReadPointerAsBytes and better errorRalf Jung-13/+29
2021-02-11Auto merge of #81350 - tmiasko:instrument-debug, r=lcnrbors-1/+1
Reduce log level used by tracing instrumentation from info to debug Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`; one use was novel).
2021-01-31Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obkbors-0/+4
codegen: assume constants cannot fail to evaluate https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :) r? `@oli-obk`
2021-01-30codegen: assume constants cannot fail to evaluateRalf Jung-0/+4
also don't submit code to LLVM when the session has errors
2021-01-30Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-seYuki Okushi-2/+2
Stabilize `unsigned_abs` Resolves #74913. This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`. I have gone ahead and used this in a couple locations throughout the repository.
2021-01-28Auto merge of #81441 - tmiasko:ctfe-inline, r=oli-obkbors-0/+1
Try inlining trivial functions used by CTFE r? `@ghost`
2021-01-28Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakisYuki Okushi-9/+6
Refractor a few more types to `rustc_type_ir` In the continuation of #79169, ~~blocked on that PR~~. This PR: - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance` - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler. ~~I will split up that commit to make this easier to review and to have a better commit history.~~ EDIT: done, I split the PR in commits of 200-ish lines each r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-27Inline MemPlace::offsetTomasz Miąsko-0/+1
2021-01-27Rollup merge of #80900 - camelid:readpointerasbytes-ice, r=oli-obkYuki Okushi-1/+5
Fix ICE with `ReadPointerAsBytes` validation error Fixes #79690. r? ``````@oli-obk``````
2021-01-24Reduce log level used by tracing instrumentation from info to debugTomasz Miąsko-1/+1