about summary refs log tree commit diff
path: root/src/test/ui/methods
diff options
context:
space:
mode:
authorAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-05-22 12:03:37 +0200
committerAliƩnore Bouttefeux <alienore.bouttefeux@gmail.com>2021-05-22 12:38:48 +0200
commit120691c590c4309fda31994931b9a561b4249c33 (patch)
tree695814ce5cb4f0d67d5e12b604129bc097d66f6a /src/test/ui/methods
parent5b802ed6c9fd23214f9201b8e05193c8a2240e73 (diff)
downloadrust-120691c590c4309fda31994931b9a561b4249c33.tar.gz
rust-120691c590c4309fda31994931b9a561b4249c33.zip
change from review and show full type if it can be deref
Diffstat (limited to 'src/test/ui/methods')
-rw-r--r--src/test/ui/methods/method-not-found-generic-arg-elision.rs20
-rw-r--r--src/test/ui/methods/method-not-found-generic-arg-elision.stderr46
2 files changed, 50 insertions, 16 deletions
diff --git a/src/test/ui/methods/method-not-found-generic-arg-elision.rs b/src/test/ui/methods/method-not-found-generic-arg-elision.rs
index 23f01fb861f..3df928b5d80 100644
--- a/src/test/ui/methods/method-not-found-generic-arg-elision.rs
+++ b/src/test/ui/methods/method-not-found-generic-arg-elision.rs
@@ -1,6 +1,7 @@
 // Test for issue 81576
 // Remove generic arguments if no method is found for all possible generic argument
 
+use std::marker::PhantomData;
 
 struct Wrapper2<'a, T, const C: usize> {
     x: &'a T,
@@ -19,8 +20,6 @@ impl<'a, const C: usize> Wrapper2<'a, i32, C> {
 }
 struct Wrapper<T>(T);
 
-
-
 impl Wrapper<i8> {
     fn method(&self) {}
 }
@@ -62,6 +61,20 @@ impl Other {
     fn other(&self) {}
 }
 
