summaryrefslogtreecommitdiffstats
path: root/src/test/ui/object-safety/object-safety-associated-consts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/object-safety/object-safety-associated-consts.rs')
-rw-r--r--src/test/ui/object-safety/object-safety-associated-consts.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/object-safety/object-safety-associated-consts.rs b/src/test/ui/object-safety/object-safety-associated-consts.rs
new file mode 100644
index 000000000..e1a772e5a
--- /dev/null
+++ b/src/test/ui/object-safety/object-safety-associated-consts.rs
@@ -0,0 +1,19 @@
+// Check that we correctly prevent users from making trait objects
+// from traits with associated consts.
+//
+// revisions: curr object_safe_for_dispatch
+
+#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
+
+trait Bar {
+ const X: usize;
+}
+
+fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
+ //[curr]~^ ERROR E0038
+ t
+ //[object_safe_for_dispatch]~^ ERROR E0038
+}
+
+fn main() {
+}