]> git.lizzy.rs Git - rust.git/commitdiff
Make try_mark_previous_green aware of cycles.
authorAlex Aktsipetrov <alex.akts@gmail.com>
Fri, 6 Dec 2019 09:48:53 +0000 (12:48 +0300)
committerAlex Aktsipetrov <alex.akts@gmail.com>
Fri, 6 Dec 2019 09:48:53 +0000 (12:48 +0300)
src/librustc/dep_graph/graph.rs
src/test/incremental/issue-61323.rs [new file with mode: 0644]

index 0104507f7020ff30b940af4ffe85eaf85492f33e..d952bf7ab9e2541ee18f8d4c62e4c8a3ea14a494 100644 (file)
@@ -710,14 +710,25 @@ fn try_mark_previous_green<'tcx>(
                                 return None
                             }
                             None => {
-                                if !tcx.sess.has_errors() {
+                                if !tcx.sess.has_errors_or_delayed_span_bugs() {
                                     bug!("try_mark_previous_green() - Forcing the DepNode \
                                           should have set its color")
                                 } else {
-                                    // If the query we just forced has resulted
-                                    // in some kind of compilation error, we
-                                    // don't expect that the corresponding
-                                    // dep-node color has been updated.
+                                    // If the query we just forced has resulted in
+                                    // some kind of compilation error, we cannot rely on
+                                    // the dep-node color having been properly updated.
+                                    // This means that the query system has reached an
+                                    // invalid state. We let the compiler continue (by
+                                    // returning `None`) so it can emit error messages
+                                    // and wind down, but rely on the fact that this
+                                    // invalid state will not be persisted to the
+                                    // incremental compilation cache because of
+                                    // compilation errors being present.
+                                    debug!("try_mark_previous_green({:?}) - END - \
+                                            dependency {:?} resulted in compilation error",
+                                           dep_node,
+                                           dep_dep_node);
+                                    return None
                                 }
                             }
                         }
diff --git a/src/test/incremental/issue-61323.rs b/src/test/incremental/issue-61323.rs
new file mode 100644 (file)
index 0000000..448ce36
--- /dev/null
@@ -0,0 +1,15 @@
+// revisions: rpass cfail
+
+enum A {
+    //[cfail]~^ ERROR 3:1: 3:7: recursive type `A` has infinite size [E0072]
+    B(C),
+}
+
+#[cfg(rpass)]
+struct C(Box<A>);
+
+#[cfg(cfail)]
+struct C(A);
+//[cfail]~^ ERROR 12:1: 12:13: recursive type `C` has infinite size [E0072]
+
+fn main() {}