+struct Struct<T>{
+    _phatom: PhantomData<T>
+}
+
+impl<T> Default for Struct<T> {
+    fn default() -> Self {
+        Self{ _phatom: PhantomData }
+    }
+}
+
+impl<T: Clone + Copy + PartialEq + Eq + PartialOrd + Ord> Struct<T> {
+    fn method(&self) {}
+}
+
 fn main() {
     let point_f64 = Point{ x: 1_f64, y: 1_f64};
     let d = point_f64.distance();
@@ -87,4 +100,7 @@ fn main() {
     let a = vec![1, 2, 3];
     a.not_found();
     //~^ ERROR no method named `not_found` found for struct `Vec
+    let s = Struct::<f64>::default();
+    s.method();
+    //~^ ERROR the method `method` exists for struct `Struct<f64>`, but its trait bounds were not satisfied
 }
diff --git a/src/test/ui/methods/method-not-found-generic-arg-elision.stderr b/src/test/ui/methods/method-not-found-generic-arg-elision.stderr
index 65dbabbc143..4a9cfb4fc80 100644
--- a/src/test/ui/methods/method-not-found-generic-arg-elision.stderr
+++ b/src/test/ui/methods/method-not-found-generic-arg-elision.stderr
@@ -1,5 +1,5 @@
 error[E0599]: no method named `distance` found for struct `Point<i32>` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:69:23
+  --> $DIR/method-not-found-generic-arg-elision.rs:82:23
    |
 LL | struct Point<T> {
    | --------------- method `distance` not found for this
@@ -7,10 +7,10 @@ LL | struct Point<T> {
 LL |     let d = point_i32.distance();
    |                       ^^^^^^^^ method not found in `Point<i32>`
    |
-   = note: The method was found for Point<f64>.
+   = note: the method was found for Point<f64>
 
 error[E0599]: no method named `other` found for struct `Point` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:71:23
+  --> $DIR/method-not-found-generic-arg-elision.rs:84:23
    |
 LL | struct Point<T> {
    | --------------- method `other` not found for this
@@ -19,13 +19,13 @@ LL |     let d = point_i32.other();
    |                       ^^^^^ method not found in `Point<i32>`
 
 error[E0599]: no method named `extend` found for struct `Map` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:74:29
+  --> $DIR/method-not-found-generic-arg-elision.rs:87:29
    |
 LL |     v.iter().map(|x| x * x).extend(std::iter::once(100));
-   |                             ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@$DIR/method-not-found-generic-arg-elision.rs:74:18: 74:27]>`
+   |                             ^^^^^^ method not found in `Map<std::slice::Iter<'_, i32>, [closure@$DIR/method-not-found-generic-arg-elision.rs:87:18: 87:27]>`
 
 error[E0599]: no method named `method` found for struct `Wrapper<bool>` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:77:13
+  --> $DIR/method-not-found-generic-arg-elision.rs:90:13
    |
 LL | struct Wrapper<T>(T);
    | --------------------- method `method` not found for this
@@ -33,10 +33,13 @@ LL | struct Wrapper<T>(T);
 LL |     wrapper.method();
    |             ^^^^^^ method not found in `Wrapper<bool>`
    |
-   = note: The method was found for Wrapper<i8>, Wrapper<u16>, Wrapper<u16> and 3 more.
+   = note: the method was found for Wrapper<i8>
+   = note: the method was found for Wrapper<i16>
+   = note: the method was found for Wrapper<i32>
+   = note: the method was found for 3 more types
 
 error[E0599]: no method named `other` found for struct `Wrapper` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:79:13
+  --> $DIR/method-not-found-generic-arg-elision.rs:92:13
    |
 LL | struct Wrapper<T>(T);
    | --------------------- method `other` not found for this
@@ -45,7 +48,7 @@ LL |     wrapper.other();
    |             ^^^^^ method not found in `Wrapper<bool>`
 
 error[E0599]: no method named `method` found for struct `Wrapper2<'_, bool, 3_usize>` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:83:13
+  --> $DIR/method-not-found-generic-arg-elision.rs:96:13
    |
 LL | struct Wrapper2<'a, T, const C: usize> {
    | -------------------------------------- method `method` not found for this
@@ -53,10 +56,12 @@ LL | struct Wrapper2<'a, T, const C: usize> {
 LL |     wrapper.method();
    |             ^^^^^^ method not found in `Wrapper2<'_, bool, 3_usize>`
    |
-   = note: The method was found for Wrapper2<'a, i8, C>, Wrapper2<'a, i32, C> and Wrapper2<'a, i32, C>.
+   = note: the method was found for Wrapper2<'a, i8, C>
+   = note: the method was found for Wrapper2<'a, i16, C>
+   = note: the method was found for Wrapper2<'a, i32, C>
 
 error[E0599]: no method named `other` found for struct `Wrapper2` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:85:13
+  --> $DIR/method-not-found-generic-arg-elision.rs:98:13
    |
 LL | struct Wrapper2<'a, T, const C: usize> {
    | -------------------------------------- method `other` not found for this
@@ -64,12 +69,25 @@ LL | struct Wrapper2<'a, T, const C: usize> {
 LL |     wrapper.other();
    |             ^^^^^ method not found in `Wrapper2<'_, bool, 3_usize>`
 
-error[E0599]: no method named `not_found` found for struct `Vec` in the current scope
-  --> $DIR/method-not-found-generic-arg-elision.rs:88:7
+error[E0599]: no method named `not_found` found for struct `Vec<{integer}>` in the current scope
+  --> $DIR/method-not-found-generic-arg-elision.rs:101:7
    |
 LL |     a.not_found();
    |       ^^^^^^^^^ method not found in `Vec<{integer}>`
 
-error: aborting due to 8 previous errors
+error[E0599]: the method `method` exists for struct `Struct<f64>`, but its trait bounds were not satisfied
+  --> $DIR/method-not-found-generic-arg-elision.rs:104:7
+   |
+LL | struct Struct<T>{
+   | ---------------- method `method` not found for this
+...
+LL |     s.method();
+   |       ^^^^^^ method cannot be called on `Struct<f64>` due to unsatisfied trait bounds
+   |
+   = note: the following trait bounds were not satisfied:
+           `f64: Eq`
+           `f64: Ord`
+
+error: aborting due to 9 previous errors
 
 For more information about this error, try `rustc --explain E0599`.