about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-02-02 14:15:52 +0100
committerGitHub <noreply@github.com>2020-02-02 14:15:52 +0100
commit5951cd3dda738ee6187ecea040738cbad57e04e4 (patch)
treed08a2ad41197c6305fbff803237b6ae90f5d1abb /src/test
parent2e1790dda1a097c2498960413dd8a89f0a18e05f (diff)
parent71a6f58229c00720b35579856bdb64e2a19af521 (diff)
downloadrust-5951cd3dda738ee6187ecea040738cbad57e04e4.tar.gz
rust-5951cd3dda738ee6187ecea040738cbad57e04e4.zip
Rollup merge of #68764 - Centril:self-semantic, r=petrochenkov
parser: syntactically allow `self` in all `fn` contexts

Part of https://github.com/rust-lang/rust/pull/68728.

`self` parameters are now *syntactically* allowed as the first parameter irrespective of item context (and in function pointers). Instead, semantic validation (`ast_validation`) is used.

r? @petrochenkov
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/invalid-self-argument/bare-fn-start.rs6
-rw-r--r--src/test/ui/invalid-self-argument/bare-fn-start.stderr6
-rw-r--r--src/test/ui/invalid-self-argument/bare-fn.rs3
-rw-r--r--src/test/ui/invalid-self-argument/bare-fn.stderr4
-rw-r--r--src/test/ui/invalid-self-argument/trait-fn.rs2
-rw-r--r--src/test/ui/invalid-self-argument/trait-fn.stderr2
-rw-r--r--src/test/ui/parser/inverted-parameters.rs1
-rw-r--r--src/test/ui/parser/inverted-parameters.stderr6
-rw-r--r--src/test/ui/parser/omitted-arg-in-item-fn.stderr4
-rw-r--r--src/test/ui/parser/pat-lt-bracket-2.stderr4
-rw-r--r--src/test/ui/parser/self-in-function-arg.stderr4
-rw-r--r--src/test/ui/parser/self-param-semantic-fail.rs64
-rw-r--r--src/test/ui/parser/self-param-semantic-fail.stderr220
-rw-r--r--src/test/ui/parser/self-param-syntactic-pass.rs66
-rw-r--r--src/test/ui/span/issue-34264.stderr8
-rw-r--r--src/test/ui/suggestions/issue-64252-self-type.stderr4
16 files changed, 387 insertions, 17 deletions
diff --git a/src/test/ui/invalid-self-argument/bare-fn-start.rs b/src/test/ui/invalid-self-argument/bare-fn-start.rs
index a003a01941b..7c580bc5a5d 100644
--- a/src/test/ui/invalid-self-argument/bare-fn-start.rs
+++ b/src/test/ui/invalid-self-argument/bare-fn-start.rs
@@ -1,6 +1,6 @@
 fn a(&self) { }
-//~^ ERROR unexpected `self` parameter in function
-//~| NOTE not valid as function parameter
-//~| NOTE `self` is only valid as the first parameter of an associated function
+//~^ ERROR `self` parameter is only allowed in associated functions
+//~| NOTE not semantically valid as function parameter
+//~| NOTE associated functions are those in `impl` or `trait` definitions
 
 fn main() { }
diff --git a/src/test/ui/invalid-self-argument/bare-fn-start.stderr b/src/test/ui/invalid-self-argument/bare-fn-start.stderr
index 23de6502094..37753e61f58 100644
--- a/src/test/ui/invalid-self-argument/bare-fn-start.stderr
+++ b/src/test/ui/invalid-self-argument/bare-fn-start.stderr
@@ -1,10 +1,10 @@
-error: unexpected `self` parameter in function
+error: `self` parameter is only allowed in associated functions
   --> $DIR/bare-fn-start.rs:1:6
    |
 LL | fn a(&self) { }
-   |      ^^^^^ not valid as function parameter
+   |      ^^^^^ not semantically valid as function parameter
    |
