summaryrefslogtreecommitdiff
path: root/compiler/rustc_const_eval/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Auto merge of #102906 - nbdd0121:mir, r=wesleywiser,tmiaskobors2023-04-079-78/+74
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor unwind in MIR This makes unwinding from current `Option<BasicBlock>` into ```rust enum UnwindAction { Continue, Cleanup(BasicBlock), Unreachable, Terminate, } ``` cc `@JakobDegen` `@RalfJung` `@Amanieu`
| * Fix mir interp of `TerminatorKind::Terminate`Gary Guo2023-04-061-1/+2
| |
| * Fix toolsGary Guo2023-04-061-0/+1
| |
| * Address review feedbackGary Guo2023-04-061-15/+23
| |
| * Rename `Abort` terminator to `Terminate`Gary Guo2023-04-065-7/+10
| | | | | | | | | | | | Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
| * Add `UnwindAction::Terminate`Gary Guo2023-04-061-0/+3
| |
| * Add `UnwindAction::Unreachable`Gary Guo2023-04-065-47/+25
| | | | | | | | | | This also makes eval machine's `StackPopUnwind` redundant so that is replaced.
| * Refactor unwind from Option to a new enumGary Guo2023-04-065-21/+23
| |
* | Stabilize is_some_andJonas Platte2023-04-061-1/+0
|/
* Rollup merge of #109921 - compiler-errors:dyn-star-const-static, r=eholkYuki Okushi2023-04-061-1/+1
|\ | | | | | | | | | | | | | | | | | | Don't ICE when encountering `dyn*` in statics or consts Since we have properly implemented `dyn*` support in CTFE (#107728), let's not ICE here anymore. Fixes #105777 r? `@eholk`
| * dyn* is a valid constMichael Goulet2023-04-041-1/+1
| |
* | Rollup merge of #109938 - oli-obk:try_norm, r=compiler-errorsMichael Goulet2023-04-041-8/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | Move a const-prop-lint specific hack from mir interpret to const-prop-lint and make it fallible fixes #109743 This hack didn't need to live in the mir interpreter. For const-prop-lint it is entirely correct to avoid doing any const prop if normalization fails at this stage. Most likely we couldn't const propagate anything anyway, and if revealing was needed (so opaque types were involved), we wouldn't want to be too smart and leak the hidden type anyway.
| * | Move a const-prop-lint specific hack from mir interpret to const-prop-lint ↵Oli Scherer2023-04-041-8/+1
| |/ | | | | | | and make it fallible
* | Rollup merge of #109901 - cjgillot:validate-debuginfo, r=b-naberMichael Goulet2023-04-041-4/+39
|\ \ | |/ |/| | | Enforce VarDebugInfo::Place in MIR validation.
| * Enforce VarDebugInfo::Place in MIR validation.Camille GILLOT2023-04-031-4/+39
| |
* | Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray2023-04-021-3/+3
| | | | | | | | All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
* | Auto merge of #109849 - scottmcm:more-fieldidx-rebase, r=oli-obkbors2023-04-021-4/+5
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Use `FieldIdx` in various things related to aggregates Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`. Part 3/? of https://github.com/rust-lang/compiler-team/issues/606 [`IndexSlice`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_index/vec/struct.IndexVec.html#deref-methods-IndexSlice%3CI,+T%3E) was added in https://github.com/rust-lang/rust/pull/109787
| * | Use `FieldIdx` in various things related to aggregatesScott McMurray2023-04-011-4/+5
| | | | | | | | | | | | Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
* | | slighty simplify a few boolean expressions (clippy::nonminimal_bool)Matthias Krüger2023-04-011-2/+1
|/ /
* | Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors2023-03-311-0/+6
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
| * | A MIR transform that checks pointers are alignedBen Kimock2023-03-231-0/+6
| | |
* | | Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray2023-03-303-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
* | | Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3bors2023-03-291-0/+1
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support TLS access into dylibs on Windows This allows access to `#[thread_local]` in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it. `convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls. A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms. This fixes https://github.com/rust-lang/rust/issues/84933.
| * | Support TLS access into dylibs on WindowsJohn Kåre Alsaker2023-03-291-0/+1
| | |
* | | Rename `IndexVec::last` → `last_index`Scott McMurray2023-03-291-2/+2
|/ / | | | | | | | | | | | | | | As I've been trying to replace a `Vec` with an `IndexVec`, having `last` exist on both but returning very different types makes the transition a bit awkward -- the errors are later, where you get things like "there's no `ty` method on `mir::Field`" rather than a more localized error like "hey, there's no `last` on `IndexVec`". So I propose renaming `last` to `last_index` to help distinguish `Vec::last`, which returns an element, and `IndexVec::last_index`, which returns an index. (Similarly, `Iterator::last` also returns an element, not an index.)
* | Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnrbors2023-03-281-0/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a builtin `FnPtr` trait that is implemented for all function pointers r? `@ghost` Rebased version of https://github.com/rust-lang/rust/pull/99531 (plus adjustments mentioned in the PR). If perf is happy with this version, I would like to land it, even if the diagnostics fix in 9df8e1befb5031a5bf9d8dfe25170620642d3c59 only works for `FnPtr` specifically, and does not generally improve blanket impls.
| * | Add a builtin `FnPtr` traitlcnr2023-03-271-0/+1
| | |
* | | Move const trait bounds checks to MIR constckDeadbeef2023-03-281-25/+26
|/ / | | | | | | | | | | | | Fixes #109543. When checking paths in HIR typeck, we don't want to check for const predicates since all we want might just be a function pointer. Therefore we move this to MIR constck and check that bounds are met during MIR constck.
* | Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray2023-03-253-6/+6
| | | | | | | | | | | | Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
* | miri: fix raw pointer dyn receiversRalf Jung2023-03-241-1/+9
|/
* Add `CastKind::Transmute` to MIRScott McMurray2023-03-223-4/+43
| | | | | | Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
* Rollup merge of #109435 - oli-obk:🇨🇭🥚_copy_op, r=RalfJungDylan DPC2023-03-233-7/+8
|\ | | | | | | | | | | | | | | | | | | Detect uninhabited types early in const eval r? `@RalfJung` implements https://github.com/rust-lang/rust/pull/108442#discussion_r1143003840 this is a breaking change, as some UB during const eval is now detected instead of silently being ignored. Users can see this and other UB that may cause future breakage with `-Zextra-const-ub-checks` or just by running miri on their code, which sets that flag by default.
| * Detect uninhabited types early in const eval.Oli Scherer2023-03-211-2/+2
| |
| * Add a layout argument to `enforce_validity`.Oli Scherer2023-03-213-6/+7
| | | | | | | | This is in preparation of checking the validity only of certain types.
* | Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errorsbors2023-03-221-2/+5
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a general type system cleanup removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context. changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR. also removes some other small - and imo unnecessary - helpers. r? types
| * | remove some trait solver helperslcnr2023-03-211-2/+5
| |/ | | | | | | | | they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.
* | Use local key in providersMichael Goulet2023-03-213-4/+3
|/
* Rollup merge of #109307 - cjgillot:inline-location, r=compiler-errorsMatthias Krüger2023-03-201-1/+5
|\ | | | | | | | | | | Ignore `Inlined` spans when computing caller location. Fixes https://github.com/rust-lang/rust/issues/105538
| * Ignore `Inlined` spans when computing caller location.Camille GILLOT2023-03-181-1/+5
| |
* | Rollup merge of #109234 - tmiasko:overflow-checks, r=cjgillotMatthias Krüger2023-03-182-8/+4
|\ \ | |/ |/| | | | | | | | | | | Tweak implementation of overflow checking assertions Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times. r? `@cjgillot`
| * Tweak implementation of overflow checking assertionsTomasz Miąsko2023-03-162-8/+4
| | | | | | | | | | Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
* | Auto merge of #108944 - cjgillot:clear-local-info, r=oli-obkbors2023-03-163-4/+5
|\ \ | |/ |/| | | | | | | | | | | Wrap the whole LocalInfo in ClearCrossCrate. MIR contains a lot of information about locals. The primary purpose of this information is the quality of borrowck diagnostics. This PR aims to drop this information after MIR analyses are finished, ie. starting from post-cleanup runtime MIR.
| * Remove LocalKind::Var.Camille GILLOT2023-03-142-3/+4
| |
| * Wrap the whole LocalInfo in ClearCrossCrate.Camille GILLOT2023-03-141-1/+1
| |
* | Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiaskobors2023-03-151-9/+0
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | Implement checked Shl/Shr at MIR building. This does not require any special handling by codegen backends, as the overflow behaviour is entirely determined by the rhs (shift amount). This allows MIR ConstProp to remove the overflow check for constant shifts. ~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).` I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~ EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
| * Implement checked Shl/Shr at MIR building.Camille GILLOT2023-02-271-9/+0
| |
* | Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obkbors2023-03-121-17/+13
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strengthen state tracking in const-prop Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization. Behaviour changes: - const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen. - we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry. - the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
| * | Assume the frame has all the locals.Camille GILLOT2023-03-081-17/+13
| | |
* | | Simplify message pathsest312023-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
* | | Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgrbors2023-03-101-1/+1
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 9 pull requests Successful merges: - #108879 (Unconstrained terms should account for infer vars being equated) - #108936 (Rustdoc: don't hide anonymous reexport) - #108940 (Add myself to compiler reviewers list) - #108945 (Make some report and emit errors take DefIds instead of BodyIds) - #108946 (Document the resulting values produced when using `From<bool>` on floats) - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.) - #108960 (Remove `body_def_id` from `Inherited`) - #108963 (only call git on git checkouts during bootstrap) - #108964 (Fix the docs for pointer method with_metadata_of) Failed merges: - #108950 (Directly construct Inherited in typeck.) r? `@ghost` `@rustbot` modify labels: rollup