about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
AgeCommit message (Collapse)AuthorLines
2024-03-08Update MIR with `MirPatch` in `UninhabitedEnumBranching`DianQK-2/+25
2024-03-07Replace the default branch with an unreachable branch If it is the last variantDianQK-0/+11
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-8/+4
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-10/+10
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-10/+10
2024-02-27Split rustc_type_ir to avoid rustc_ast from depending on itOli Scherer-1/+1
2024-02-24Implement asm goto in MIR and MIR loweringGary Guo-1/+9
2024-02-24Change InlineAsm to allow multiple targets insteadGary Guo-48/+54
2024-02-24Use slice.chain(option) for SuccessorsGary Guo-31/+28
This makes more sense because most cases then second one is unwind target.
2024-02-18By tracking import use types to check whether it is scope uses or the other ↵surechen-1/+1
situations like module-relative uses, we can do more accurate redundant import checking. fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
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-15Auto merge of #120931 - chenyukang:yukang-cleanup-hashmap, r=michaelwoeristerbors-5/+4
Clean up potential_query_instability with FxIndexMap and UnordMap From https://github.com/rust-lang/rust/pull/120485#issuecomment-1916437191 r? `@michaelwoerister`
2024-02-15Auto merge of #116564 - oli-obk:evaluated_static_in_metadata, ↵bors-57/+12
r=RalfJung,cjgillot Store static initializers in metadata instead of the MIR of statics. This means that adding generic statics would be even more difficult, as we can't evaluate statics from other crates anymore, but the subtle issue I have encountered make me think that having this be an explicit problem is better. The issue is that ```rust static mut FOO: &mut u32 = &mut 42; static mut BAR = unsafe { FOO }; ``` gets different allocations, instead of referring to the same one. This is also true for non-static mut, but promotion makes `static FOO: &u32 = &42;` annoying to demo. Fixes https://github.com/rust-lang/rust/issues/61345 ## Why is this being done? In order to ensure all crates see the same nested allocations (which is the last issue that needs fixing before we can stabilize [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349)), I am working on creating anonymous (from the Rust side, to LLVM it's like a regular static item) static items for the nested allocations in a static. If we evaluate the static item in a downstream crate again, we will end up duplicating its nested allocations (and in some cases, like the `match` case, even duplicate the main allocation).
2024-02-15Return ConstAllocation from eval_static_initializer query directlyOli Scherer-35/+6
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-15Enforce coroutine-closure layouts are identicalMichael Goulet-2/+4
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-5/+4
2024-02-12Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obkMatthias Krüger-10/+10
Dejargonize `subst` In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12Rollup merge of #120950 - compiler-errors:miri-async-closurs, r=RalfJung,oli-obkMatthias Krüger-1/+1
Fix async closures in CTFE First commit renames `is_coroutine_or_closure` into `is_closure_like`, because `is_coroutine_or_closure_or_coroutine_closure` seems confusing and long. Second commit fixes some forgotten cases where we want to handle `TyKind::CoroutineClosure` the same as closures and coroutines. The test exercises the change to `ValidityVisitor::aggregate_field_path_elem` which is the source of #120946, but not the change to `UsedParamsNeedSubstVisitor`, though I feel like it's not that big of a deal. Let me know if you'd like for me to look into constructing a test for the latter, though I have no idea what it'd look like (we can't assert against `TooGeneric` anywhere?). Fixes #120946 r? oli-obk cc ``@RalfJung``
2024-02-12Dejargnonize substShoyu Vanilla-10/+10
2024-02-11is_closure_likeMichael Goulet-1/+1
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
2024-02-10interpret: rename ReadExternStatic → ExternStaticRalf Jung-1/+1
2024-02-10interpret/write_discriminant: when encoding niched variant, ensure the ↵Ralf Jung-0/+2
stored value matches
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-0/+4
And in clippy
2024-02-07Rollup merge of #120733 - klensy:trait-const-fn, r=oli-obkGuillaume Boisseau-2/+6
MirPass: make name more const Continues #120161, this time applied to `MirPass` instead of `MirLint`, locally shaves few (very few) instructions off. r? ``@cjgillot``
2024-02-07MirPass: make name more constklensy-2/+6
2024-02-06Rollup merge of #120423 - RalfJung:indirect-structural-match, r=petrochenkovMatthias Krüger-2/+1
update indirect structural match lints to match RFC and to show up for dependencies This is a large step towards implementing https://github.com/rust-lang/rfcs/pull/3535. We currently have five lints related to "the structural match situation": - nontrivial_structural_match - indirect_structural_match - pointer_structural_match - const_patterns_without_partial_eq - illegal_floating_point_literal_pattern This PR concerns the first 3 of them. (The 4th already is set up to show for dependencies, and the 5th is removed by https://github.com/rust-lang/rust/pull/116284.) nontrivial_structural_match is being removed as per the RFC; the other two are enabled to show up in dependencies. Fixes https://github.com/rust-lang/rust/issues/73448 by removing the affected analysis.
2024-02-06Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closureMichael Goulet-3/+19
2024-02-06Bless tests, add commentsMichael Goulet-2/+10
2024-02-06Construct body for by-move coroutine closure outputMichael Goulet-0/+7
2024-02-06Build a shim to call async closures with different AsyncFn trait kindsMichael Goulet-0/+2
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-1/+12
2024-02-05get rid of nontrivial_structural_match lint and custom_eq const qualifRalf Jung-2/+1
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-2/+2
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-03Use `DiagnosticArgName` in a few more places.Nicholas Nethercote-4/+8
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-8/+5
Because it's almost always static. This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial, which is nice. There are a few diagnostics constructed in `compiler/rustc_mir_build/src/check_unsafety.rs` and `compiler/rustc_mir_transform/src/errors.rs` that now need symbols converted to `String` with `to_string` instead of `&str` with `as_str`, but that' no big deal, and worth it for the simplifications elsewhere.
2024-01-26make matching on NaN a hard errorRalf Jung-2/+2
2024-01-26interpret: project_downcast: do not ICE for uninhabited variantsRalf Jung-0/+2
2024-01-25Rollup merge of #120330 - ↵Matthias Krüger-4/+15
compiler-errors:no-coroutine-info-in-coroutine-drop-body, r=nnethercote Remove coroutine info when building coroutine drop body Coroutine drop shims are not themselves coroutines, so erase the "`coroutine`" field from the body so that helper fns like `yield_ty` and `coroutine_kind` properly return `None` for the drop shim.
2024-01-25What even is CoroutineInfoMichael Goulet-4/+15