diff options
| author | bors <bors@rust-lang.org> | 2020-09-17 03:56:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-17 03:56:38 +0000 |
| commit | 95386b656e91168bf53e2ab63c6b992cae591fe7 (patch) | |
| tree | 1f8188971f7f3a37db4a03b96941449576352c13 /compiler/rustc_error_codes/src | |
| parent | 285fc7d704fcdd7b2a37d475d04d5d955490e000 (diff) | |
| parent | 81161bed41124a7a62bdaf5a349df0e8f2ff09bf (diff) | |
| download | rust-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 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0118.md | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0118.md b/compiler/rustc_error_codes/src/error_codes/E0118.md index 5cb5f506e0a..345ec341c3f 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, +enum, union, or 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) {} +} +``` |
