about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2018-06-08 17:00:36 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2018-06-08 17:00:36 +0100
commit0476a875d19bd79a4755d0e086cb5b62492aa66a (patch)
tree12b21527ccb87c265edbeed586992f5ccfbf7667
parent87f63ca258416e55d89879ea7f89a8ca1064b665 (diff)
downloadrust-0476a875d19bd79a4755d0e086cb5b62492aa66a.tar.gz
rust-0476a875d19bd79a4755d0e086cb5b62492aa66a.zip
Test that object bounds are preferred over global where clause bounds
-rw-r--r--src/test/ui/trivial-bounds-object.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/trivial-bounds-object.rs b/src/test/ui/trivial-bounds-object.rs
new file mode 100644
index 00000000000..00986eefbda
--- /dev/null
+++ b/src/test/ui/trivial-bounds-object.rs
@@ -0,0 +1,28 @@
+// Copyright 2018 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.
+
+// run-pass
+// Check that the object bound dyn A + 'a: A is preferred over the
+// where clause bound dyn A + 'static: A.
+
+#![allow(unused)]
+
+trait A {
+    fn test(&self);
+}
+
+fn foo(x: &dyn A)
+where
+    dyn A + 'static: A, // Using this bound would lead to a lifetime error.
+{
+    x.test();
+}
+
+fn main () {}