diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-27697.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-27697.rs b/src/test/ui/issues/issue-27697.rs new file mode 100644 index 000000000..12af8a8e8 --- /dev/null +++ b/src/test/ui/issues/issue-27697.rs @@ -0,0 +1,21 @@ +// check-pass + +use std::ops::Deref; + +trait MyTrait { + fn do_something(&self); + fn as_str(&self) -> &str; +} + +impl Deref for dyn MyTrait { + type Target = str; + fn deref(&self) -> &Self::Target { + self.as_str() + } +} + +fn trait_object_does_something(t: &dyn MyTrait) { + t.do_something() +} + +fn main() {} |