Skip to content

Commit 660725d

Browse files
committed
Allow explicitly concrete instruction result types to specialize generic instances
1 parent e8852c7 commit 660725d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

crates/rustc_codegen_spirv/src/linker/specializer.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,14 @@ impl<'a, S: Specialization> InferCx<'a, S> {
16151615

16161616
#[allow(clippy::match_same_arms)]
16171617
Ok(match (a.clone(), b.clone()) {
1618+
// Concrete result types explicitly created inside functions
1619+
// can be assigned to instances.
1620+
// FIXME(jwollen) do we need to infere instance generics?
1621+
(InferOperand::Instance(_), InferOperand::Concrete(new))
1622+
| (InferOperand::Concrete(new), InferOperand::Instance(_)) => {
1623+
InferOperand::Concrete(new)
1624+
}
1625+
16181626
// Instances of "generic" globals/functions must be of the same ID,
16191627
// and their `generic_args` inference variables must be unified.
16201628
(
@@ -1999,13 +2007,13 @@ impl<'a, S: Specialization> InferCx<'a, S> {
19992007

20002008
if let Some(type_of_result) = type_of_result {
20012009
// Keep the (instantiated) *Result Type*, for future instructions to use
2002-
// (but only if it has any `InferVar`s at all).
2010+
// if it has any `InferVar`s at all or if it was a concrete type.
20032011
match type_of_result {
2004-
InferOperand::Var(_) | InferOperand::Instance(_) => {
2012+
InferOperand::Var(_) | InferOperand::Instance(_) | InferOperand::Concrete(_) => {
20052013
self.type_of_result
20062014
.insert(inst.result_id.unwrap(), type_of_result);
20072015
}
2008-
InferOperand::Unknown | InferOperand::Concrete(_) => {}
2016+
InferOperand::Unknown => {}
20092017
}
20102018
}
20112019
}

0 commit comments

Comments
 (0)