@@ -1615,6 +1615,14 @@ impl<'a, S: Specialization> InferCx<'a, S> {
1615
1615
1616
1616
#[ allow( clippy:: match_same_arms) ]
1617
1617
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
+
1618
1626
// Instances of "generic" globals/functions must be of the same ID,
1619
1627
// and their `generic_args` inference variables must be unified.
1620
1628
(
@@ -1999,13 +2007,13 @@ impl<'a, S: Specialization> InferCx<'a, S> {
1999
2007
2000
2008
if let Some ( type_of_result) = type_of_result {
2001
2009
// 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 .
2003
2011
match type_of_result {
2004
- InferOperand :: Var ( _) | InferOperand :: Instance ( _) => {
2012
+ InferOperand :: Var ( _) | InferOperand :: Instance ( _) | InferOperand :: Concrete ( _ ) => {
2005
2013
self . type_of_result
2006
2014
. insert ( inst. result_id . unwrap ( ) , type_of_result) ;
2007
2015
}
2008
- InferOperand :: Unknown | InferOperand :: Concrete ( _ ) => { }
2016
+ InferOperand :: Unknown => { }
2009
2017
}
2010
2018
}
2011
2019
}
0 commit comments