]> git.lizzy.rs Git - rust.git/commitdiff
Explain why we can encounter a `Goto` terminator that we want to promote
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 25 Oct 2018 17:37:07 +0000 (19:37 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 25 Oct 2018 17:37:07 +0000 (19:37 +0200)
src/librustc_mir/transform/promote_consts.rs

index bba9260f2b829f2dc965bd30257ac317309d8b81..1d45850a080d510e8ff056d54cd7eb13c2697667 100644 (file)
@@ -332,7 +332,13 @@ fn interior_base<'a, 'tcx>(place: &'a mut Place<'tcx>)
                             let operand = Operand::Copy(promoted_place(ty, span));
                             mem::replace(&mut args[index], operand)
                         }
-                        // already promoted out
+                        // We expected a `TerminatorKind::Call` for which we'd like to promote an
+                        // argument. Since `qualify_consts` saw a `TerminatorKind::Call` here, but
+                        // we are seeing a `Goto`, that means that the `promote_temps` method
+                        // already promoted this call away entirely. This case occurs when calling
+                        // a function requiring a constant argument and as that constant value
+                        // providing a value whose computation contains another call to a function
+                        // requiring a constant argument.
                         TerminatorKind::Goto { .. } => return,
                         _ => bug!()
                     }