]> git.lizzy.rs Git - rust.git/commitdiff
Split non-fixable case to different test
authorclubby789 <jamie@hill-daniel.co.uk>
Sun, 25 Sep 2022 23:33:08 +0000 (00:33 +0100)
committerclubby789 <jamie@hill-daniel.co.uk>
Sat, 5 Nov 2022 22:56:38 +0000 (22:56 +0000)
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs [new file with mode: 0644]
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr [new file with mode: 0644]
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr

diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs
new file mode 100644 (file)
index 0000000..a39b871
--- /dev/null
@@ -0,0 +1,11 @@
+struct GenericAssocMethod<T>(T);
+
+impl<T> GenericAssocMethod<T> {
+    fn default_hello() {}
+}
+
+fn main() {
+    let x = GenericAssocMethod(33);
+    x.default_hello();
+    //~^ ERROR no method named `default_hello` found
+}
diff --git a/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr b/src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr
new file mode 100644 (file)
index 0000000..c247e73
--- /dev/null
@@ -0,0 +1,22 @@
+error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
+  --> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:9:7
+   |
+LL | struct GenericAssocMethod<T>(T);
+   | ---------------------------- method `default_hello` not found for this struct
+...
+LL |     x.default_hello();
+   |     --^^^^^^^^^^^^^--
+   |     | |
+   |     | this is an associated function, not a method
+   |     help: use associated function syntax instead: `GenericAssocMethod::<_>::default_hello()`
+   |
+   = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
+note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
+  --> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:4:5
+   |
+LL |     fn default_hello() {}
+   |     ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
index 0398c510feac3e56eac04fe52c17e82e6e4b69fd..02dd0715c8011dade2fa2bfe73e58b9d7d9bb48d 100644 (file)
@@ -11,9 +11,6 @@ impl<T> GenericAssocMethod<T> {
 fn main() {
     // Test for inferred types
     let x = GenericAssocMethod(33);
-    // This particular case is unfixable without more information by the user,
-    // but `cargo fix --broken-code` reports a bug if
-    // x.default_hello();
     GenericAssocMethod::<_>::self_ty_ref_hello(&x);
     //~^ ERROR no method named `self_ty_ref_hello` found
     GenericAssocMethod::<_>::self_ty_hello(x);
index 8bafc83bdd0b326f9f0d0cb4b142ff3e0c4a10ab..1d0ca8e780abf85a88dab2bab833a6d763baa835 100644 (file)
@@ -11,9 +11,6 @@ fn self_ty_ref_hello(_: &Self) {}
 fn main() {
     // Test for inferred types
     let x = GenericAssocMethod(33);
-    // This particular case is unfixable without more information by the user,
-    // but `cargo fix --broken-code` reports a bug if
-    // x.default_hello();
     x.self_ty_ref_hello();
     //~^ ERROR no method named `self_ty_ref_hello` found
     x.self_ty_hello();
index e2f2d46b9e8b81e6c6a545a2172d5407354b1fd2..92b03fc77142c3f4bf7f6a260fa69bbe1babd4b1 100644 (file)
@@ -1,5 +1,5 @@
 error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
-  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:17:7
+  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:14:7
    |
 LL | struct GenericAssocMethod<T>(T);
    | ---------------------------- method `self_ty_ref_hello` not found for this struct
@@ -18,7 +18,7 @@ LL |     fn self_ty_ref_hello(_: &Self) {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope
-  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:19:7
+  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:16:7
    |
 LL | struct GenericAssocMethod<T>(T);
    | ---------------------------- method `self_ty_hello` not found for this struct
@@ -37,7 +37,7 @@ LL |     fn self_ty_hello(_: Self) {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<i32>` in the current scope
-  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:23:7
+  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:20:7
    |
 LL | struct GenericAssocMethod<T>(T);
    | ---------------------------- method `default_hello` not found for this struct
@@ -56,7 +56,7 @@ LL |     fn default_hello() {}
    |     ^^^^^^^^^^^^^^^^^^
 
 error[E0599]: no method named `self_ty_ref_hello` found for struct `GenericAssocMethod<i32>` in the current scope
-  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:25:7
+  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:22:7
    |
 LL | struct GenericAssocMethod<T>(T);
    | ---------------------------- method `self_ty_ref_hello` not found for this struct
@@ -75,7 +75,7 @@ LL |     fn self_ty_ref_hello(_: &Self) {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0599]: no method named `self_ty_hello` found for struct `GenericAssocMethod<i32>` in the current scope
-  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:27:7
+  --> $DIR/suggest-assoc-fn-call-with-turbofish.rs:24:7
    |
 LL | struct GenericAssocMethod<T>(T);
    | ---------------------------- method `self_ty_hello` not found for this struct