about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2022-08-29Rollup merge of #101131 - RalfJung:ctfe-no-needs-rfc, r=oli-obkMatthias Krüger-18/+11
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-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-29Only normalize once in mir validator typecheckerNilstrieb-15/+10
Before, it called `normalize_erasing_regions` twice since `equal_up_to_regions` called it as well for both types.
2022-08-29Try normalizing types without RevealAll in ParamEnv in mir validationNilstrieb-8/+20
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-29interpret: fix unnecessary allocation in validation visitorRalf Jung-4/+5
2022-08-29Rollup merge of #100239 - RalfJung:const-prop-uninit, r=oli-obkDylan DPC-25/+9
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-29Rollup merge of #100897 - RalfJung:const-not-to-mutable, r=lcnrMatthias Krüger-27/+45
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-29Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obkMatthias Krüger-11/+11
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-28entirely get rid of NeedsRfc CTFE errorsRalf Jung-15/+5
2022-08-28CTFE: exposing pointers and calling extern fn doesn't need an RFC, it is ↵Ralf Jung-3/+6
just impossible
2022-08-28validation should only catch UB errorsRalf Jung-17/+20
2022-08-28Rollup merge of #101038 - RalfJung:interning-alignment, r=oli-obkMatthias Krüger-3/+5
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-27interpret: make read-pointer-as-bytes *always* work in MiriRalf Jung-47/+64
and show some extra information when it happens in CTFE
2022-08-27interpret: rename relocation → provenanceRalf Jung-25/+25
2022-08-27Auto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3bors-6/+4
Shrink `FnAbi` Because they can take up a lot of memory in debug and release builds. r? `@bjorn3`
2022-08-27remove a now-useless machine hookRalf Jung-24/+5
2022-08-27remove an ineffective check in const_propRalf Jung-1/+4
2022-08-27Auto merge of #101064 - compiler-errors:rollup-fwm5m5f, r=compiler-errorsbors-113/+171
Rollup of 9 pull requests Successful merges: - #100724 (Migrate ast lowering to session diagnostic) - #100735 (Migrate `rustc_ty_utils` to `SessionDiagnostic`) - #100738 (Diagnostics migr const eval) - #100744 (Migrate rustc_mir_dataflow to diagnostic structs) - #100776 (Migrate `rustc_lint` errors to `SessionDiagnostic`) - #100817 (sugg: suggest the usage of boolean value when there is a typo in the keyword) - #100836 (Migrate `rustc_attr` crate diagnostics) - #100890 (Migrate rustc_driver to SessionDiagnostic) - #100900 (on `region_errors.rs`) Failed merges: - #100831 (Migrate `symbol_mangling` module to new diagnostics structs) r? `@ghost` `@rustbot` modify labels: rollup
2022-08-26Rollup merge of #100738 - nidnogg:diagnostics_migr_const_eval, r=davidtwcoMichael Goulet-113/+171
Diagnostics migr const eval This PR should eventually contain all diagnostic migrations for the `rustc_const_eval` crate. r? `@davidtwco` `@rustbot` label +A-translation
2022-08-26make read_immediate error immediately on uninit, so ImmTy can carry ↵Ralf Jung-264/+175
initialized Scalar
2022-08-26remove some now-unnecessary parameters from check_bytesRalf Jung-12/+3
2022-08-26remove enforce_number_init machine hook that Miri no longer needsRalf Jung-24/+8
2022-08-26fix an outdated machine hook nameRalf Jung-7/+7
2022-08-26Replace `Body::basic_blocks()` with field accessTomasz Miąsko-11/+11
2022-08-26no alignment check during interningRalf Jung-3/+5
2022-08-26Move `ArgAbi::pad_i32` into `PassMode::Cast`.Nicholas Nethercote-4/+2
Because it's only needed for that variant. This shrinks the types and clarifies the logic.
2022-08-26Turn `ArgAbi::pad` into a `bool`.Nicholas Nethercote-1/+1
Because it's only ever set to `None` or `Some(Reg::i32())`.
2022-08-26Box `CastTarget` within `PassMode`.Nicholas Nethercote-2/+2
Because `PassMode::Cast` is by far the largest variant, but is relatively rare. This requires making `PassMode` not impl `Copy`, and `Clone` is no longer necessary. This causes lots of sigil adjusting, but nothing very notable.
2022-08-25Auto merge of #100571 - cjgillot:mir-cost-visit, r=compiler-errorsbors-16/+14
Check projection types before inlining MIR Fixes https://github.com/rust-lang/rust/issues/100550 I'm very unhappy with this solution, having to duplicate MIR validation code, but at least it removes the ICE. r? `@compiler-errors`
2022-08-23extra sanity check against consts pointing to mutable memoryRalf Jung-27/+45
2022-08-22Addressing tidy check failnidnogg-2/+7
2022-08-22Addressing last comment on PR reviewnidnogg-4/+4
2022-08-22Switched errors to diags according to latest PRsnidnogg-12/+12
2022-08-21Hotfix ftl err name, added check for err.code in create_feature_errnidnogg-1/+1
2022-08-21Fixed failing tests (missing labels), added automatic error code in ↵nidnogg-18/+11
create_feature_err() builder
2022-08-21Added several more migrations under ops.rs, failing some tests thoughnidnogg-97/+138
2022-08-21Migration on ops.rs for unstable const functionsnidnogg-5/+11
2022-08-21Migrated Unallowed function pointer calls in interpreter/opsnidnogg-5/+10
2022-08-21Finished const_eval module migration, moving onto sibling foldersnidnogg-6/+14
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