-   = note: `self` is only valid as the first parameter of an associated function
+   = note: associated functions are those in `impl` or `trait` definitions
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/invalid-self-argument/bare-fn.rs b/src/test/ui/invalid-self-argument/bare-fn.rs
index 73d68e8b7a5..342bdc31a7c 100644
--- a/src/test/ui/invalid-self-argument/bare-fn.rs
+++ b/src/test/ui/invalid-self-argument/bare-fn.rs
@@ -1,6 +1,5 @@
 fn b(foo: u32, &mut self) { }
 //~^ ERROR unexpected `self` parameter in function
-//~| NOTE not valid as function parameter
-//~| NOTE `self` is only valid as the first parameter of an associated function
+//~| NOTE must be the first parameter of an associated function
 
 fn main() { }
diff --git a/src/test/ui/invalid-self-argument/bare-fn.stderr b/src/test/ui/invalid-self-argument/bare-fn.stderr
index 601a51bb4a9..ff2217b5e80 100644
--- a/src/test/ui/invalid-self-argument/bare-fn.stderr
+++ b/src/test/ui/invalid-self-argument/bare-fn.stderr
@@ -2,9 +2,7 @@ error: unexpected `self` parameter in function
   --> $DIR/bare-fn.rs:1:16
    |
 LL | fn b(foo: u32, &mut self) { }
-   |                ^^^^^^^^^ not valid as function parameter
-   |
-   = note: `self` is only valid as the first parameter of an associated function
+   |                ^^^^^^^^^ must be the first parameter of an associated function
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/invalid-self-argument/trait-fn.rs b/src/test/ui/invalid-self-argument/trait-fn.rs
index 1e8220d7b4a..5ccea589561 100644
--- a/src/test/ui/invalid-self-argument/trait-fn.rs
+++ b/src/test/ui/invalid-self-argument/trait-fn.rs
@@ -3,7 +3,7 @@ struct Foo {}
 impl Foo {
     fn c(foo: u32, self) {}
     //~^ ERROR unexpected `self` parameter in function
-    //~| NOTE must be the first associated function parameter
+    //~| NOTE must be the first parameter of an associated function
 
     fn good(&mut self, foo: u32) {}
 }
diff --git a/src/test/ui/invalid-self-argument/trait-fn.stderr b/src/test/ui/invalid-self-argument/trait-fn.stderr
index 96a2251c036..b9887af962c 100644
--- a/src/test/ui/invalid-self-argument/trait-fn.stderr
+++ b/src/test/ui/invalid-self-argument/trait-fn.stderr
@@ -2,7 +2,7 @@ error: unexpected `self` parameter in function
   --> $DIR/trait-fn.rs:4:20
    |
 LL |     fn c(foo: u32, self) {}
-   |                    ^^^^ must be the first associated function parameter
+   |                    ^^^^ must be the first parameter of an associated function
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/inverted-parameters.rs b/src/test/ui/parser/inverted-parameters.rs
index d6efc8be072..6f19ee9c7dc 100644
--- a/src/test/ui/parser/inverted-parameters.rs
+++ b/src/test/ui/parser/inverted-parameters.rs
@@ -21,6 +21,7 @@ fn pattern((i32, i32) (a, b)) {}
 fn fizz(i32) {}
 //~^ ERROR expected one of `:`, `@`
 //~| HELP if this was a parameter name, give it a type
+//~| HELP if this is a `self` type, give it a parameter name
 //~| HELP if this is a type, explicitly ignore the parameter name
 
 fn missing_colon(quux S) {}
diff --git a/src/test/ui/parser/inverted-parameters.stderr b/src/test/ui/parser/inverted-parameters.stderr
index 51e9087ffc1..043ff65f74e 100644
--- a/src/test/ui/parser/inverted-parameters.stderr
+++ b/src/test/ui/parser/inverted-parameters.stderr
@@ -35,6 +35,10 @@ LL | fn fizz(i32) {}
    |            ^ expected one of `:`, `@`, or `|`
    |
    = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a `self` type, give it a parameter name
+   |
+LL | fn fizz(self: i32) {}
+   |         ^^^^^^^^^
 help: if this was a parameter name, give it a type
    |
 LL | fn fizz(i32: TypeName) {}
@@ -45,7 +49,7 @@ LL | fn fizz(_: i32) {}
    |         ^^^^^^
 
 error: expected one of `:`, `@`, or `|`, found `S`
