From ec23f4ed3fdb7f09a4398a32eaf486da22bd3ae9 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 10 Aug 2020 18:51:14 +0800 Subject: [PATCH 1/4] Add sample fix for E0749 Even though the description is clear but the solution may not be as straightforward. Adding a suggested fix. --- src/librustc_error_codes/error_codes/E0749.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_error_codes/error_codes/E0749.md b/src/librustc_error_codes/error_codes/E0749.md index 7a1a745b53c12..74cd2903f6d01 100644 --- a/src/librustc_error_codes/error_codes/E0749.md +++ b/src/librustc_error_codes/error_codes/E0749.md @@ -11,6 +11,7 @@ trait MyTrait { impl !MyTrait for u32 { type Foo = i32; // error! } +// impl !MyTrait for u32 {} // fix # fn main() {} ``` From a2d7c33aa83d39cd0ab1fba0a8ccdfd2c7f29576 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 10 Aug 2020 22:33:17 +0800 Subject: [PATCH 2/4] Split fix into another section for E0749 --- src/librustc_error_codes/error_codes/E0749.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0749.md b/src/librustc_error_codes/error_codes/E0749.md index 74cd2903f6d01..962da0eda08f6 100644 --- a/src/librustc_error_codes/error_codes/E0749.md +++ b/src/librustc_error_codes/error_codes/E0749.md @@ -11,10 +11,20 @@ trait MyTrait { impl !MyTrait for u32 { type Foo = i32; // error! } -// impl !MyTrait for u32 {} // fix # fn main() {} ``` Negative impls are not allowed to have any items. Negative impls declare that a trait is **not** implemented (and never will be) and hence there is no need to specify the values for trait methods or other items. + +One way to fix this is to remove the items in negative impls. + +``` +# #![feature(negative_impls)] +trait MyTrait { + type Foo; +} + +impl !MyTrait for u32 {} +``` From 8cb1a2f8a2a3fe9dce850e512c003bffd7786ab6 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 10 Aug 2020 22:46:15 +0800 Subject: [PATCH 3/4] Use : rather than . in example description Co-authored-by: Guillaume Gomez --- src/librustc_error_codes/error_codes/E0749.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0749.md b/src/librustc_error_codes/error_codes/E0749.md index 962da0eda08f6..5b6bfe75cfc90 100644 --- a/src/librustc_error_codes/error_codes/E0749.md +++ b/src/librustc_error_codes/error_codes/E0749.md @@ -18,7 +18,7 @@ Negative impls are not allowed to have any items. Negative impls declare that a trait is **not** implemented (and never will be) and hence there is no need to specify the values for trait methods or other items. -One way to fix this is to remove the items in negative impls. +One way to fix this is to remove the items in negative impls: ``` # #![feature(negative_impls)] From a7f61bf3bb416f03da478bbe2421946ef9b80379 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 11 Aug 2020 01:06:30 +0800 Subject: [PATCH 4/4] Remove empty fn main from E0749 --- src/librustc_error_codes/error_codes/E0749.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0749.md b/src/librustc_error_codes/error_codes/E0749.md index 5b6bfe75cfc90..dfe90ae89e4cb 100644 --- a/src/librustc_error_codes/error_codes/E0749.md +++ b/src/librustc_error_codes/error_codes/E0749.md @@ -11,7 +11,6 @@ trait MyTrait { impl !MyTrait for u32 { type Foo = i32; // error! } -# fn main() {} ``` Negative impls are not allowed to have any items. Negative impls declare that a