about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret
AgeCommit message (Collapse)AuthorLines
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-5/+5
2022-02-25Rollup merge of #94343 - RalfJung:fn-ptr, r=oli-obkMatthias Krüger-28/+38
Miri fn ptr check: don't use conservative null check In https://github.com/rust-lang/rust/pull/94270 I used the wrong NULL check for function pointers: `memory.ptr_may_be_null` is conservative even on machines that support ptr-to-int casts, leading to false errors in Miri. This fixes that problem, and also replaces that foot-fun of a method with `scalar_may_be_null` which is never unnecessarily conservative. r? `@oli-obk`
2022-02-24Miri fn ptr check: don't use conservative null checkRalf Jung-28/+38
2022-02-24Auto merge of #94131 - Mark-Simulacrum:fmt-string, r=oli-obkbors-5/+5
Always format to internal String in FmtPrinter This avoids monomorphizing for different parameters, decreasing generic code instantiated downstream from rustc_middle -- locally seeing 7% unoptimized LLVM IR line wins on rustc_borrowck, for example. We likely can't/shouldn't get rid of the Result-ness on most functions, though some further cleanup avoiding fmt::Error where we now know it won't occur may be possible, though somewhat painful -- fmt::Write is a pretty annoying API to work with in practice when you're trying to use it infallibly.
2022-02-24Rollup merge of #94270 - RalfJung:fn-ptrs, r=oli-obkMatthias Krüger-13/+18
Miri: relax fn ptr check As discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/72#issuecomment-1025407536, the function pointer check done by Miri is currently overeager: contrary to our usual principle of only checking rather uncontroversial validity invariants, we actually check that the pointer points to a real function. So, this relaxes the check to what the validity invariant probably will be (and what the reference already says it is): the function pointer must be non-null, and that's it. The check that CTFE does on the final value of a constant is unchanged -- CTFE recurses through references, so it makes some sense to also recurse through function pointers. We might still want to relax this in the future, but that would be a separate change. r? `@oli-obk`
2022-02-23Miri: relax fn ptr checkRalf Jung-13/+18
2022-02-23Rollup merge of #94280 - tmiasko:should-print-region, r=oli-obkMatthias Krüger-1/+1
Rename `region_should_not_be_omitted` to `should_print_region` to avoid double negation
2022-02-23Rename `region_should_not_be_omitted` to `should_print_region`Tomasz Miąsko-1/+1
to avoid double negation
2022-02-22Miri: extend comments on downcast operationRalf Jung-2/+6
2022-02-21ScalarMaybeUninit is explicitly hexadecimal in its formattingRalf Jung-7/+7
2022-02-21Rollup merge of #94189 - GuillaumeGomez:scalar-lower-hex, r=RalfJungMatthias Krüger-1/+1
Implement LowerHex on Scalar to clean up their display in rustdoc Follow-up of https://github.com/rust-lang/rust/pull/94091. r? ````@RalfJung````
2022-02-21Rollup merge of #94143 - est31:let_else_const_eval, r=lcnrMatthias Krüger-91/+67
rustc_const_eval: adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles rustc_const_eval.
2022-02-21Fix typoest31-1/+1
Co-authored-by: lcnr <rust@lcnr.de>
2022-02-20Always format to internal String in FmtPrinterMark Rousskov-5/+5
This avoids monomorphizing for different parameters, decreasing generic code instantiated downstream from rustc_middle.
2022-02-20Implement LowerHex on Scalar to clean up their display in rustdocGuillaume Gomez-1/+1
2022-02-19rustc_const_eval: adopt let else in more placesest31-91/+67
2022-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-1/+1
2022-02-15Overhaul `Const`.Nicholas Nethercote-8/+8
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-6/+6
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-11use body.tainted_by_error to skip loading MIRMichael Goulet-17/+9
2022-02-11rework borrowck errors so that it's harder to not set taintedMichael Goulet-2/+4
2022-02-11skip const eval if we have an error in borrowckMichael Goulet-1/+5
2022-01-20update commentslcnr-1/+5
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-2/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-15initial revertEllen-8/+4
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-2/+0
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-3/+3
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-04rename StackPopClean::None to RootRalf Jung-6/+12
2022-01-03Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievinkMatthias Krüger-12/+1
Remove `NullOp::Box` Follow up of #89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely. r? `@jonas-schievink` `@rustbot` label T-compiler
2021-12-31Extend check for UnsafeCell in consts to cover unionsTomasz Miąsko-1/+8
A validity companion to changes from #90373.
2021-12-24Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obkbors-136/+209
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-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-2/+2
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-20better name for AdjustForForeignAbiError error variant in InterpErrorRalf Jung-1/+3
2021-12-20don't ICE on variadic function callsRalf Jung-2/+9
2021-12-20also compare ArgAttributesRalf Jung-29/+38
2021-12-20compare calling convention instead of call ABIRalf Jung-37/+9
2021-12-20CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibilityRalf Jung-107/+190
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
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-15miri: lift restriction on extern types being the only field in a structTomasz Miąsko-27/+11
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-14Rollup merge of #91856 - ouz-a:master, r=oli-obkMatthias Krüger-2/+3
Looser check for overflowing_binary_op Fix for issue #91636 tight check resulted in ICE, this makes the check a little looser. It seems `eq` allows comparing of `supertype` and `subtype` if `lhs = supertype` and `rhs = subtype` but not vice versa, is this intended behavior ?
2021-12-14comment updateouz-a-1/+1
2021-12-13Remove `in_band_lifetimes` from `rustc_const_eval`LegionMammal978-12/+13
See #91867 for more information.
2021-12-14Add regression test and commentouz-a-1/+2
2021-12-13formattingouz-a-1/+1
2021-12-13Looser check for binary_op_overflowouz-a-1/+1
2021-12-12Auto merge of #91549 - fee1-dead:const_env, r=spastorinobors-0/+1
Eliminate ConstnessAnd again Closes #91489. Closes #89432. Reverts #91491. Reverts #89450. r? `@spastorino`
2021-12-12Rollup merge of #91815 - RalfJung:span, r=oli-obkMatthias Krüger-2/+2
better span for unexpected normalization failure in CTFE engine No reason to use `DUMMY_SP` here.
2021-12-12Rollup merge of #91814 - japm48:spelling-fix, r=RalfJungMatthias Krüger-2/+2
doc: fix typo in comments `dereferencable -> dereferenceable` Fixes #91802.
2021-12-12Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"Deadbeef-0/+1
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.