about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-20 16:57:05 +0000
committerbors <bors@rust-lang.org>2023-07-20 16:57:05 +0000
commit092e4f46be168ab24d53e4141086b2cf04822b8e (patch)
tree319a736d758b0d3fc9a9eabf1333c987ca96fa9e /compiler/rustc_codegen_ssa/src
parent06a53ddc0bd3a50f9bcf2f7c373011dc7869f59f (diff)
parent464e02a26713c92caf635f2fd037e95043a17343 (diff)
downloadrust-092e4f46be168ab24d53e4141086b2cf04822b8e.tar.gz
rust-092e4f46be168ab24d53e4141086b2cf04822b8e.zip
Auto merge of #113890 - matthiaskrgr:rollup-k1w2vii, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #110765 (rustdoc: fix position of `default` in method rendering)
 - #113529 (Permit pre-evaluated constants in simd_shuffle)
 - #113800 (Avoid another gha group nesting)
 - #113827 (Add Foreign, Never, FnDef, Closure and Generator tys to SMIR)
 - #113835 (new solver: don't consider blanket impls multiple times)
 - #113883 (Remove outdated Firefox-specific CSS for search's crate selector appearance)
 - #113884 (Don't translate compiler-internal bug messages)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/constant.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/constant.rs b/compiler/rustc_codegen_ssa/src/mir/constant.rs
index 1c5031dfc4b..babcf9bee24 100644
--- a/compiler/rustc_codegen_ssa/src/mir/constant.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/constant.rs
@@ -65,8 +65,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
         &self,
         constant: &mir::Constant<'tcx>,
     ) -> Result<Option<ty::ValTree<'tcx>>, ErrorHandled> {
-        let uv = match constant.literal {
+        let uv = match self.monomorphize(constant.literal) {
             mir::ConstantKind::Unevaluated(uv, _) => uv.shrink(),
+            mir::ConstantKind::Ty(c) => match c.kind() {
+                // A constant that came from a const generic but was then used as an argument to old-style
+                // simd_shuffle (passing as argument instead of as a generic param).
+                rustc_type_ir::ConstKind::Value(valtree) => return Ok(Some(valtree)),
+                other => span_bug!(constant.span, "{other:#?}"),
+            },
+            // We should never encounter `ConstantKind::Val` unless MIR opts (like const prop) evaluate
+            // a constant and write that value back into `Operand`s. This could happen, but is unlikely.
+            // Also: all users of `simd_shuffle` are on unstable and already need to take a lot of care
+            // around intrinsics. For an issue to happen here, it would require a macro expanding to a
+            // `simd_shuffle` call without wrapping the constant argument in a `const {}` block, but
+            // the user pass through arbitrary expressions.
+            // FIXME(oli-obk): replace the magic const generic argument of `simd_shuffle` with a real
+            // const generic.
             other => span_bug!(constant.span, "{other:#?}"),
         };
         let uv = self.monomorphize(uv);