From c5e0d6e4d43f228687c75ab7406f64b318752d7b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 6 Oct 2019 15:23:33 +0200 Subject: [PATCH 1/2] Add long error explanation for E0566 --- src/librustc/error_codes.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 66c51000066..9a5e1ea6f33 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -1700,6 +1700,30 @@ To understand better how closures work in Rust, read: https://doc.rust-lang.org/book/ch13-01-closures.html "##, +E0566: r##" +Conflicting representation hints have been used on a same item. + +Erroneous code example: + +```compile_fail,E0566 +# #![deny(warnings)] +# fn main() { +#[repr(u32, u64)] // error! +enum Repr { A } +# } +``` + +In most cases (if not all), using just one representation hint is more than +enough. If you want to have a representation hint depending on the current +architecture, use `cfg_attr`. Example: + +``` +#[cfg_attr(linux, repr(u32))] +#[cfg_attr(not(linux), repr(u64))] +enum Repr { A } +``` +"##, + E0580: r##" The `main` function was incorrectly declared. @@ -2097,7 +2121,6 @@ rejected in your own crates. E0490, // a value of type `..` is borrowed for too long E0495, // cannot infer an appropriate lifetime due to conflicting // requirements - E0566, // conflicting representation hints E0623, // lifetime mismatch where both parameters are anonymous regions E0628, // generators cannot have explicit parameters E0631, // type mismatch in closure arguments From 57cb8819ee78f2debf24d2e123c78796204db8c9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 6 Oct 2019 17:02:01 +0200 Subject: [PATCH 2/2] Update ui tests --- src/librustc/error_codes.rs | 7 ++----- src/test/ui/conflicting-repr-hints.stderr | 1 + src/test/ui/feature-gates/feature-gate-repr-simd.stderr | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 9a5e1ea6f33..502172db91c 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -1705,12 +1705,9 @@ Conflicting representation hints have been used on a same item. Erroneous code example: -```compile_fail,E0566 -# #![deny(warnings)] -# fn main() { -#[repr(u32, u64)] // error! +``` +#[repr(u32, u64)] // warning! enum Repr { A } -# } ``` In most cases (if not all), using just one representation hint is more than diff --git a/src/test/ui/conflicting-repr-hints.stderr b/src/test/ui/conflicting-repr-hints.stderr index 6b15b7ebbe9..832f5c3ac2b 100644 --- a/src/test/ui/conflicting-repr-hints.stderr +++ b/src/test/ui/conflicting-repr-hints.stderr @@ -66,3 +66,4 @@ LL | | } error: aborting due to 8 previous errors +For more information about this error, try `rustc --explain E0566`. diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr index dfaa85bc5f0..02c8400e03e 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr @@ -26,4 +26,5 @@ LL | #[repr(simd)] error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0566, E0658. +For more information about an error, try `rustc --explain E0566`.