about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2017-02-16 13:55:08 -0500
committerNiko Matsakis <niko@alum.mit.edu>2017-02-16 13:56:06 -0500
commitf2d8a0019188d4db19afc22a3fd8e3df28b28da9 (patch)
tree3682d58b75e136d44a4ef023b2640929e1a9f12a /src/test
parentccd96c945fb5d3a0841e0f9469d27f1fc8142edd (diff)
erase late bound regions in `get_vtable_methods()`
Higher-ranked object types can otherwise cause late-bound regions to
sneak into the substs, leading to the false conclusion that some method
is unreachable.  The heart of this patch is from @arielb1.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/issue-39292.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/run-pass/issue-39292.rs b/src/test/run-pass/issue-39292.rs
new file mode 100644
index 00000000000..dc2b21f3470
--- /dev/null
+++ b/src/test/run-pass/issue-39292.rs
@@ -0,0 +1,26 @@
+// 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 issue #39292. The object vtable was being
+// incorrectly left with a null pointer.
+
+trait Foo<T> {
+    fn print<'a>(&'a self) where T: 'a { println!("foo"); }
+}
+
+impl<'a> Foo<&'a ()> for () { }
+
+trait Bar: for<'a> Foo<&'a ()> { }
+
+impl Bar for () {}
+
+fn main() {
+    (&() as &Bar).print(); // Segfault
+}