summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/interpret
AgeCommit message (Collapse)AuthorLines
2024-06-05Don't walk the bodies of free constants for reachability.Oli Scherer-3/+23
2024-05-27miri: avoid making a full copy of all new allocationsRalf Jung-22/+21
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-2/+1
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-23Auto merge of #125434 - nnethercote:rm-more-extern-tracing, r=jackh726bors-3/+5
Remove more `#[macro_use] extern crate tracing` Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. Continuing the work from #124511 and #124914. r? `@jackh726`
2024-05-23Allow const eval failures if the cause is a type layout issueOli Scherer-0/+3
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-3/+5
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-2/+1
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-21interpret: make overflowing binops just normal binopsRalf Jung-6/+13
2024-05-13interpret: move error macros into error.rsRalf Jung-132/+126
2024-05-13Remove `extern crate rustc_middle` from `rustc_const_eval`.Nicholas Nethercote-11/+27
This requires exporting the interpreter macros so they can be used with `use crate::interpret::*`.
2024-05-09Remove `TinyList`.Nicholas Nethercote-9/+8
It is optimized for lists with a single element, avoiding the need for an allocation in that case. But `SmallVec<[T; 1]>` also avoids the allocation, and is better in general: more standard, log2 number of allocations if the list exceeds one item, and a much more capable API. This commit removes `TinyList` and converts the two uses to `SmallVec<[T; 1]>`. It also reorders the `use` items in the relevant file so they are in just two sections (`pub` and non-`pub`), ordered alphabetically, instead of many sections. (This is a relevant part of the change because I had to decide where to add a `use` item for `SmallVec`.)
2024-05-03remove trait bounds on AllocBytesStrophox-3/+1
2024-05-03Cow::from(&*...) changed to Cow::Owned(Vec::from(...))Strophox-1/+1
2024-05-03generalize adjust_from_tcxStrophox-4/+4
2024-04-29Remove `extern crate rustc_data_structures` from numerous crates.Nicholas Nethercote-2/+3
2024-04-29Remove `extern crate rustc_macros` from `rustc_middle`.Nicholas Nethercote-4/+7
2024-04-21Miri: detect wrong vtables in wide pointersRalf Jung-21/+78
2024-04-19Auto merge of #124113 - RalfJung:interpret-scalar-ops, r=oli-obkbors-11/+13
interpret: use ScalarInt for bin-ops; avoid PartialOrd for ScalarInt Best reviewed commit-by-commit r? `@oli-obk`
2024-04-19ScalarInt: add methods to assert being a (u)int of given sizeRalf Jung-2/+2
2024-04-18interpret/binary_int_op: avoid dropping to raw ints until we determined the signRalf Jung-10/+12
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-2/+2
We want to run them on all 64-bit platforms.
2024-04-03Check `x86_64` size assertions on `aarch64`, tooZalathar-2/+2
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
2024-03-26Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJungbors-0/+2
Print a backtrace in const eval if interrupted Demo: ```rust #![feature(const_eval_limit)] #![const_eval_limit = "0"] const OW: u64 = { let mut res: u64 = 0; let mut i = 0; while i < u64::MAX { res = res.wrapping_add(i); i += 1; } res }; fn main() { println!("{}", OW); } ``` ``` ╭ ➜ ben@archlinux:~/rust ╰ ➤ rustc +stage1 spin.rs ^Cerror[E0080]: evaluation of constant value failed --> spin.rs:8:33 | 8 | res = res.wrapping_add(i); | ^ Compilation was interrupted note: erroneous constant used --> spin.rs:15:20 | 15 | println!("{}", OW); | ^^ note: erroneous constant used --> spin.rs:15:20 | 15 | println!("{}", OW); | ^^ | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. ```
2024-03-22Rollup merge of #122537 - RalfJung:interpret-allocation, r=oli-obkMatthias Krüger-11/+31
interpret/allocation: fix aliasing issue in interpreter and refactor getters a bit That new raw getter will be needed to let Miri pass pointers to natively executed FFI code ("extern-so" mode). While doing that I realized our get_bytes_mut are named less scary than get_bytes_unchecked so I rectified that. Also I realized `mem_copy_repeatedly` would break if we called it for multiple overlapping copies so I made sure this does not happen. And I realized that we are actually [violating Stacked Borrows in the interpreter](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/I.20think.20Miri.20violates.20Stacked.20Borrows.20.F0.9F.99.88).^^ That was introduced in https://github.com/rust-lang/rust/pull/87777. r? ```@oli-obk```
2024-03-20Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obkMatthias Krüger-2/+2
various clippy fixes We need to keep the order of the given clippy lint rules before passing them. Since clap doesn't offer any useful interface for this purpose out of the box, we have to handle it manually. Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well. Fixes #121481 cc `@matthiaskrgr`
2024-03-20resolve clippy errorsonur-ozkan-2/+2
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-03-18Avoid various uses of `Option<Span>` in favor of using `DUMMY_SP` in the few ↵Oli Scherer-8/+8
cases that used `None`
2024-03-17Print a backtrace in const eval if interruptedBen Kimock-0/+2
2024-03-15interpret/allocation: fix aliasing issue in interpreter and refactor getters ↵Ralf Jung-11/+31
a bit - rename mutating functions to be more scary - add a new raw bytes getter
2024-03-14Add compiler support for parsing `f16` and `f128`Trevor Gross-1/+21
2024-03-12Ensure nested allocations in statics do not get deduplicatedOli Scherer-1/+11
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-10/+10
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-4/+2
2024-02-29Rollup merge of #121782 - RalfJung:mutable-ref-in-static, r=oli-obkMatthias Krüger-1/+0
allow statics pointing to mutable statics Fixes https://github.com/rust-lang/rust/issues/120450 for good. We can even simplify our checks: no need to specifically go looking for mutable references in const, we can just reject any reference that points to something mutable. r? `@oli-obk`
2024-02-29allow statics pointing to mutable staticsRalf Jung-1/+0
2024-02-28Auto merge of #121489 - nnethercote:diag-renaming, r=davidtwcobors-8/+8
Diagnostic renaming Renaming various diagnostic types from `Diagnostic*` to `Diag*`. Part of https://github.com/rust-lang/compiler-team/issues/722. There are more to do but this is enough for one PR. r? `@davidtwco`
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-8/+8
2024-02-27Split rustc_type_ir to avoid rustc_ast from depending on itOli Scherer-1/+1
2024-02-16Rollup merge of #121179 - RalfJung:zst-mutable-refs, r=oli-obkGuillaume Gomez-4/+5
allow mutable references in const values when they point to no memory Fixes https://github.com/rust-lang/rust/issues/120450 The second commit is just some drive-by test suite cleanup. r? `@oli-obk`
2024-02-16allow mutable references in const values when they point to no memoryRalf Jung-4/+5
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-7/+7
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-15Return ConstAllocation from eval_static_initializer query directlyOli Scherer-34/+3
2024-02-15Add new query just for static initializersOli Scherer-26/+10
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-2/+2
2024-02-15Use generic `NonZero` internally.Markus Reiter-7/+7
2024-02-12Dejargnonize substShoyu Vanilla-9/+9
2024-02-11Rollup merge of #120883 - RalfJung:extern-static-err, r=oli-obkMatthias Krüger-1/+1
interpret: rename ReadExternStatic → ExternStatic This error shows up for reads and writes, so `ReadExternStatic` is misleading.
2024-02-11Rollup merge of #120882 - RalfJung:set-discriminant, r=compiler-errorsMatthias Krüger-0/+2
interpret/write_discriminant: when encoding niched variant, ensure the stored value matches Cc https://github.com/rust-lang/unsafe-code-guidelines/issues/487
2024-02-10detect consts that reference extern staticsRalf Jung-0/+1
2024-02-10validation: descend from consts into staticsRalf Jung-0/+1