summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions/constrain-trait.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/suggestions/constrain-trait.fixed')
-rw-r--r--src/test/ui/suggestions/constrain-trait.fixed47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/constrain-trait.fixed b/src/test/ui/suggestions/constrain-trait.fixed
new file mode 100644
index 000000000..f292f27f0
--- /dev/null
+++ b/src/test/ui/suggestions/constrain-trait.fixed
@@ -0,0 +1,47 @@
+// run-rustfix
+// check-only
+
+#[derive(Debug)]
+struct Demo {
+ a: String
+}
+
+trait GetString {
+ fn get_a(&self) -> &String;
+}
+
+trait UseString: std::fmt::Debug + GetString {
+ fn use_string(&self) {
+ println!("{:?}", self.get_a()); //~ ERROR no method named `get_a` found
+ }
+}
+
+trait UseString2: GetString {
+ fn use_string(&self) {
+ println!("{:?}", self.get_a()); //~ ERROR no method named `get_a` found
+ }
+}
+
+impl GetString for Demo {
+ fn get_a(&self) -> &String {
+ &self.a
+ }
+}
+
+impl UseString for Demo {}
+impl UseString2 for Demo {}
+
+
+#[cfg(test)]
+mod tests {
+ use crate::{Demo, UseString};
+
+ #[test]
+ fn it_works() {
+ let d = Demo { a: "test".to_string() };
+ d.use_string();
+ }
+}
+
+
+fn main() {}