about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-17 03:56:38 +0000
committerbors <bors@rust-lang.org>2020-09-17 03:56:38 +0000
commit95386b656e91168bf53e2ab63c6b992cae591fe7 (patch)
tree1f8188971f7f3a37db4a03b96941449576352c13 /src
parent285fc7d704fcdd7b2a37d475d04d5d955490e000 (diff)
parent81161bed41124a7a62bdaf5a349df0e8f2ff09bf (diff)
downloadrust-95386b656e91168bf53e2ab63c6b992cae591fe7.tar.gz
rust-95386b656e91168bf53e2ab63c6b992cae591fe7.zip
Auto merge of #76028 - aticu:improve_e0118, r=estebank,jyn514,GuillaumeGomez
Improve E0118

- Changes the "base type" terminology to "nominal type" (according to the [reference](https://doc.rust-lang.org/stable/reference/items/implementations.html#inherent-implementations)).
- Suggests removing a reference, if one is present on the type.
- Clarify what is meant by a "nominal type".

closes #69392

This is my first not-entirely-trivial PR, so please let me know if I missed anything or if something could be improved. Though I probably won't be able to fix anything in the upcoming week.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/error-codes/E0118-2.rs8
-rw-r--r--src/test/ui/error-codes/E0118-2.stderr12
-rw-r--r--src/test/ui/error-codes/E0118.stderr4
-rw-r--r--src/test/ui/privacy/private-in-public-ill-formed.rs6
-rw-r--r--src/test/ui/privacy/private-in-public-ill-formed.stderr10
5 files changed, 31 insertions, 9 deletions
diff --git a/src/test/ui/error-codes/E0118-2.rs b/src/test/ui/error-codes/E0118-2.rs
new file mode 100644
index 00000000000..fe04190162a
--- /dev/null
+++ b/src/test/ui/error-codes/E0118-2.rs
@@ -0,0 +1,8 @@
+struct Foo;
+
+impl &mut Foo {
+    //~^ ERROR E0118
+    fn bar(self) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/error-codes/E0118-2.stderr b/src/test/ui/error-codes/E0118-2.stderr
new file mode 100644
index 00000000000..2a1fe231116
--- /dev/null
+++ b/src/test/ui/error-codes/E0118-2.stderr
@@ -0,0 +1,12 @@
+error[E0118]: no nominal type found for inherent implementation
+  --> $DIR/E0118-2.rs:3:6
+   |
+LL | impl &mut Foo {
+   |      ^^^^^^^^ impl requires a nominal type
+   |
+   = note: either implement a trait on it or create a newtype to wrap it instead
+   = note: you could also try moving the reference to uses of `Foo` (such as `self`) within the implementation
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0118`.
diff --git a/src/test/ui/error-codes/E0118.stderr b/src/test/ui/error-codes/E0118.stderr
index b0afaeb5c1f..2693a93213a 100644
--- a/src/test/ui/error-codes/E0118.stderr
+++ b/src/test/ui/error-codes/E0118.stderr
@@ -1,8 +1,8 @@
-error[E0118]: no base type found for inherent implementation
+error[E0118]: no nominal type found for inherent implementation
   --> $DIR/E0118.rs:1:6
    |
 LL | impl (u8, u8) {
-   |      ^^^^^^^^ impl requires a base type
+   |      ^^^^^^^^ impl requires a nominal type
    |
    = note: either implement a trait on it or create a newtype to wrap it instead
 
diff --git a/src/test/ui/privacy/private-in-public-ill-formed.rs b/src/test/ui/privacy/private-in-public-ill-formed.rs
index 0ef5d89002e..031e2874a2b 100644
--- a/src/test/ui/privacy/private-in-public-ill-formed.rs
+++ b/src/test/ui/privacy/private-in-public-ill-formed.rs
@@ -11,7 +11,8 @@ mod aliases_pub {
         type AssocAlias = m::Pub3;
     }
 
-    impl <Priv as PrivTr>::AssocAlias { //~ ERROR no base type found for inherent implementation
+    impl <Priv as PrivTr>::AssocAlias {
+        //~^ ERROR no nominal type found for inherent implementation
         pub fn f(arg: Priv) {} // private type `aliases_pub::Priv` in public interface
     }
 }
@@ -27,7 +28,8 @@ mod aliases_priv {
         type AssocAlias = Priv3;
     }
 
-    impl <Priv as PrivTr>::AssocAlias { //~ ERROR no base type found for inherent implementation
+    impl <Priv as PrivTr>::AssocAlias {
+        //~^ ERROR no nominal type found for inherent implementation
         pub fn f(arg: Priv) {} // OK
     }
 }
diff --git a/src/test/ui/privacy/private-in-public-ill-formed.stderr b/src/test/ui/privacy/private-in-public-ill-formed.stderr
index a1a326f2873..e7c94bc301b 100644
--- a/src/test/ui/privacy/private-in-public-ill-formed.stderr
+++ b/src/test/ui/privacy/private-in-public-ill-formed.stderr
@@ -1,16 +1,16 @@
-error[E0118]: no base type found for inherent implementation
+error[E0118]: no nominal type found for inherent implementation
   --> $DIR/private-in-public-ill-formed.rs:14:10
    |
 LL |     impl <Priv as PrivTr>::AssocAlias {
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a base type
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type
    |
    = note: either implement a trait on it or create a newtype to wrap it instead
 
-error[E0118]: no base type found for inherent implementation
-  --> $DIR/private-in-public-ill-formed.rs:30:10
+error[E0118]: no nominal type found for inherent implementation
+  --> $DIR/private-in-public-ill-formed.rs:31:10
    |
 LL |     impl <Priv as PrivTr>::AssocAlias {
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a base type
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type
    |
    = note: either implement a trait on it or create a newtype to wrap it instead