about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2025-01-30Auto merge of #136035 - SpecificProtagonist:miri-zeroed-alloc, r=oli-obkbors-16/+25
miri: optimize zeroed alloc When allocating zero-initialized memory in MIR interpretation, rustc allocates zeroed memory, marks it as initialized and then re-zeroes it. Remove the last step. I don't expect this to have much of an effect on performance normally, but in my case in which I'm creating a large allocation via mmap it gets in the way.
2025-01-29Rollup merge of #136166 - RalfJung:interpet-is-alloc-live, r=compiler-errorsLeón Orell Valerian Liehr-2/+4
interpret: is_alloc_live: check global allocs last See https://github.com/rust-lang/rust/pull/136105#discussion_r1930609553. (A perf run makes no sense as this is only used by Miri.)
2025-01-28Auto merge of #136203 - matthiaskrgr:rollup-1k0f44l, r=matthiaskrgrbors-109/+118
Rollup of 9 pull requests Successful merges: - #135869 (Make docs for AtomicUsize::from_mut platform-independent) - #135892 (-Znext-solver: "normalize" signature before checking it mentions self in `deduce_closure_signature`) - #136055 (Implement MIR const trait stability checks) - #136066 (Pass spans to `perform_locally_in_new_solver`) - #136071 ([Clippy] Add vec_reserve & vecdeque_reserve diagnostic items) - #136124 (Arbitrary self types v2: explain test.) - #136149 (Flip the `rustc-rayon`/`indexmap` dependency order) - #136173 (Update comments and sort target_arch in c_char_definition) - #136178 (Update username in build helper example) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-28Rollup merge of #136055 - fee1-dead-contrib:push-ovmyztlkptmk, r=RalfJungMatthias Krüger-109/+118
Implement MIR const trait stability checks Addresses https://github.com/rust-lang/project-const-traits/issues/16 cc ``@rust-lang/project-const-traits`` r? ``@RalfJung``
2025-01-28miri: optimize zeroed allocSpecificProtagonist-16/+25
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-01-28Implement MIR const trait stability checksDeadbeef-109/+118
2025-01-28interpret: is_alloc_live: check global allocs lastRalf Jung-2/+4
2025-01-28Represent the raw pointer for a array length check as a new kind of fake borrowMichael Goulet-21/+15
2025-01-27Reapply "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Michael Goulet-7/+31
r=davidtwco,RalfJung" This reverts commit 122a55bb442bd1995df9cf9b36e6f65ed3ef4a1d.
2025-01-27Add `TooGeneric` variant to `LayoutError` and emit `Unknown` oneFedericoBruzzone-1/+1
- `check-pass` test for a MRE of #135020 - fail test for #135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
2025-01-19Rollup merge of #134858 - estebank:issue-81370, r=NoratriebGuillaume Gomez-4/+33
Provide structured suggestion for `#![feature(..)]` in more cases Fix #81370.
2025-01-19Auto merge of #135709 - lqd:bring-back-len, r=compiler-errorsbors-34/+20
Temporarily bring back `Rvalue::Len` r? `@compiler-errors` as requested in https://github.com/rust-lang/rust/issues/135671#issuecomment-2599580364 > However, in the mean time, I'd rather we not crunch trying to find and more importantly validate the soundness of a solution 🤔 Agreed. To fix the IMO P-critical #135671 for which we somehow didn't have test coverage, this PR temporarily reverts: - https://github.com/rust-lang/rust/pull/133734 - its bugfix https://github.com/rust-lang/rust/pull/134371 - https://github.com/rust-lang/rust/pull/134330 cc `@scottmcm` I added the few samples from that issue as a test, but we can add more in the future, in particular it seems `@steffahn` [will work on that](https://github.com/rust-lang/rust/issues/135671#issuecomment-2599714354). Fixes #135671. And if we want to land this, it should also be nominated for beta backport.
2025-01-18Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Rémy Rakic-31/+7
r=davidtwco,RalfJung" This reverts commit b57d93d8b9525fa261404b4cd9c0670eeb1264b8, reversing changes made to 0aeaa5eb22180fdf12a8489e63c4daa18da6f236.
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-3/+13
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.
2025-01-18Deduplicate logicEsteban Küber-14/+8
2025-01-18Structured suggestion for "missing `feature` intrinsic"Esteban Küber-1/+18
``` error: `size_of_val` is not yet stable as a const intrinsic --> $DIR/const-unstable-intrinsic.rs:17:9 | LL | unstable_intrinsic::size_of_val(&x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(unstable)]` to the crate attributes to enable help: add `#![feature(unstable)]` to the crate attributes to enable | LL + #![feature("unstable")] | ```
2025-01-18Structured suggestion for "missing `feature` in unstable fn call"Esteban Küber-3/+21
When encountering a call corresponding to an item marked as unstable behind a feature flag, provide a structured suggestion pointing at where in the crate the `#![feature(..)]` needs to be written. ``` error: `foobar` is not yet stable as a const fn --> $DIR/const-stability-attribute-implies-no-feature.rs:12:5 | LL | foobar(); | ^^^^^^^^ | help: add `#![feature(const_foobar)]` to the crate attributes to enable | LL + #![feature(const_foobar)] | ``` Fix #81370.
2025-01-18const-eval: detect more pointers as definitely not-nullRalf Jung-8/+17
2025-01-15Methods of const traits are constOli Scherer-12/+13
2025-01-14Do not consider traits that have unsatisfied const conditions to be ↵Michael Goulet-8/+18
conditionally const
2025-01-13Assert that Instance::try_resolve is only used on body-like thingsMichael Goulet-4/+8
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-3/+3
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2025-01-09Unify conditional and non const call error reportingMichael Goulet-221/+256
2025-01-09Make the non-const part swappable in the diagnosticMichael Goulet-14/+31
2025-01-09Add note back to conditionally-const error messageMichael Goulet-2/+10
2025-01-07Avoid naming variables `str`Josh Triplett-4/+4
This renames variables named `str` to other names, to make sure `str` always refers to a type. It's confusing to read code where `str` (or another standard type name) is used as an identifier. It also produces misleading syntax highlighting.
2025-01-04rustc_intrinsic: support functions without body; they are implicitly marked ↵Ralf Jung-1/+2
as must-be-overridden
2024-12-30Auto merge of #134757 - RalfJung:const_swap, r=scottmcmbors-46/+29
stabilize const_swap libs-api FCP passed in https://github.com/rust-lang/rust/issues/83163. However, I only just realized that this actually involves an intrinsic. The intrinsic could be implemented entirely with existing stable const functionality, but we choose to make it a primitive to be able to detect more UB. So nominating for `@rust-lang/lang` to make sure they are aware; I leave it up to them whether they want to FCP this. While at it I also renamed the intrinsic to make the "nonoverlapping" constraint more clear. Fixes #83163
2024-12-27Rollup merge of #134787 - fmease:spruce-up-queries, r=compiler-errors许杰友 Jieyou Xu (Joe)-10/+4
Spruce up the docs of several queries related to the type/trait system and const eval - Editorial - Proper rustdoc summary/synopsis line by making use of extra paragraphs: Leads to better rendered output on module pages, in search result lists and overall, too - Use rustdoc warning blocks for admonitions of the form "do not call / avoid calling this query directly" - Use intra-doc links of the form ``[`Self::$query`]`` to cross-link queries. Indeed, such links are generally a bit brittle due to the existence of `TyCtxtFeed` which only contains a subset of queries. Therefore the docs of `feedable` queries cannot cross-link to non-`feedable` ones. I'd say it's fine to use intra-doc links despite the potential/unlikely occasional future breakage (if a query with the aforementioned characteristics becomes `feedable`). `Self::` is nicer than `TyCtxt::` (which would be more stable) since it accounts for other contexts like `TyCtxt{Feed,At,Ensure{,WithValue}}` - Informative - Generally add, flesh out and correct some doc comments - Add *Panic* sections (to a few selected queries only). The lists of panics aren't necessarily exhaustive and focus on the more "obvious" or "important" panics. - Where applicable add a paragraph calling attention to the relevant [`#[rustc_*]` TEST attribute](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html#rustc_-test-attributes) The one non-doc change (it's internal and not observable): Be even more defensive in `query constness`'s impl (spiritual follow-up to #134122) (see self review comment). Fixes #133494. r\? **any**(compiler-errors, oli-obk)
2024-12-27Rollup merge of #134606 - RalfJung:ptr-copy-docs, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-0/+2
ptr::copy: fix docs for the overlapping case Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/549 As discussed in that issue, it doesn't make any sense for `copy` to read a byte via `src` after it was already written via `dst`. The entire point of this method is that is copies correctly even if they overlap, and that requires always reading any given location before writing it. Cc `@rust-lang/opsem`
2024-12-27Spruce up the docs of several queries related to the type/trait system and ↵León Orell Valerian Liehr-10/+4
const eval
2024-12-25swap_typed_nonoverlapping: properly detect overlap even when swapping scalar ↵Ralf Jung-45/+28
values
2024-12-25rename typed_swap → typed_swap_nonoverlappingRalf Jung-1/+1
2024-12-25miri: add test for overlapping typed_swapRalf Jung-1/+1
2024-12-24Auto merge of #134716 - Zalathar:rollup-1h4q8cc, r=Zalatharbors-0/+2
Rollup of 5 pull requests Successful merges: - #134638 (Fix effect predicates from item bounds in old solver) - #134662 (Fix safety docs for `dyn Any + Send {+ Sync}`) - #134689 (core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets) - #134699 (Belay new reviews for workingjubilee) - #134701 (Correctly note item kind in `NonConstFunctionCall` error message) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-24Auto merge of #134625 - compiler-errors:unsafe-binders-ty, r=oli-obkbors-3/+12
Begin to implement type system layer of unsafe binders Mostly TODOs, but there's a lot of match arms that are basically just noops so I wanted to split these out before I put up the MIR lowering/projection part of this logic. r? oli-obk Tracking: - https://github.com/rust-lang/rust/issues/130516
2024-12-23Note def descr in NonConstFunctionCallMichael Goulet-0/+2
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-3/+12
2024-12-22Delete `Rvalue::Len`Scott McMurray-13/+3
Everything's moved to `PtrMetadata` instead.
2024-12-21ptr::copy: fix docs for the overlapping caseRalf Jung-0/+2
2024-12-20Auto merge of #134550 - jhpratt:rollup-wsfmo59, r=jhprattbors-9/+13
Rollup of 6 pull requests Successful merges: - #126118 (docs: Mention `spare_capacity_mut()` in `Vec::set_len`) - #132830 (Rename `elem_offset` to `element_offset`) - #133103 (Pass FnAbi to find_mir_or_eval_fn) - #134321 (Hide `= _` as associated constant value inside impl blocks) - #134518 (fix typos in the example code in the doc comments of `Ipv4Addr::from_bits()`, `Ipv6Addr::from_bits()` & `Ipv6Addr::to_bits()`) - #134521 (Arbitrary self types v2: roll loop.) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-20Rollup merge of #133103 - tiif:fnabi, r=RalfJungJacob Pratt-9/+13
Pass FnAbi to find_mir_or_eval_fn https://github.com/rust-lang/miri/issues/4013 needs information from ``FnAbi``, hence it is passed to ``find_mir_or_eval_fn``. r? `@RalfJung`
2024-12-20Auto merge of #134438 - lqd:const-qualif-bitsets, r=compiler-errorsbors-5/+7
Use `MixedBitSet`s in const qualif These analyses' domains should be very homogeneous, having compressed bitmaps on huge cfgs should make a difference (and doesn’t have an impact on the smaller / regular cfgs in our benchmarks). This is a >40% walltime reduction on [this stress test](https://github.com/Manishearth/icu4x_compile_sample) extracted from a real world ICU case, and a 10x or so max-rss reduction. cc `@oli-obk` `@RalfJung` Should help with (or fix) issue #134404.
2024-12-19Pass FnAbi to find_mir_or_eval_fntiif-9/+13
2024-12-19Rollup merge of #133702 - RalfJung:single-variant, r=oli-obk许杰友 Jieyou Xu (Joe)-17/+18
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of https://github.com/rust-lang/rust/pull/133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
2024-12-18Auto merge of #134443 - joshtriplett:use-field-init-shorthand, ↵bors-1/+1
r=lqd,tgross35,nnethercote Use field init shorthand where possible Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used. EDIT: this PR also updates `rustfmt.toml` to set `use_field_init_shorthand = true`.
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-9/+13
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-15/+12
2024-12-18make const qualif use mixed bitsets instead of dense bitsetsRémy Rakic-5/+7
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-9/+7
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.