-  --> $DIR/inverted-parameters.rs:26:23
+  --> $DIR/inverted-parameters.rs:27:23
    |
 LL | fn missing_colon(quux S) {}
    |                  -----^
diff --git a/src/test/ui/parser/omitted-arg-in-item-fn.stderr b/src/test/ui/parser/omitted-arg-in-item-fn.stderr
index c7c76a7f1d4..9f138bf84ce 100644
--- a/src/test/ui/parser/omitted-arg-in-item-fn.stderr
+++ b/src/test/ui/parser/omitted-arg-in-item-fn.stderr
@@ -5,6 +5,10 @@ LL | fn foo(x) {
    |         ^ expected one of `:`, `@`, or `|`
    |
    = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a `self` type, give it a parameter name
+   |
+LL | fn foo(self: x) {
+   |        ^^^^^^^
 help: if this was a parameter name, give it a type
    |
 LL | fn foo(x: TypeName) {
diff --git a/src/test/ui/parser/pat-lt-bracket-2.stderr b/src/test/ui/parser/pat-lt-bracket-2.stderr
index e51dd57f9c7..6db9a4a0f15 100644
--- a/src/test/ui/parser/pat-lt-bracket-2.stderr
+++ b/src/test/ui/parser/pat-lt-bracket-2.stderr
@@ -5,6 +5,10 @@ LL | fn a(B<) {}
    |       ^ expected one of `:`, `@`, or `|`
    |
    = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a `self` type, give it a parameter name
+   |
+LL | fn a(self: B<) {}
+   |      ^^^^^^^
 help: if this is a type, explicitly ignore the parameter name
    |
 LL | fn a(_: B<) {}
diff --git a/src/test/ui/parser/self-in-function-arg.stderr b/src/test/ui/parser/self-in-function-arg.stderr
index f58df9b9e79..47d8381b0b1 100644
--- a/src/test/ui/parser/self-in-function-arg.stderr
+++ b/src/test/ui/parser/self-in-function-arg.stderr
@@ -2,9 +2,7 @@ error: unexpected `self` parameter in function
   --> $DIR/self-in-function-arg.rs:1:15
    |
 LL | fn foo(x:i32, self: i32) -> i32 { self }
-   |               ^^^^ not valid as function parameter
-   |
-   = note: `self` is only valid as the first parameter of an associated function
+   |               ^^^^ must be the first parameter of an associated function
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/self-param-semantic-fail.rs b/src/test/ui/parser/self-param-semantic-fail.rs
new file mode 100644
index 00000000000..5676971b01a
--- /dev/null
+++ b/src/test/ui/parser/self-param-semantic-fail.rs
@@ -0,0 +1,64 @@
+// This test ensures that `self` is semantically rejected
+// in contexts with `FnDecl` but outside of associated `fn`s.
+// FIXME(Centril): For now closures are an exception.
+
+fn main() {}
+
+fn free() {
+    fn f1(self) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f2(mut self) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f3(&self) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f4(&mut self) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f5<'a>(&'a self) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f6<'a>(&'a mut self) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f7(self: u8) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f8(mut self: u8) {}
+    //~^ ERROR `self` parameter is only allowed in associated functions
+}
+
+extern {
+    fn f1(self);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f2(mut self);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    //~| ERROR patterns aren't allowed in
+    fn f3(&self);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f4(&mut self);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f5<'a>(&'a self);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f6<'a>(&'a mut self);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f7(self: u8);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    fn f8(mut self: u8);
+    //~^ ERROR `self` parameter is only allowed in associated functions
+    //~| ERROR patterns aren't allowed in
+}
+
+type X1 = fn(self);
+//~^ ERROR `self` parameter is only allowed in associated functions
+type X2 = fn(mut self);
+//~^ ERROR `self` parameter is only allowed in associated functions
+//~| ERROR patterns aren't allowed in
+type X3 = fn(&self);
+//~^ ERROR `self` parameter is only allowed in associated functions
+type X4 = fn(&mut self);
+//~^ ERROR `self` parameter is only allowed in associated functions
+type X5 = for<'a> fn(&'a self);
+//~^ ERROR `self` parameter is only allowed in associated functions
+type X6 = for<'a> fn(&'a mut self);
+//~^ ERROR `self` parameter is only allowed in associated functions
+type X7 = fn(self: u8);
+//~^ ERROR `self` parameter is only allowed in associated functions
+type X8 = fn(mut self: u8);
+//~^ ERROR `self` parameter is only allowed in associated functions
+//~| ERROR patterns aren't allowed in
diff --git a/src/test/ui/parser/self-param-semantic-fail.stderr b/src/test/ui/parser/self-param-semantic-fail.stderr
new file mode 100644
index 00000000000..e5d67977369
--- /dev/null
+++ b/src/test/ui/parser/self-param-semantic-fail.stderr
@@ -0,0 +1,220 @@
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:8:11
+   |
+LL |     fn f1(self) {}
+   |           ^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:10:11
+   |
+LL |     fn f2(mut self) {}
+   |           ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:12:11
+   |
+LL |     fn f3(&self) {}
+   |           ^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:14:11
+   |
+LL |     fn f4(&mut self) {}
+   |           ^^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:16:15
+   |
+LL |     fn f5<'a>(&'a self) {}
+   |               ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:18:15
+   |
+LL |     fn f6<'a>(&'a mut self) {}
+   |               ^^^^^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:20:11
+   |
+LL |     fn f7(self: u8) {}
+   |           ^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:22:11
+   |
+LL |     fn f8(mut self: u8) {}
+   |           ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:27:11
+   |
+LL |     fn f1(self);
+   |           ^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:29:11
+   |
+LL |     fn f2(mut self);
+   |           ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error[E0130]: patterns aren't allowed in foreign function declarations
+  --> $DIR/self-param-semantic-fail.rs:29:11
+   |
+LL |     fn f2(mut self);
+   |           ^^^^^^^^ pattern not allowed in foreign function
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:32:11
+   |
+LL |     fn f3(&self);
+   |           ^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:34:11
+   |
+LL |     fn f4(&mut self);
+   |           ^^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:36:15
+   |
+LL |     fn f5<'a>(&'a self);
+   |               ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:38:15
+   |
+LL |     fn f6<'a>(&'a mut self);
+   |               ^^^^^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:40:11
+   |
+LL |     fn f7(self: u8);
+   |           ^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:42:11
+   |
+LL |     fn f8(mut self: u8);
+   |           ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error[E0130]: patterns aren't allowed in foreign function declarations
+  --> $DIR/self-param-semantic-fail.rs:42:11
+   |
+LL |     fn f8(mut self: u8);
+   |           ^^^^^^^^ pattern not allowed in foreign function
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:47:14
+   |
+LL | type X1 = fn(self);
+   |              ^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:49:14
+   |
+LL | type X2 = fn(mut self);
+   |              ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error[E0561]: patterns aren't allowed in function pointer types
+  --> $DIR/self-param-semantic-fail.rs:49:14
+   |
+LL | type X2 = fn(mut self);
+   |              ^^^^^^^^
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:52:14
+   |
+LL | type X3 = fn(&self);
+   |              ^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:54:14
+   |
+LL | type X4 = fn(&mut self);
+   |              ^^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:56:22
+   |
+LL | type X5 = for<'a> fn(&'a self);
+   |                      ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:58:22
+   |
+LL | type X6 = for<'a> fn(&'a mut self);
+   |                      ^^^^^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:60:14
+   |
+LL | type X7 = fn(self: u8);
+   |              ^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error: `self` parameter is only allowed in associated functions
+  --> $DIR/self-param-semantic-fail.rs:62:14
+   |
+LL | type X8 = fn(mut self: u8);
+   |              ^^^^^^^^ not semantically valid as function parameter
+   |
+   = note: associated functions are those in `impl` or `trait` definitions
+
+error[E0561]: patterns aren't allowed in function pointer types
+  --> $DIR/self-param-semantic-fail.rs:62:14
+   |
+LL | type X8 = fn(mut self: u8);
+   |              ^^^^^^^^
+
+error: aborting due to 28 previous errors
+
+Some errors have detailed explanations: E0130, E0561.
+For more information about an error, try `rustc --explain E0130`.
diff --git a/src/test/ui/parser/self-param-syntactic-pass.rs b/src/test/ui/parser/self-param-syntactic-pass.rs
new file mode 100644
index 00000000000..9e215e6cdd4
--- /dev/null
+++ b/src/test/ui/parser/self-param-syntactic-pass.rs
@@ -0,0 +1,66 @@
+// This test ensures that `self` is syntactically accepted in all places an `FnDecl` is parsed.
+// FIXME(Centril): For now closures are an exception.
+
+// check-pass
+
+fn main() {}
+
+#[cfg(FALSE)]
+fn free() {
+    fn f(self) {}
+    fn f(mut self) {}
+    fn f(&self) {}
+    fn f(&mut self) {}
+    fn f(&'a self) {}
+    fn f(&'a mut self) {}
+    fn f(self: u8) {}
+    fn f(mut self: u8) {}
+}
+
+#[cfg(FALSE)]
+extern {
+    fn f(self);
+    fn f(mut self);
+    fn f(&self);
+    fn f(&mut self);
+    fn f(&'a self);
+    fn f(&'a mut self);
+    fn f(self: u8);
+    fn f(mut self: u8);
+}
+
+#[cfg(FALSE)]
+trait X {
+    fn f(self) {}
+    fn f(mut self) {}
+    fn f(&self) {}
+    fn f(&mut self) {}
+    fn f(&'a self) {}
+    fn f(&'a mut self) {}
+    fn f(self: u8) {}
+    fn f(mut self: u8) {}
+}
+
+#[cfg(FALSE)]
+impl X for Y {
+    fn f(self) {}
+    fn f(mut self) {}
+    fn f(&self) {}
+    fn f(&mut self) {}
+    fn f(&'a self) {}
+    fn f(&'a mut self) {}
+    fn f(self: u8) {}
+    fn f(mut self: u8) {}
+}
+
+#[cfg(FALSE)]
+impl X for Y {
+    type X = fn(self);
+    type X = fn(mut self);
+    type X = fn(&self);
+    type X = fn(&mut self);
+    type X = fn(&'a self);
+    type X = fn(&'a mut self);
+    type X = fn(self: u8);
+    type X = fn(mut self: u8);
+}
diff --git a/src/test/ui/span/issue-34264.stderr b/src/test/ui/span/issue-34264.stderr
index 56a2686945c..80a237ac6aa 100644
--- a/src/test/ui/span/issue-34264.stderr
+++ b/src/test/ui/span/issue-34264.stderr
@@ -5,6 +5,10 @@ LL | fn foo(Option<i32>, String) {}
    |              ^ expected one of `:`, `@`, or `|`
    |
    = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a `self` type, give it a parameter name
+   |
+LL | fn foo(self: Option<i32>, String) {}
+   |        ^^^^^^^^^^^^
 help: if this is a type, explicitly ignore the parameter name
    |
 LL | fn foo(_: Option<i32>, String) {}
@@ -33,6 +37,10 @@ LL | fn bar(x, y: usize) {}
    |         ^ expected one of `:`, `@`, or `|`
    |
    = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a `self` type, give it a parameter name
+   |
+LL | fn bar(self: x, y: usize) {}
+   |        ^^^^^^^
 help: if this was a parameter name, give it a type
    |
 LL | fn bar(x: TypeName, y: usize) {}
diff --git a/src/test/ui/suggestions/issue-64252-self-type.stderr b/src/test/ui/suggestions/issue-64252-self-type.stderr
index 4abffb1ad79..e96db3f1e86 100644
--- a/src/test/ui/suggestions/issue-64252-self-type.stderr
+++ b/src/test/ui/suggestions/issue-64252-self-type.stderr
@@ -5,6 +5,10 @@ LL | pub fn foo(Box<Self>) { }
    |               ^ expected one of `:`, `@`, or `|`
    |
    = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a `self` type, give it a parameter name
+   |
+LL | pub fn foo(self: Box<Self>) { }
+   |            ^^^^^^^^^
 help: if this is a type, explicitly ignore the parameter name
    |
 LL | pub fn foo(_: Box<Self>) { }