From 1c1bb1309f5b2e15438711b701f6ab59f04fd633 Mon Sep 17 00:00:00 2001 From: aticu <15schnic@gmail.com> Date: Thu, 27 Aug 2020 23:55:22 +0200 Subject: Improve E0118 description --- .../rustc_error_codes/src/error_codes/E0118.md | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_error_codes/src') diff --git a/compiler/rustc_error_codes/src/error_codes/E0118.md b/compiler/rustc_error_codes/src/error_codes/E0118.md index 5cb5f506e0a..ddd4f498f0c 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0118.md +++ b/compiler/rustc_error_codes/src/error_codes/E0118.md @@ -1,10 +1,10 @@ -An inherent implementation was defined for something which isn't a struct nor -an enum. +An inherent implementation was defined for something which isn't a struct, an +enum, a union or a trait object. Erroneous code example: ```compile_fail,E0118 -impl (u8, u8) { // error: no base type found for inherent implementation +impl (u8, u8) { // error: no nominal type found for inherent implementation fn get_state(&self) -> String { // ... } @@ -41,3 +41,24 @@ impl TypeWrapper { } } ``` + +Instead of defining an inherent implementation on a reference, you could also +move the reference inside the implementation: + +```compile_fail,E0118 +struct Foo; + +impl &Foo { // error: no nominal type found for inherent implementation + fn bar(self, other: Self) {} +} +``` + +becomes + +``` +struct Foo; + +impl Foo { + fn bar(&self, other: &Self) {} +} +``` -- cgit 1.4.1-3-g733a5 From 81161bed41124a7a62bdaf5a349df0e8f2ff09bf Mon Sep 17 00:00:00 2001 From: Niclas Schwarzlose <15schnic@gmail.com> Date: Tue, 15 Sep 2020 18:10:41 +0200 Subject: Adjust spelling Co-authored-by: Joshua Nelson --- compiler/rustc_error_codes/src/error_codes/E0118.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_error_codes/src') diff --git a/compiler/rustc_error_codes/src/error_codes/E0118.md b/compiler/rustc_error_codes/src/error_codes/E0118.md index ddd4f498f0c..345ec341c3f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0118.md +++ b/compiler/rustc_error_codes/src/error_codes/E0118.md @@ -1,5 +1,5 @@ -An inherent implementation was defined for something which isn't a struct, an -enum, a union or a trait object. +An inherent implementation was defined for something which isn't a struct, +enum, union, or trait object. Erroneous code example: -- cgit 1.4.1-3-g733a5