about summary refs log tree commit diff
path: root/tests/ui/illegal-sized-bound/regular.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/illegal-sized-bound/regular.rs')
-rw-r--r--tests/ui/illegal-sized-bound/regular.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/illegal-sized-bound/regular.rs b/tests/ui/illegal-sized-bound/regular.rs
new file mode 100644
index 00000000000..7abd27ef983
--- /dev/null
+++ b/tests/ui/illegal-sized-bound/regular.rs
@@ -0,0 +1,32 @@
+struct MutType;
+
+pub trait MutTrait {
+    fn function(&mut self)
+    where
+        Self: Sized;
+    //~^ this has a `Sized` requirement
+}
+
+impl MutTrait for MutType {
+    fn function(&mut self) {}
+}
+
+struct Type;
+
+pub trait Trait {
+    fn function(&self)
+    where
+        Self: Sized;
+    //~^ this has a `Sized` requirement
+}
+
+impl Trait for Type {
+    fn function(&self) {}
+}
+
+fn main() {
+    (&mut MutType as &mut dyn MutTrait).function();
+    //~^ ERROR the `function` method cannot be invoked on a trait object
+    (&Type as &dyn Trait).function();
+    //~^ ERROR the `function` method cannot be invoked on a trait object
+}