about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2023-09-13Generate MIR pass names for profiling on the fly and pass the body DefId as ↵John Kåre Alsaker-0/+37
argument
2023-09-13restore the old logic adjusting ty::UnevaluatedConst before evaluationRalf Jung-4/+5
2023-09-13make the set of methods between our two Const types more consistentRalf Jung-53/+31
2023-09-13make the eval() functions on our const types return the resulting valueRalf Jung-41/+58
2023-09-12Auto merge of #115699 - RalfJung:interpret-abi-compat, r=oli-obkbors-7/+12
interpret: change ABI-compat test to be type-based This makes the test consistent across targets. Otherwise the chances are very high that ABI mismatches get accepted on x86_64 but still fail on many other targets with more complicated ABIs. This implements (most of) the rules described in https://github.com/rust-lang/rust/pull/115476.
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-12/+18
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-09-09give extra context to ABI mismatch errorsRalf Jung-7/+12
2023-09-08Auto merge of #115612 - cjgillot:const-prop-int, r=oli-obkbors-1/+8
Improvements to dataflow const-prop Partially cherry-picked from https://github.com/rust-lang/rust/pull/110719 r? `@oli-obk` cc `@jachris`
2023-09-06Support array length.Camille GILLOT-0/+7
2023-09-05Do not assert in try_to_int.Camille GILLOT-1/+1
2023-09-05Refactor how MIR represents composite debuginfo.Camille GILLOT-57/+37
2023-09-05Refactor projection debug.Camille GILLOT-55/+69
2023-09-04interpret: make MemPlace, Place, Operand types private to the interpreterRalf Jung-1/+1
2023-09-01Use `OnceLock` for `SingleCache`John Kåre Alsaker-6/+6
2023-08-30move marking-locals-live out of push_stack_frame, so it happens with ↵Ralf Jung-0/+2
argument passing this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-24make MIR less verboseRalf Jung-4/+13
2023-08-24cache the terminate block with the last reason that we sawRalf Jung-13/+9
2023-08-24document more things as needing to stay in syncRalf Jung-3/+16
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-38/+98
2023-08-20Auto merge of #114993 - RalfJung:panic-nounwind, r=fee1-deadbors-64/+49
interpret/miri: call the panic_nounwind machinery the same way codegen does
2023-08-20sync printing of MIR terminators with their new names (and dedup some to-str ↵Ralf Jung-44/+27
logic)
2023-08-20give some unwind-related terminators a more clear nameRalf Jung-24/+26
2023-08-20coverage: Give the instrumentor its own counter type, separate from MIRZalathar-15/+0
This splits off `BcbCounter` from MIR's `CoverageKind`, allowing the two types to evolve in different directions as necessary.
2023-08-17Revert "Implement references VarDebugInfo."Camille GILLOT-12/+2
This reverts commit 2ec007191348ef7cc13eb55e44e007b02cf75cf3.
2023-08-16Make TerminatorEdge plural.Camille GILLOT-13/+13
2023-08-16Allow apply_terminator_effect to customize edges.Camille GILLOT-0/+106
2023-08-10Rollup merge of #114622 - petrochenkov:noplugin, r=oli-obkMichael Goulet-2/+2
rustc: Move `crate_types` and `stable_crate_id` from `Session` to `GlobalCtxt` Removes two pieces of mutable state. Follow up to https://github.com/rust-lang/rust/pull/114578.
2023-08-09Rollup merge of #114587 - ouz-a:smir_allocation, r=oli-obkMatthias Krüger-0/+3
Convert Const to Allocation in smir Continuation of previous pr https://github.com/rust-lang/rust/pull/114466 cc https://github.com/rust-lang/project-stable-mir/issues/15 r? `@oli-obk`
2023-08-09Convert Const to Allocation in smirouz-a-0/+3
2023-08-09rustc: Move `stable_crate_id` from `Session` to `GlobalCtxt`Vadim Petrochenkov-2/+2
Removes a piece of mutable state. Follow up to #114578.
2023-08-08interpret: remove incomplete protection against invalid where clausesRalf Jung-2/+0
2023-08-06Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJungMatthias Krüger-11/+17
Add documentation to has_deref Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose. cc https://github.com/rust-lang/rust/issues/114401 r? `@RalfJung`
2023-08-06cleanup misinformation regarding has_derefouz-a-11/+17
2023-08-03Rollup merge of #114372 - RalfJung:const-pointer-as-int, r=oli-obkMatthias Krüger-60/+77
const validation: point at where we found a pointer but expected an integer Instead of validation just printing "unable to turn pointer into bytes", make this a regular validation error that says where in the value the bad pointer was found. Also distinguish "expected integer, got pointer" from "expected pointer, got partial pointer or mix of pointers". To avoid duplicating things too much I refactored the diagnostics for validity a bit, so that "got uninit, expected X" and "got pointer, expected X" can share the "X" part. Also all the errors emitted for validation are now grouped under `const_eval_validation` so that they are in a single group in the ftl file. r? `@oli-obk`
2023-08-03Rollup merge of #114363 - RalfJung:interpret-not-miri, r=jackh726Matthias Krüger-2/+2
avoid 'miri' when refering to the shared interpreter This is basically the rustc source code version of https://github.com/rust-lang/rustc-dev-guide/pull/1471.
2023-08-02const validation: point at where we found a pointer but expected an integerRalf Jung-60/+77
2023-08-02avoid 'miri' when refering to the shared interpreterRalf Jung-2/+2
2023-08-02Auto merge of #114333 - RalfJung:dangling-ptr-offset, r=oli-obkbors-2/+2
Miri: fix error on dangling pointer inbounds offset We used to claim that the pointer was "dereferenced", but that is just not true. Can be reviewed commit-by-commit. The first commit is an unrelated rename that didn't seem worth splitting into its own PR. r? `@oli-obk`
2023-08-01properly track why we checked whether a pointer is in-boundsRalf Jung-2/+2
also simplify the in-bounds checking in Miri's borrow trackers
2023-08-01Make coverage counter IDs count up from 0, not 1Zalathar-13/+13
Operand types are now tracked explicitly, so there is no need to reserve ID 0 for the special always-zero counter. As part of the renumbering, this change fixes an off-by-one error in the way counters were counted by the `coverageinfo` query. As a result, functions should now have exactly the number of counters they actually need, instead of always having an extra counter that is never used.
2023-08-01Make coverage expression IDs count up from 0, not down from `u32::MAX`Zalathar-11/+15
Operand types are now tracked explicitly, so there is no need for expression IDs to avoid counter IDs by descending from `u32::MAX`. Instead they can just count up from 0, and can be used directly as indices when necessary.
2023-08-01Replace `ExpressionOperandId` with enum `Operand`Zalathar-48/+26
Because the three kinds of operand are now distinguished explicitly, we no longer need fiddly code to disambiguate counter IDs and expression IDs based on the total number of counters/expressions in a function. This does increase the size of operands from 4 bytes to 8 bytes, but that shouldn't be a big deal since they are mostly stored inside boxed structures, and the current coverage code is not particularly size-optimized anyway.
2023-08-01Add some line comments to enum `CoverageKind`Zalathar-0/+4
The actual motivation here is to prevent `rustfmt` from suddenly reformatting these enum variants onto a single line, when they become slightly shorter in the future. But there's no harm in adding some helpful documentation at the same time.
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-163/+145
2023-07-27Remove `constness` from `ParamEnv`Deadbeef-7/+2
2023-07-25Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnrbors-9/+3
Normalize the RHS of an `Unsize` goal in the new solver `Unsize` goals are... tricky. Not only do they structurally match on their self type, but they're also structural on their other type parameter. I'm pretty certain that it is both incomplete and also just plain undesirable to not consider normalizing the RHS of an unsize goal. More practically, I'd like for this code to work: ```rust trait A {} trait B: A {} impl A for usize {} impl B for usize {} trait Mirror { type Assoc: ?Sized; } impl<T: ?Sized> Mirror for T { type Assoc = T; } fn main() { // usize: Unsize<dyn B> let x = Box::new(1usize) as Box<<dyn B as Mirror>::Assoc>; // dyn A: Unsize<dyn B> let y = x as Box<<dyn A as Mirror>::Assoc>; } ``` --- In order to achieve this, we add `EvalCtxt::normalize_non_self_ty` (naming modulo bikeshedding), which *must* be used for all non-self type arguments that are structurally matched in candidate assembly. Currently this is only necessary for `Unsize`'s argument, but I could see future traits requiring this (hopefully rarely) in the future. It uses `repeat_while_none` to limit infinite looping, and normalizes the self type until it is no longer an alias. Also, we need to fix feature gate detection for `trait_upcasting` and `unsized_tuple_coercion` when HIR typeck has unnormalized types. We can do that by checking the `ImplSource` returned by selection, which necessitates adding a new impl source for tuple upcasting.
2023-07-25Make everything builtin!Michael Goulet-9/+3
2023-07-25add some sanity checks in write_immediate_no_validateRalf Jung-1/+9
2023-07-25interpret: refactor projection code to work on a common trait, and use that ↵Ralf Jung-2/+6
for visitors
2023-07-24interpret: support projecting into Place::Local without force_allocationRalf Jung-3/+2