about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLimira <2409315-limira-rs@users.noreply.gitlab.com>2019-07-16 11:30:48 +0700
committerLimira <2409315-limira-rs@users.noreply.gitlab.com>2019-07-16 11:30:48 +0700
commitb7cbd4ec47640323e5b25cc64110f5ff414e4946 (patch)
tree56c4d623a0482ad1545be725a7f0889d9e8ba5a0
parent4b65a86ebace8600c8e269e8bfe3365cdc460e68 (diff)
downloadrust-b7cbd4ec47640323e5b25cc64110f5ff414e4946.tar.gz
rust-b7cbd4ec47640323e5b25cc64110f5ff414e4946.zip
Update the help message on error for self type
-rw-r--r--src/librustc_typeck/check/wfcheck.rs10
-rw-r--r--src/test/ui/feature-gates/feature-gate-arbitrary-self-types.stderr6
-rw-r--r--src/test/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr6
-rw-r--r--src/test/ui/issues/issue-56806.stderr2
-rw-r--r--src/test/ui/span/issue-27522.stderr2
-rw-r--r--src/test/ui/ufcs/ufcs-explicit-self-bad.stderr6
6 files changed, 18 insertions, 14 deletions
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index 68e5e7d4fd2..32f1f8c6188 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -769,6 +769,10 @@ fn check_method_receiver<'fcx, 'tcx>(
     method: &ty::AssocItem,
     self_ty: Ty<'tcx>,
 ) {
+    const HELP_FOR_SELF_TYPE: &str =
+        "consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, \
+         `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one \
+         of the previous types except `Self`)";
     // Check that the method has a valid receiver type, given the type `Self`.
     debug!("check_method_receiver({:?}, self_ty={:?})",
            method, self_ty);
@@ -805,7 +809,7 @@ fn check_method_receiver<'fcx, 'tcx>(
             fcx.tcx.sess.diagnostic().mut_span_err(
                 span, &format!("invalid method receiver type: {:?}", receiver_ty)
             ).note("type of `self` must be `Self` or a type that dereferences to it")
-            .help("consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`")
+            .help(HELP_FOR_SELF_TYPE)
             .code(DiagnosticId::Error("E0307".into()))
             .emit();
         }
@@ -823,14 +827,14 @@ fn check_method_receiver<'fcx, 'tcx>(
                             the `arbitrary_self_types` feature",
                         receiver_ty,
                     ),
-                ).help("consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`")
+                ).help(HELP_FOR_SELF_TYPE)
                 .emit();
             } else {
                 // Report error; would not have worked with `arbitrary_self_types`.
                 fcx.tcx.sess.diagnostic().mut_span_err(
                     span, &format!("invalid method receiver type: {:?}", receiver_ty)
                 ).note("type must be `Self` or a type that dereferences to it")
-                .help("consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`")
+                .help(HELP_FOR_SELF_TYPE)
                 .code(DiagnosticId::Error("E0307".into()))
                 .emit();
             }
diff --git a/src/test/ui/feature-gates/feature-gate-arbitrary-self-types.stderr b/src/test/ui/feature-gates/feature-gate-arbitrary-self-types.stderr
index ed5fef68918..a70bf1f1990 100644
--- a/src/test/ui/feature-gates/feature-gate-arbitrary-self-types.stderr
+++ b/src/test/ui/feature-gates/feature-gate-arbitrary-self-types.stderr
@@ -6,7 +6,7 @@ LL |     fn foo(self: Ptr<Self>);
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/44874
    = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0658]: `Ptr<Bar>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
   --> $DIR/feature-gate-arbitrary-self-types.rs:22:18
@@ -16,7 +16,7 @@ LL |     fn foo(self: Ptr<Self>) {}
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/44874
    = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0658]: `std::boxed::Box<Ptr<Bar>>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
   --> $DIR/feature-gate-arbitrary-self-types.rs:26:18
@@ -26,7 +26,7 @@ LL |     fn bar(self: Box<Ptr<Self>>) {}
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/44874
    = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr b/src/test/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr
index 4963f9f461c..0f8863b8715 100644
--- a/src/test/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr
+++ b/src/test/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr
@@ -6,7 +6,7 @@ LL |     fn bar(self: *const Self);
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/44874
    = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0658]: `*const Foo` cannot be used as the type of `self` without the `arbitrary_self_types` feature
   --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:4:18
@@ -16,7 +16,7 @@ LL |     fn foo(self: *const Self) {}
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/44874
    = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0658]: `*const ()` cannot be used as the type of `self` without the `arbitrary_self_types` feature
   --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:14:18
@@ -26,7 +26,7 @@ LL |     fn bar(self: *const Self) {}
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/44874
    = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/issues/issue-56806.stderr b/src/test/ui/issues/issue-56806.stderr
index 96979b9dc1e..fae6a26720f 100644
--- a/src/test/ui/issues/issue-56806.stderr
+++ b/src/test/ui/issues/issue-56806.stderr
@@ -5,7 +5,7 @@ LL |     fn dyn_instead_of_self(self: Box<dyn Trait>);
    |                                  ^^^^^^^^^^^^^^
    |
    = note: type must be `Self` or a type that dereferences to it
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/span/issue-27522.stderr b/src/test/ui/span/issue-27522.stderr
index 46f424b1927..88dfee1cada 100644
--- a/src/test/ui/span/issue-27522.stderr
+++ b/src/test/ui/span/issue-27522.stderr
@@ -5,7 +5,7 @@ LL |     fn handler(self: &SomeType);
    |                      ^^^^^^^^^
    |
    = note: type must be `Self` or a type that dereferences to it
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
index 1251d6eee80..6da20e37577 100644
--- a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
+++ b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr
@@ -5,7 +5,7 @@ LL |     fn foo(self: isize, x: isize) -> isize {
    |                  ^^^^^
    |
    = note: type must be `Self` or a type that dereferences to it
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0307]: invalid method receiver type: Bar<isize>
   --> $DIR/ufcs-explicit-self-bad.rs:19:18
@@ -14,7 +14,7 @@ LL |     fn foo(self: Bar<isize>, x: isize) -> isize {
    |                  ^^^^^^^^^^
    |
    = note: type must be `Self` or a type that dereferences to it
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0307]: invalid method receiver type: &Bar<usize>
   --> $DIR/ufcs-explicit-self-bad.rs:23:18
@@ -23,7 +23,7 @@ LL |     fn bar(self: &Bar<usize>, x: isize) -> isize {
    |                  ^^^^^^^^^^^
    |
    = note: type must be `Self` or a type that dereferences to it
-   = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
+   = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
 
 error[E0308]: mismatched method receiver
   --> $DIR/ufcs-explicit-self-bad.rs:37:21