about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-3/+3
cleanup
2023-11-25Rollup merge of #118158 - nnethercote:reduce-fluent-boilerplate, ↵Michael Goulet-3/+1
r=compiler-errors Reduce fluent boilerplate Best reviewed one commit at a time. r? `@davidtwco`
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-25Rollup merge of #117871 - klensy:unused-pub, r=cjgillotGuillaume Gomez-35/+2
remove unused pub fns This removes some unused `pub fn`; also fixes few obsoleted fn names or added fixmes with reminders to update them.
2023-11-25Auto merge of #118075 - tmiasko:validate-critical-call-edges, r=cjgillotbors-0/+22
Validate there are no critical call edges in optimized MIR
2023-11-23few moreklensy-33/+0
2023-11-23remove unused pub fnklensy-2/+2
2023-11-23Auto merge of #118073 - saethlin:gc-dead-allocs, r=RalfJungbors-0/+11
Miri: GC the dead_alloc_map too dead_alloc_map is the last piece of state in the interpreter I can find that leaks. With this PR, all of the long-term memory growth I can find in Miri with programs that do things like run a big `loop {` or run property tests is attributable to some data structure properties in borrow tracking, and is _extremely_ slow. My only gripe with the commit in this PR is that I don't have a new test for it. I'd like to have a regression test for this, but it would have to be statistical I think because the peak memory of a process that Linux reports is not exactly the same run-to-run. Which means it would have to not be very sensitive to slow leaks (some guesswork suggests for acceptable CI time we would be checking for like 10% memory growth over a minute or two, which is still pretty fast IMO). Unless someone has a better idea for how to detect a regression, I think on balance I'm fine with manually keeping an eye on the memory use situation. r? RalfJung
2023-11-22Miri: GC the dead_alloc_map tooBen Kimock-0/+11
2023-11-22Rollup merge of #118147 - Nilstrieb:no-redundant-casts, r=WaffleLapkinMichael Goulet-1/+1
Fix some unnecessary casts `x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-22Validate there are no critical call edges in optimized MIRTomasz Miąsko-0/+22
2023-11-21Fix some unnecessary castsNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::unnecessary_cast --fix` with some manual review to ensure every fix is correct.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-31/+31
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21Rollup merge of #118029 - saethlin:allocid-gc, r=RalfJungNilstrieb-0/+25
Expand Miri's BorTag GC to a Provenance GC As suggested in https://github.com/rust-lang/miri/issues/3080#issuecomment-1732505573 We previously solved memory growth issues associated with the Stacked Borrows and Tree Borrows runtimes with a GC. But of course we also have state accumulation associated with whole allocations elsewhere in the interpreter, and this PR starts tackling those. To do this, we expand the visitor for the GC so that it can visit a BorTag or an AllocId. Instead of collecting all live AllocIds into a single HashSet, we just collect from the Machine itself then go through an accessor `InterpCx::is_alloc_live` which checks a number of allocation data structures in the core interpreter. This avoids the overhead of all the inserts that collecting their keys would require. r? ``@RalfJung``
2023-11-19Rollup merge of #117832 - RalfJung:interpret-shift, r=cjgillotMichael Goulet-28/+26
interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch While we're at it, also update comments in codegen and MIR building related to shifts, and fix the overflow error printed by Miri on negative shift amounts.
2023-11-19Expand Miri's BorTag GC to a Provenance GCBen Kimock-0/+25
2023-11-19Auto merge of #117807 - RalfJung:raw-str-slice, r=davidtwcobors-4/+9
patterns: don't ice when encountering a raw str slice Fixes https://github.com/rust-lang/rust/issues/117806
2023-11-18guarantee that char and u32 are ABI-compatibleRalf Jung-0/+2
2023-11-17replace unnecessary folder impls with fold_regionlcnr-2/+1
2023-11-15Re-format code with new rustfmtMark Rousskov-3/+2
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-11-14Fix some typoscui fliter-2/+2
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-11-12interpret: simplify handling of shifts by no longer trying to handle signed ↵Ralf Jung-28/+26
and unsigned shift amounts in the same branch
2023-11-12patterns: don't ice when encountering a raw str sliceRalf Jung-4/+9
2023-11-09Auto merge of #117712 - lcnr:expand-coroutine, r=jackh726bors-7/+7
generator layout: ignore fake borrows fixes #117059 We emit fake shallow borrows in case the scrutinee place uses a `Deref` and there is a match guard. This is necessary to prevent the match guard from mutating the scrutinee: https://github.com/rust-lang/rust/blob/fab1054e1742790c22ccc92a625736d658363677/compiler/rustc_mir_build/src/build/matches/mod.rs#L1250-L1265 These fake borrows end up impacting the generator witness computation in `mir_generator_witnesses`, which causes the issue in #117059. This PR now completely ignores fake borrows during this computation. This is sound as thse are always removed after analysis and the actual computation of the generator layout happens afterwards. Only the second commit impacts behavior, and could be backported by itself. r? types
2023-11-08rename `BorrowKind::Shallow` to `Fake`lcnr-7/+7
also adds some comments
2023-11-08Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwcobors-10/+27
patterns: reject raw pointers that are not just integers Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not. This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784654073) for some more explanation and context. Also fixes https://github.com/rust-lang/rust/issues/116929. Cc `@oli-obk` `@lcnr`
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-3/+3
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-3/+3
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-11-01Rollup merge of #117441 - cjgillot:diag-noassert, r=oli-obk,RalfJungMatthias Krüger-8/+20
Do not assert in op_to_const. `op_to_const` is used in `try_destructure_mir_constant_for_diagnostics`, which may encounter invalid constants created by optimizations and debugging. r? ``@oli-obk`` Fixes https://github.com/rust-lang/rust/issues/117368
2023-11-01Rollup merge of #117373 - saethlin:avoid-ice-lint, r=compiler-errorsMatthias Krüger-8/+4
Avoid the path trimming ICE lint in error reporting Types or really anything in MIR should never be formatted without path trimming disabled, because its formatting often tries to construct trimmed paths. In this case, the lint turns a nice error report into an irrelevant ICE.
2023-11-01Comment `for_diagnostics` flag.Camille GILLOT-0/+5
2023-11-01Specify diagnostic path.Camille GILLOT-6/+13
2023-11-01Rename hook.Camille GILLOT-3/+3
2023-11-01Do not assert in op_to_const.Camille GILLOT-2/+2
2023-11-01Avoid the path trimming ICE lint in error reportingBen Kimock-8/+4
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-13/+12
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-10-31Enums in offset_of: update based on est31, scottmcm & llogiq reviewGeorge Bateman-24/+12
2023-10-31Support enum variants in offset_of!George Bateman-12/+23
2023-10-31Turn const_caller_location from a query to a hookOli Scherer-6/+9
2023-10-30Rollup merge of #117317 - RalfJung:track-caller, r=oli-obkGuillaume Gomez-158/+135
share some track_caller logic between interpret and codegen Also move the code that implements the track_caller intrinsics out of the core interpreter engine -- it's just a helper creating a const-allocation, doesn't need to be part of the interpreter core.
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-5/+5
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-29Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJungbors-9/+58
See through aggregates in GVN This PR is extracted from https://github.com/rust-lang/rust/pull/111344 The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later `SimplifyLocals` do it. This makes tests easier to read (among others). The next 3 commits add a constant folding mechanism to the GVN pass, presented in https://github.com/rust-lang/rust/pull/116012. ~This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.~ The following commits implement opportunistic simplifications, in particular: - projections of aggregates: `MyStruct { x: a }.x` gets replaced by `a`, works with enums too; - projections of arrays: `[a, b][0]` becomes `a`; - projections of repeat expressions: `[a; N][x]` becomes `a`; - transform arrays of equal operands into a repeat rvalue. Fixes https://github.com/rust-lang/miri/issues/3090 r? `@oli-obk`
2023-10-28patterns: reject raw pointers that are not just integersRalf Jung-10/+27
2023-10-28share the track_caller handling within a mir::BodyRalf Jung-29/+11
2023-10-28interpret: call caller_location logic the same way codegen does, and share ↵Ralf Jung-158/+153
some code
2023-10-25Rename has_provance and tweaks comments.Camille GILLOT-1/+4
2023-10-25Refactor away the need for some `descr` methods.Oli Scherer-1/+1
Instead we use `Display` impls and their `alternate` render scheme to decide whether we want backticks or not.
2023-10-25Rename `AsyncCoroutineKind` to `CoroutineSource`Oli Scherer-2/+2
similar to how we have `MatchSource`, it explains where the desugaring came from.