about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2024-02-09Remove ConstGoto and SeparateConstSwitch.Camille GILLOT-478/+0
2024-02-09Enable by default.Camille GILLOT-1/+1
2024-02-09Remove untested arithmetic ops.Camille GILLOT-19/+5
2024-02-09Const-prop pointers.Camille GILLOT-0/+13
2024-02-09Split gvn wide ptr tests.Camille GILLOT-0/+3
2024-02-09Compute binary ops between pointers in GVN.Camille GILLOT-6/+60
2024-02-09Compute unsizing casts in GVN.Camille GILLOT-0/+10
2024-02-09Fold consecutive PtrToPtr casts.Camille GILLOT-13/+43
2024-02-09Auto merge of #120843 - matthiaskrgr:rollup-med37z5, r=matthiaskrgrbors-4/+5
Rollup of 8 pull requests Successful merges: - #113671 (Make privacy visitor use types more (instead of HIR)) - #120308 (core/time: avoid divisions in Duration::new) - #120693 (Invert diagnostic lints.) - #120704 (A drive-by rewrite of `give_region_a_name()`) - #120809 (Use `transmute_unchecked` in `NonZero::new`.) - #120817 (Fix more `ty::Error` ICEs in MIR passes) - #120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - #120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-09Rollup merge of #120817 - compiler-errors:more-mir-errors, r=oli-obkMatthias Krüger-2/+5
Fix more `ty::Error` ICEs in MIR passes Fixes #120791 - Add a check for `ty::Error` in the `ByMove` coroutine pass Fixes #120816 - Add a check for `ty::Error` in the MIR validator Also a drive-by fix for a FIXME I had asked oli to add r? oli-obk
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-2/+0
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-09Auto merge of #120594 - saethlin:delayed-debug-asserts, r=oli-obkbors-0/+39
Toggle assert_unsafe_precondition in codegen instead of expansion The goal of this PR is to make some of the unsafe precondition checks in the standard library available in debug builds. Some UI tests are included to verify that it does that. The diff is large, but most of it is blessing mir-opt tests and I've also split up this PR so it can be reviewed commit-by-commit. This PR: 1. Adds a new intrinsic, `debug_assertions` which is lowered to a new MIR NullOp, and only to a constant after monomorphization 2. Rewrites `assume_unsafe_precondition` to check the new intrinsic, and be monomorphic. 3. Skips codegen of the `assume` intrinsic in unoptimized builds, because that was silly before but with these checks it's *very* silly 4. The checks with the most overhead are `ptr::read`/`ptr::write` and `NonNull::new_unchecked`. I've simply added `#[cfg(debug_assertions)]` to the checks for `ptr::read`/`ptr::write` because I was unable to come up with any (good) ideas for decreasing their impact. But for `NonNull::new_unchecked` I found that the majority of callers can use a different function, often a safe one. Yes, this PR slows down the compile time of some programs. But in our benchmark suite it's never more than 1% icount, and the average icount change in debug-full programs is 0.22%. I think that is acceptable for such an improvement in developer experience. https://github.com/rust-lang/rust/issues/120539#issuecomment-1922687101
2024-02-09Don't ICE in ByMoveBody when coroutine is taintedMichael Goulet-2/+5
2024-02-08Rollup merge of #120782 - oli-obk:track_errors8, r=WaffleLapkinMatthias Krüger-0/+1
Fix mir pass ICE in the presence of other errors fixes #120779 it is impossible to add a ui test for this, because it only reproduces in build-fail, but a test that also has errors in check-fail mode can't be made build-fail 🙃 I would have to add a run-make test or sth, which is overkill for such a tiny thing imo.
2024-02-08Rollup merge of #120778 - zetanumbers:refactor_try_instance_mir, ↵Matthias Krüger-15/+10
r=compiler-errors Deduplicate `tcx.instance_mir(instance)` calls in `try_instance_mir`
2024-02-08Rollup merge of #120590 - compiler-errors:dead, r=NilstriebMatthias Krüger-7/+2
Remove unused args from functions `#[instrument]` suppresses the unused arguments from a function, *and* suppresses unused methods too! This PR removes things which are only used via `#[instrument]` calls, and fixes some other errors (privacy?) that I will comment inline. It's possible that some of these arguments were being passed in for the purposes of being instrumented, but I am unconvinced by most of them.
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-0/+14
And in clippy
2024-02-08InstSimplify rustc_nounwind callsBen Kimock-0/+25
2024-02-08Fix mir pass ICE in the presence of other errorsOli Scherer-0/+1
2024-02-08Deduplicate `tcx.instance_mir(instance)` calls in `try_instance_mir`zetanumbers-15/+10
2024-02-08Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgrbors-2/+2
Rollup of 9 pull requests Successful merges: - #119592 (resolve: Unload speculatively resolved crates before freezing cstore) - #120103 (Make it so that async-fn-in-trait is compatible with a concrete future in implementation) - #120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s) - #120214 (match lowering: consistently lower bindings deepest-first) - #120688 (GVN: also turn moves into copies with projections) - #120702 (docs: also check the inline stmt during redundant link check) - #120727 (exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered") - #120734 (Add `SubdiagnosticMessageOp` as a trait alias.) - #120739 (improve pretty printing for associated items in trait objects) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-0/+1
2024-02-08Rollup merge of #120688 - cjgillot:gvn-partial-move, r=oli-obkMatthias Krüger-2/+2
GVN: also turn moves into copies with projections Fixes https://github.com/rust-lang/rust/issues/120613
2024-02-07Stop using is_copy_modulo_regions when building clone shimMichael Goulet-4/+1
2024-02-07Rollup merge of #120733 - klensy:trait-const-fn, r=oli-obkGuillaume Boisseau-10/+2
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-07Rollup merge of #120564 - Zalathar:increment-site, r=oli-obkGuillaume Boisseau-80/+79
coverage: Split out counter increment sites from BCB node/edge counters This makes it possible for two nodes/edges in the coverage graph to share the same counter, without causing the instrumentor to inject unwanted duplicate counter-increment statements. --- ````@rustbot```` label +A-code-coverage
2024-02-07MirPass: make name more constklensy-10/+2
2024-02-06Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closureMichael Goulet-26/+111
2024-02-06More comments, final tweaksMichael Goulet-1/+12
2024-02-06Construct body for by-move coroutine closure outputMichael Goulet-0/+135
2024-02-06Build a shim to call async closures with different AsyncFn trait kindsMichael Goulet-1/+122
2024-02-06Teach typeck/borrowck/solvers how to deal with async closuresMichael Goulet-2/+5
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-5/+14
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-02-05Also turn moves into copies even if through projections.Camille GILLOT-2/+2
2024-02-05coverage: Make `fn_sig_span` optional, and note its quirksZalathar-11/+17
2024-02-05coverage: Hoist special handling of async function spansZalathar-26/+30
This sidesteps the normal span refinement code in cases where we know that we are only dealing with the special signature span that represents having called an async function.
2024-02-05coverage: Make unexpansion of closure bodies more preciseZalathar-18/+12
This improves the coverage instrumentation of closures declared in macros, as seen in `closure_macro.rs` and `closure_macro_async.rs`.
2024-02-02Remove dead args from functionsMichael Goulet-7/+2
2024-02-03Use `DiagnosticArgName` in a few more places.Nicholas Nethercote-1/+1
2024-02-02coverage: Split out counter increment sites from BCB node/edge countersZalathar-80/+79
This makes it possible for two nodes/edges in the coverage graph to share the same counter, without causing the instrumentor to inject unwanted duplicate counter-increment statements.
2024-01-31Rollup merge of #120495 - clubby789:remove-amdgpu-kernel, r=oli-obkNadrieril-1/+0
Remove the `abi_amdgpu_kernel` feature The tracking issue (#51575) has been closed for 3 years, with no activity for 5.
2024-01-31Auto merge of #120346 - petrochenkov:ownodes, r=oli-obkbors-6/+1
hir: Refactor getters for owner nodes
2024-01-30Remove the `abi_amdgpu_kernel` featureclubby789-1/+0
2024-01-30hir: Add non-optional `hir_owner_nodes` for real `OwnerId`sVadim Petrochenkov-6/+1
2024-01-30hir: Simplify `hir_owner_nodes` queryVadim Petrochenkov-1/+1
The query accept arbitrary DefIds, not just owner DefIds. The return can be an `Option` because if there are no nodes, then it doesn't matter whether it's due to NonOwner or Phantom. Also rename the query to `opt_hir_owner_nodes`.
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-3/+3
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-29Stop using `String` for error codes.Nicholas Nethercote-3/+3
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-26add test for GVN issue; cleanup in dataflow_const_propRalf Jung-6/+1
2024-01-26Auto merge of #119968 - clubby789:unused-feature, r=compiler-errorsbors-2/+0
Remove unused/unnecessary features ~~The bulk of the actual code changes here is replacing try blocks with equivalent closures. I'm not entirely sure that's a good idea since it may have perf impact, happy to revert if that's the case/the change is unwanted.~~ I also removed a lot of `recursion_limit = "256"` since everything seems to build fine without that and most don't have any comment justifying it.