summary refs log tree commit diff
path: root/tests/ui/traits/default-method-lifetime-params-13204.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/default-method-lifetime-params-13204.rs')
-rw-r--r--tests/ui/traits/default-method-lifetime-params-13204.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/traits/default-method-lifetime-params-13204.rs b/tests/ui/traits/default-method-lifetime-params-13204.rs
new file mode 100644
index 00000000000..cdf34ab773c
--- /dev/null
+++ b/tests/ui/traits/default-method-lifetime-params-13204.rs
@@ -0,0 +1,27 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/13204
+
+//@ run-pass
+#![allow(unused_mut)]
+// Test that when instantiating trait default methods, typeck handles
+// lifetime parameters defined on the method bound correctly.
+
+
+pub trait Foo {
+    fn bar<'a, I: Iterator<Item=&'a ()>>(&self, it: I) -> usize {
+        let mut xs = it.filter(|_| true);
+        xs.count()
+    }
+}
+
+pub struct Baz;
+
+impl Foo for Baz {
+    // When instantiating `Foo::bar` for `Baz` here, typeck used to
+    // ICE due to the lifetime parameter of `bar`.
+}
+
+fn main() {
+    let x = Baz;
+    let y = vec![(), (), ()];
+    assert_eq!(x.bar(y.iter()), 3);
+}