about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2022-08-21fix ICE with extra-const-ub-checksRalf Jung-7/+33
2022-08-21Also validate types before inlining.Camille GILLOT-16/+14
2022-08-21Replace #[lint/warning/error] with #[diag]Xiretza-9/+9
2022-08-20Rollup merge of #100507 - cameron1024:suggest-lazy, r=compiler-errorsMatthias Krüger-0/+5
suggest `once_cell::Lazy` for non-const statics Addresses https://github.com/rust-lang/rust/issues/100410 Some questions: - removing the `if` seems to include too many cases (e.g. calls to non-const functions inside a `const fn`), but this code excludes the following case: ```rust const FOO: Foo = non_const_fn(); ``` Should we suggest `once_cell` in this case as well? - The original issue mentions suggesting `AtomicI32` instead of `Mutex<i32>`, should this PR address that as well?
2022-08-19Rollup merge of #100208 - RalfJung:dyn-upcast-nop, r=petrochenkovDylan DPC-1/+6
make NOP dyn casts not require anything about the vtable As suggested [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/dyn-upcasting.20stabilization/near/292151439). This matches what the codegen backends already do, and what Miri did do until https://github.com/rust-lang/rust/pull/99420 when I made it super extra paranoid.
2022-08-17Rollup merge of #99972 - RalfJung:1zst, r=lcnrMatthias Krüger-1/+3
interpret: only consider 1-ZST when searching for receiver `repr(transparent)` currently entirely rejects ZST with alignment larger than 1 (which is odd, arguably [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=02870f29396fa948c3123cb53d869ad1) should be accepted), so this should be safe. And if it ever isn't safe then that is very likely a bug elsewhere in the compiler.
2022-08-16Rollup merge of #100600 - saethlin:rename-memory-hooks, r=RalfJungMatthias Krüger-8/+14
Rename Machine memory hooks to suggest when they run Some of the other memory hooks start with `before_` or `after_` to indicate that they run before or after a certain operation. These don't, so I was a bit confused as to when they are supposed to run. `memory_read` can be read two ways in English, "memory was read" or "this is a memory read" so without the prefix this was especially ambiguous.
2022-08-15Rename Machine memory hooks to suggest when they runBen Kimock-8/+14
2022-08-14suggest lazy-static for non-const staticscameron-0/+5
2022-08-13Rollup merge of #100438 - compiler-errors:issue-100360, r=lcnrMichael Goulet-7/+2
Erase regions better in `promote_candidate` Use `tcx.erase_regions` instead of manually walking through the substs.... this also makes the code slightly simpler :see_no_evil: Fixes #100360 Fixes #89851
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-12Rollup merge of #100229 - RalfJung:extra-const-ub-checks, r=lcnrDylan DPC-12/+14
add -Zextra-const-ub-checks to enable more UB checking in const-eval Cc https://github.com/rust-lang/rust/issues/99923 r? `@oli-obk`
2022-08-12Erase regions better in promote_candidateMichael Goulet-7/+2
2022-08-11Rollup merge of #100391 - nnethercote:improve-size-assertions, r=lqdDylan DPC-9/+11
Improve size assertions r? `@lqd`
2022-08-10Avoid repeating qualifiers on `static_assert_size` calls.Nicholas Nethercote-9/+11
Some of these don't need a `use` statement because there is already a `#[macro_use] extern crate rustc_data_structures` item in the crate.
2022-08-09dont rely on old macro-in-trait-impl bugRalf Jung-12/+0
2022-08-09Rollup merge of #100181 - RalfJung:alloc-ref-mutability, r=jackh726Dylan DPC-0/+7
add method to get the mutability of an AllocId Miri needs this for https://github.com/rust-lang/miri/issues/2463.
2022-08-07add -Zextra-const-ub-checks to enable more UB checking in const-evalRalf Jung-0/+14
2022-08-06make NOP dyn casts not require anything about the vtableRalf Jung-1/+6
2022-08-06Auto merge of #99743 - compiler-errors:fulfillment-context-cleanups, r=jackh726bors-10/+2
Some `FulfillmentContext`-related cleanups Use `ObligationCtxt` in some places, remove some `FulfillmentContext`s in others... r? types
2022-08-05add method to get the mutability of an AllocIdRalf Jung-0/+7
2022-08-04Rollup merge of #100095 - jackh726:early-binder, r=lcnrMatthias Krüger-2/+2
More EarlyBinder cleanups Each commit is independent r? types
2022-08-04Add `traits::fully_solve_obligation` that acts like `traits::fully_normalize`Michael Goulet-10/+2
It spawns up a trait engine, registers the single obligation, then fully solves it
2022-08-03Rollup merge of #99746 - compiler-errors:more-trait-engine, r=jackh726Matthias Krüger-2/+2
Use `TraitEngine` in more places that don't specifically need `FulfillmentContext::new_in_snapshot` Not sure if this change is worthwhile, but couldn't hurt re: chalkification r? types
2022-08-03Auto merge of #100064 - RalfJung:disaligned, r=petrochenkovbors-16/+12
fix is_disaligned logic for nested packed structs https://github.com/rust-lang/rust/pull/83605 broke the `is_disaligned` logic by bailing out of the loop in `is_within_packed` early. This PR fixes that problem and adds suitable tests. Fixes https://github.com/rust-lang/rust/issues/99838
2022-08-03fix is_disaligned logic for nested packed structsRalf Jung-16/+12
2022-08-03Add bound_impl_subject and bound_return_tyJack Huey-2/+2
2022-08-01Remove trait_of_item query.Camille GILLOT-1/+1
2022-08-01Remove DefId from AssocItemContainer.Camille GILLOT-3/+6
2022-08-01Rollup merge of #100003 - nnethercote:improve-size-assertions, r=lqdMatthias Krüger-27/+23
Improve size assertions. - For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order. r? `@lqd`
2022-08-01Improve size assertions.Nicholas Nethercote-27/+23
- For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order.
2022-07-30interpret: only consider 1-ZST when searching for receiverRalf Jung-1/+3
2022-07-30Use LocalDefId for closures moreCameron Steffen-1/+1
2022-07-27Rollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, ↵Guillaume Gomez-1/+1
r=oli-obk Deeply deny fn and raw ptrs in const generics I think this is right -- just because we wrap a fn ptr in a wrapper type does not mean we should allow it in a const parameter. We now reject both of these in the same way: ``` #![feature(adt_const_params)] #[derive(Eq, PartialEq)] struct Wrapper(); fn foo<const W: Wrapper>() {} fn foo2<const F: fn()>() {} ``` This does regress one test (`src/test/ui/consts/refs_check_const_eq-issue-88384.stderr`), but I'm not sure it should've passed in the first place. cc: ``@b-naber`` who introduced that test^ fixes #99641
2022-07-26ICE on RawPtrComparison checkDeadbeef-4/+4
2022-07-26Rollup merge of #99692 - RalfJung:too-far, r=oli-obkDylan DPC-24/+48
interpret, ptr_offset_from: refactor and test too-far-apart check We didn't have any tests for the "too far apart" message, and indeed that check mostly relied on the in-bounds check and was otherwise probably not entirely correct... so I rewrote that check, and it is before the in-bounds check so we can test it separately.
2022-07-26Use TraitEngine in more places that don't specifically need ↵Michael Goulet-2/+2
FulfillmentCtxt::new_in_snapshot
2022-07-26Rollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obkYuki Okushi-2/+2
don't ICE on invalid dyn calls Due to https://github.com/rust-lang/rust/issues/50781 this is actually reachable. Fixes https://github.com/rust-lang/miri/issues/2432 r? ``@oli-obk``
2022-07-25Remove non-descriptive boolean from search_for_structural_match_violationMichael Goulet-1/+1
2022-07-25Deeply deny fn and raw ptrs in const genericsMichael Goulet-1/+1
2022-07-24interpret, ptr_offset_from: refactor and test too-far-apart checkRalf Jung-24/+48
2022-07-24don't ICE on invalid dyn callsRalf Jung-2/+2
2022-07-23now we can make scalar_to_ptr a method on ScalarRalf Jung-45/+23
2022-07-23remove some provenance-related machine hooks that Miri no longer needsRalf Jung-46/+17
2022-07-22interpret: fix vtable check debug assertionRalf Jung-2/+1
2022-07-20detect bad vptrs on dyn callsRalf Jung-15/+46
2022-07-20detect bad vtables on an upcastRalf Jung-2/+5
2022-07-20consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)Ralf Jung-12/+12
2022-07-20incorporate some review feedbackRalf Jung-28/+8
2022-07-20add intrinsic to access vtable size and alignRalf Jung-0/+12