summaryrefslogtreecommitdiffstats
path: root/src/test/ui/variance/variance-trait-object-bound.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/variance/variance-trait-object-bound.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/variance/variance-trait-object-bound.rs b/src/test/ui/variance/variance-trait-object-bound.rs
new file mode 100644
index 000000000..ec3c973bc
--- /dev/null
+++ b/src/test/ui/variance/variance-trait-object-bound.rs
@@ -0,0 +1,18 @@
+// Checks that regions which appear in a trait object type are
+// observed by the variance inference algorithm (and hence
+// `TOption` is contavariant w/r/t `'a` and not bivariant).
+//
+// Issue #18262.
+
+#![feature(rustc_attrs)]
+
+use std::mem;
+
+trait T { fn foo(&self); }
+
+#[rustc_variance]
+struct TOption<'a> { //~ ERROR [-]
+ v: Option<Box<dyn T + 'a>>,
+}
+
+fn main() { }