about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-09-13 18:31:26 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-09-14 11:04:39 -0400
commit6353e30bb2d7968332217c04ac25e0800500fb33 (patch)
treecb7e73aa0816f4ad143ccf54adf1cbe4e74e3830 /src/test
parentc87ba3f1222ba20d491e8ed76a04977283280742 (diff)
downloadrust-6353e30bb2d7968332217c04ac25e0800500fb33.tar.gz
rust-6353e30bb2d7968332217c04ac25e0800500fb33.zip
clear obligations-added flag with nested fulfillcx
This flag is a debugging measure designed to detect cases where we start
a snapshot, create type variables, register obligations involving those
type variables in the fulfillment cx, and then have to unroll the
snapshot, leaving "dangling type variables" behind.  HOWEVER, in some
cases the flag is wrong. In particular, we sometimes create a
"mini-fulfilment-cx" in which we enroll obligations. As long as this
fulfillment cx is fully drained before we return, this is not a problem,
as there won't be any escaping obligations in the main cx. So we add a
fn to save/restore the flag.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-36053-2.rs21
-rw-r--r--src/test/run-pass/issue-36053.rs32
2 files changed, 53 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-36053-2.rs b/src/test/compile-fail/issue-36053-2.rs
new file mode 100644
index 00000000000..7da529487aa
--- /dev/null
+++ b/src/test/compile-fail/issue-36053-2.rs
@@ -0,0 +1,21 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Regression test for #36053. ICE was caused due to obligations
+// being added to a special, dedicated fulfillment cx during
+// a probe.
+
+use std::iter::once;
+fn main() {
+    once::<&str>("str").fuse().filter(|a: &str| true).count();
+    //~^ ERROR no method named `count`
+    //~| ERROR E0281
+    //~| ERROR E0281
+}
diff --git a/src/test/run-pass/issue-36053.rs b/src/test/run-pass/issue-36053.rs
new file mode 100644
index 00000000000..2411996cf05
--- /dev/null
+++ b/src/test/run-pass/issue-36053.rs
@@ -0,0 +1,32 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Regression test for #36053. ICE was caused due to obligations being
+// added to a special, dedicated fulfillment cx during a
+// probe. Problem seems to be related to the particular definition of
+// `FusedIterator` in std but I was not able to isolate that into an
+// external crate.
+
+#![feature(fused)]
+use std::iter::FusedIterator;
+
+struct Thing<'a>(&'a str);
+impl<'a> Iterator for Thing<'a> {
+    type Item = &'a str;
+    fn next(&mut self) -> Option<&'a str> {
+        None
+    }
+}
+
+impl<'a> FusedIterator for Thing<'a> {}
+
+fn main() {
+    Thing("test").fuse().filter(|_| true).count();
+}