From 0c13a9c020b1a70ad3d33b4de706567d46955e5d Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Sun, 6 Dec 2020 20:30:07 +0000 Subject: smarter E0390 --- src/test/ui/error-codes/E0390.stderr | 2 +- src/test/ui/kinds-of-primitive-impl.rs | 23 ++++++++ src/test/ui/kinds-of-primitive-impl.stderr | 65 +++++++++++++++++++++++ src/test/ui/single-primitive-inherent-impl.stderr | 2 +- 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/kinds-of-primitive-impl.rs create mode 100644 src/test/ui/kinds-of-primitive-impl.stderr (limited to 'src') diff --git a/src/test/ui/error-codes/E0390.stderr b/src/test/ui/error-codes/E0390.stderr index 3ca3a77c74f..414ec20ae80 100644 --- a/src/test/ui/error-codes/E0390.stderr +++ b/src/test/ui/error-codes/E0390.stderr @@ -4,7 +4,7 @@ error[E0390]: only a single inherent implementation marked with `#[lang = "mut_p LL | impl *mut Foo {} | ^^^^^^^^^^^^^^^^ | -help: consider using a trait to implement these methods +help: consider using a trait --> $DIR/E0390.rs:5:1 | LL | impl *mut Foo {} diff --git a/src/test/ui/kinds-of-primitive-impl.rs b/src/test/ui/kinds-of-primitive-impl.rs new file mode 100644 index 00000000000..cbd4d7ae904 --- /dev/null +++ b/src/test/ui/kinds-of-primitive-impl.rs @@ -0,0 +1,23 @@ +// ignore-tidy-linelength + + +impl u8 { +//~^ error: only a single inherent implementation marked with `#[lang = "u8"]` is allowed for the `u8` primitive + pub const B: u8 = 0; +} + +impl str { +//~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive + fn foo() {} + fn bar(self) {} +} + +impl char { +//~^ error: only a single inherent implementation marked with `#[lang = "char"]` is allowed for the `char` primitive + pub const B: u8 = 0; + pub const C: u8 = 0; + fn foo() {} + fn bar(self) {} +} + +fn main() {} diff --git a/src/test/ui/kinds-of-primitive-impl.stderr b/src/test/ui/kinds-of-primitive-impl.stderr new file mode 100644 index 00000000000..14aed00c005 --- /dev/null +++ b/src/test/ui/kinds-of-primitive-impl.stderr @@ -0,0 +1,65 @@ +error[E0390]: only a single inherent implementation marked with `#[lang = "u8"]` is allowed for the `u8` primitive + --> $DIR/kinds-of-primitive-impl.rs:4:1 + | +LL | / impl u8 { +LL | | +LL | | pub const B: u8 = 0; +LL | | } + | |_^ + | +help: consider using a trait to implement this constant + --> $DIR/kinds-of-primitive-impl.rs:4:1 + | +LL | / impl u8 { +LL | | +LL | | pub const B: u8 = 0; +LL | | } + | |_^ + +error[E0390]: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive + --> $DIR/kinds-of-primitive-impl.rs:9:1 + | +LL | / impl str { +LL | | +LL | | fn foo() {} +LL | | fn bar(self) {} +LL | | } + | |_^ + | +help: consider using a trait to implement these methods + --> $DIR/kinds-of-primitive-impl.rs:9:1 + | +LL | / impl str { +LL | | +LL | | fn foo() {} +LL | | fn bar(self) {} +LL | | } + | |_^ + +error[E0390]: only a single inherent implementation marked with `#[lang = "char"]` is allowed for the `char` primitive + --> $DIR/kinds-of-primitive-impl.rs:15:1 + | +LL | / impl char { +LL | | +LL | | pub const B: u8 = 0; +LL | | pub const C: u8 = 0; +LL | | fn foo() {} +LL | | fn bar(self) {} +LL | | } + | |_^ + | +help: consider using a trait to implement these associated items + --> $DIR/kinds-of-primitive-impl.rs:15:1 + | +LL | / impl char { +LL | | +LL | | pub const B: u8 = 0; +LL | | pub const C: u8 = 0; +LL | | fn foo() {} +LL | | fn bar(self) {} +LL | | } + | |_^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0390`. diff --git a/src/test/ui/single-primitive-inherent-impl.stderr b/src/test/ui/single-primitive-inherent-impl.stderr index d357afa3b38..0daae91956d 100644 --- a/src/test/ui/single-primitive-inherent-impl.stderr +++ b/src/test/ui/single-primitive-inherent-impl.stderr @@ -6,7 +6,7 @@ LL | | LL | | } | |_^ | -help: consider using a trait to implement these methods +help: consider using a trait --> $DIR/single-primitive-inherent-impl.rs:11:1 | LL | / impl str { -- cgit 1.4.1-3-g733a5