diff --git a/tests/compile_tests.rs b/tests/compile_tests.rs index 29c72a8..a806321 100644 --- a/tests/compile_tests.rs +++ b/tests/compile_tests.rs @@ -3,27 +3,10 @@ #[test] fn no_std() { let t = trybuild::TestCases::new(); - #[cfg(not(feature = "std"))] - t.compile_fail("tests/no_std/without.rs"); - #[cfg(not(feature = "std"))] - t.compile_fail("tests/no_std/multi_line.rs"); - #[cfg(not(feature = "std"))] - t.pass("tests/no_std/multi_line_allow.rs"); - #[cfg(not(feature = "std"))] - t.compile_fail("tests/no_std/enum_prefix_missing.rs"); - #[cfg(not(feature = "std"))] - t.pass("tests/no_std/enum_prefix.rs"); - #[cfg(feature = "std")] - t.compile_fail("tests/std/without.rs"); - #[cfg(feature = "std")] - t.compile_fail("tests/std/multi_line.rs"); - #[cfg(feature = "std")] - t.pass("tests/std/multi_line_allow.rs"); - #[cfg(feature = "std")] - t.compile_fail("tests/std/enum_prefix_missing.rs"); - #[cfg(feature = "std")] - t.pass("tests/std/enum_prefix.rs"); - #[cfg(feature = "std")] - t.pass("tests/std/multiple.rs"); - t.pass("tests/no_std/with.rs"); + t.compile_fail("tests/ui/without.rs"); + t.compile_fail("tests/ui/multi_line.rs"); + t.pass("tests/ui/multi_line_allow.rs"); + t.compile_fail("tests/ui/enum_prefix_missing.rs"); + t.pass("tests/ui/enum_prefix.rs"); + t.pass("tests/ui/multiple.rs"); } diff --git a/tests/no_std.rs b/tests/no_std.rs new file mode 100644 index 0000000..f444421 --- /dev/null +++ b/tests/no_std.rs @@ -0,0 +1,46 @@ +#![no_std] +#![allow(unused)] + +// This test ensures that the generated code doesn't reference any stdlib items. + +use displaydoc::Display; + +#[derive(Display)] +/// Just a basic struct {thing} +struct HappyStruct { + thing: &'static str, +} + +#[derive(Display)] +#[ignore_extra_doc_attributes] +/// Just a basic struct {thing} +/// and this line should get ignored +struct HappyStruct2 { + thing: &'static str, +} + +#[derive(Display)] +enum Happy { + /// I really like Variant1 + Variant1, + /// Variant2 is pretty swell 2 + Variant2, + /// Variant3 is okay {sometimes} + Variant3 { sometimes: &'static str }, + /** + * Variant4 wants to have a lot of lines + * + * Lets see how this works out for it + */ + Variant4, + /// Variant5 has a parameter {0} and some regular comments + // A regular comment that won't get picked + Variant5(u32), + + /// These docs are ignored + #[displaydoc("Variant7 has a parameter {0} and uses #[displaydoc]")] + /// These docs are also ignored + Variant7(u32), +} + + diff --git a/tests/no_std/enum_prefix.rs b/tests/no_std/enum_prefix.rs deleted file mode 100644 index 5538e27..0000000 --- a/tests/no_std/enum_prefix.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -#[prefix_enum_doc_attributes] -enum TestType { - /// this variant is too - Variant1, - - /// this variant is two - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/no_std/enum_prefix_missing.rs b/tests/no_std/enum_prefix_missing.rs deleted file mode 100644 index 7171072..0000000 --- a/tests/no_std/enum_prefix_missing.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -#[derive(Display)] -#[prefix_enum_doc_attributes] -enum TestType { - /// this variant is too - Variant1, - - /// this variant is two - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/no_std/enum_prefix_missing.stderr b/tests/no_std/enum_prefix_missing.stderr deleted file mode 100644 index 8cf7993..0000000 --- a/tests/no_std/enum_prefix_missing.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: proc-macro derive panicked - --> $DIR/enum_prefix_missing.rs:22:10 - | -22 | #[derive(Display)] - | ^^^^^^^ - | - = help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself. - -error[E0277]: `TestType` doesn't implement `Display` - --> $DIR/enum_prefix_missing.rs:32:37 - | -32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); - | ^^^^^^^^ `TestType` cannot be formatted with the default formatter - | - = help: the trait `Display` is not implemented for `TestType` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `assert_impl_all` - --> $DIR/enum_prefix_missing.rs:32:1 - | -32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/no_std/multi_line.rs b/tests/no_std/multi_line.rs deleted file mode 100644 index ca4215c..0000000 --- a/tests/no_std/multi_line.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -enum TestType { - /// This one is okay - Variant1, - - /// Multi - /// line - /// doc. - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/no_std/multi_line.stderr b/tests/no_std/multi_line.stderr deleted file mode 100644 index f3d77b9..0000000 --- a/tests/no_std/multi_line.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: proc-macro derive panicked - --> $DIR/multi_line.rs:23:10 - | -23 | #[derive(Display)] - | ^^^^^^^ - | - = help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive. - -error[E0277]: `TestType` doesn't implement `Display` - --> $DIR/multi_line.rs:34:37 - | -34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); - | ^^^^^^^^ `TestType` cannot be formatted with the default formatter - | - = help: the trait `Display` is not implemented for `TestType` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `assert_impl_all` - --> $DIR/multi_line.rs:34:1 - | -34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/no_std/multi_line_allow.rs b/tests/no_std/multi_line_allow.rs deleted file mode 100644 index 8467681..0000000 --- a/tests/no_std/multi_line_allow.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -#[ignore_extra_doc_attributes] -enum TestType { - /// This one is okay - Variant1, - - /// Multi - /// line - /// doc. - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/no_std/with.rs b/tests/no_std/with.rs deleted file mode 100644 index 67aef47..0000000 --- a/tests/no_std/with.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![feature(lang_items, start)] -#![no_std] - -#[start] -#[cfg(not(feature = "std"))] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} - -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} - -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -#[cfg(feature = "std")] -fn main() {} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -struct FakeType; - -static_assertions::assert_impl_all!(FakeType: core::fmt::Display); diff --git a/tests/no_std/without.rs b/tests/no_std/without.rs deleted file mode 100644 index 04d4b8f..0000000 --- a/tests/no_std/without.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -/// this type is pretty swell -struct FakeType; - -static_assertions::assert_impl_all!(FakeType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/no_std/without.stderr b/tests/no_std/without.stderr deleted file mode 100644 index a12edc4..0000000 --- a/tests/no_std/without.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: unused import: `displaydoc::Display` - --> $DIR/without.rs:20:5 - | -20 | use displaydoc::Display; - | ^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unused_imports)]` on by default - -error[E0277]: `FakeType` doesn't implement `Display` - --> $DIR/without.rs:25:37 - | -25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display); - | ^^^^^^^^ `FakeType` cannot be formatted with the default formatter - | - = help: the trait `Display` is not implemented for `FakeType` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `assert_impl_all` - --> $DIR/without.rs:25:1 - | -25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/std/enum_prefix.rs b/tests/std/enum_prefix.rs deleted file mode 100644 index 7e6abcc..0000000 --- a/tests/std/enum_prefix.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![cfg_attr(not(feature = "std"), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -#[prefix_enum_doc_attributes] -enum TestType { - /// this variant is too - Variant1, - - /// this variant is two - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/std/enum_prefix_missing.rs b/tests/std/enum_prefix_missing.rs deleted file mode 100644 index 45c312b..0000000 --- a/tests/std/enum_prefix_missing.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![cfg_attr(not(feature = "std"), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -#[derive(Display)] -#[prefix_enum_doc_attributes] -enum TestType { - /// this variant is too - Variant1, - - /// this variant is two - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/std/multi_line_allow.rs b/tests/std/multi_line_allow.rs deleted file mode 100644 index e09e8fc..0000000 --- a/tests/std/multi_line_allow.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![cfg_attr(not(feature = "std"), feature(lang_items, start))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg_attr(not(feature = "std"), start)] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -#[ignore_extra_doc_attributes] -enum TestType { - /// This one is okay - Variant1, - - /// Multi - /// line - /// doc. - Variant2, -} - -static_assertions::assert_impl_all!(TestType: core::fmt::Display); - -#[cfg(feature = "std")] -fn main() {} diff --git a/tests/std/multiple.rs b/tests/std/multiple.rs deleted file mode 100644 index 66d59b7..0000000 --- a/tests/std/multiple.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![feature(lang_items, start)] -#![no_std] - -#[start] -#[cfg(not(feature = "std"))] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - 0 -} - -#[lang = "eh_personality"] -#[no_mangle] -#[cfg(not(feature = "std"))] -pub extern "C" fn rust_eh_personality() {} - -#[panic_handler] -#[cfg(not(feature = "std"))] -fn panic(_info: &core::panic::PanicInfo) -> ! { - unsafe { - libc::abort(); - } -} - -#[cfg(feature = "std")] -fn main() {} - -use displaydoc::Display; - -/// this type is pretty swell -#[derive(Display)] -struct FakeType; - -static_assertions::assert_impl_all!(FakeType: core::fmt::Display); - -/// this type is pretty swell2 -#[derive(Display)] -struct FakeType2; - -static_assertions::assert_impl_all!(FakeType2: core::fmt::Display); diff --git a/tests/std/without.stderr b/tests/std/without.stderr deleted file mode 100644 index 4f0d713..0000000 --- a/tests/std/without.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: unused import: `displaydoc::Display` - --> $DIR/without.rs:20:5 - | -20 | use displaydoc::Display; - | ^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unused_imports)]` on by default - -error[E0277]: `FakeType` doesn't implement `std::fmt::Display` - --> $DIR/without.rs:25:37 - | -25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display); - | ^^^^^^^^ `FakeType` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `FakeType` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -note: required by a bound in `assert_impl_all` - --> $DIR/without.rs:25:1 - | -25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/enum_prefix.rs b/tests/ui/enum_prefix.rs new file mode 100644 index 0000000..ba0dd70 --- /dev/null +++ b/tests/ui/enum_prefix.rs @@ -0,0 +1,16 @@ +use displaydoc::Display; + +/// this type is pretty swell +#[derive(Display)] +#[prefix_enum_doc_attributes] +enum TestType { + /// this variant is too + Variant1, + + /// this variant is two + Variant2, +} + +static_assertions::assert_impl_all!(TestType: core::fmt::Display); + +fn main() {} \ No newline at end of file diff --git a/tests/ui/enum_prefix_missing.rs b/tests/ui/enum_prefix_missing.rs new file mode 100644 index 0000000..78301f9 --- /dev/null +++ b/tests/ui/enum_prefix_missing.rs @@ -0,0 +1,15 @@ +use displaydoc::Display; + +#[derive(Display)] +#[prefix_enum_doc_attributes] +enum TestType { + /// this variant is too + Variant1, + + /// this variant is two + Variant2, +} + +static_assertions::assert_impl_all!(TestType: core::fmt::Display); + +fn main() {} \ No newline at end of file diff --git a/tests/std/enum_prefix_missing.stderr b/tests/ui/enum_prefix_missing.stderr similarity index 60% rename from tests/std/enum_prefix_missing.stderr rename to tests/ui/enum_prefix_missing.stderr index 09e1db6..dc97f86 100644 --- a/tests/std/enum_prefix_missing.stderr +++ b/tests/ui/enum_prefix_missing.stderr @@ -1,22 +1,22 @@ error: proc-macro derive panicked - --> $DIR/enum_prefix_missing.rs:22:10 - | -22 | #[derive(Display)] - | ^^^^^^^ - | - = help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself. + --> tests/std/enum_prefix_missing.rs:3:10 + | +3 | #[derive(Display)] + | ^^^^^^^ + | + = help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself. error[E0277]: `TestType` doesn't implement `std::fmt::Display` - --> $DIR/enum_prefix_missing.rs:32:37 + --> tests/std/enum_prefix_missing.rs:13:37 | -32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); +13 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ^^^^^^^^ `TestType` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `TestType` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `assert_impl_all` - --> $DIR/enum_prefix_missing.rs:32:1 + --> tests/std/enum_prefix_missing.rs:13:1 | -32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); +13 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/std/multi_line.rs b/tests/ui/multi_line.rs similarity index 100% rename from tests/std/multi_line.rs rename to tests/ui/multi_line.rs diff --git a/tests/std/multi_line.stderr b/tests/ui/multi_line.stderr similarity index 58% rename from tests/std/multi_line.stderr rename to tests/ui/multi_line.stderr index c36a75d..2971768 100644 --- a/tests/std/multi_line.stderr +++ b/tests/ui/multi_line.stderr @@ -1,22 +1,22 @@ error: proc-macro derive panicked - --> $DIR/multi_line.rs:23:10 - | -23 | #[derive(Display)] - | ^^^^^^^ - | - = help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive. + --> tests/std/multi_line.rs:4:10 + | +4 | #[derive(Display)] + | ^^^^^^^ + | + = help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive. error[E0277]: `TestType` doesn't implement `std::fmt::Display` - --> $DIR/multi_line.rs:34:37 + --> tests/std/multi_line.rs:15:37 | -34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); +15 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ^^^^^^^^ `TestType` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `TestType` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `assert_impl_all` - --> $DIR/multi_line.rs:34:1 + --> tests/std/multi_line.rs:15:1 | -34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); +15 | static_assertions::assert_impl_all!(TestType: core::fmt::Display); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/multi_line_allow.rs b/tests/ui/multi_line_allow.rs new file mode 100644 index 0000000..c2ea9d3 --- /dev/null +++ b/tests/ui/multi_line_allow.rs @@ -0,0 +1,18 @@ +use displaydoc::Display; + +/// this type is pretty swell +#[derive(Display)] +#[ignore_extra_doc_attributes] +enum TestType { + /// This one is okay + Variant1, + + /// Multi + /// line + /// doc. + Variant2, +} + +static_assertions::assert_impl_all!(TestType: core::fmt::Display); + +fn main() {} \ No newline at end of file diff --git a/tests/ui/multiple.rs b/tests/ui/multiple.rs new file mode 100644 index 0000000..d048906 --- /dev/null +++ b/tests/ui/multiple.rs @@ -0,0 +1,15 @@ +use displaydoc::Display; + +/// this type is pretty swell +#[derive(Display)] +struct FakeType; + +static_assertions::assert_impl_all!(FakeType: core::fmt::Display); + +/// this type is pretty swell2 +#[derive(Display)] +struct FakeType2; + +static_assertions::assert_impl_all!(FakeType2: core::fmt::Display); + +fn main() {} \ No newline at end of file diff --git a/tests/std/without.rs b/tests/ui/without.rs similarity index 100% rename from tests/std/without.rs rename to tests/ui/without.rs diff --git a/tests/ui/without.stderr b/tests/ui/without.stderr new file mode 100644 index 0000000..bfc15c8 --- /dev/null +++ b/tests/ui/without.stderr @@ -0,0 +1,22 @@ +warning: unused import: `displaydoc::Display` + --> tests/std/without.rs:1:5 + | +1 | use displaydoc::Display; + | ^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +error[E0277]: `FakeType` doesn't implement `std::fmt::Display` + --> tests/std/without.rs:6:37 + | +6 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display); + | ^^^^^^^^ `FakeType` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `FakeType` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `assert_impl_all` + --> tests/std/without.rs:6:1 + | +6 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)