rust-lang/rust-clippy

large_enum_variant triggered in error-chain macro has unhelpful help message

Open

#2121 aperta il 9 ott 2017

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)Rust (1391 fork)batch import
C-enhancementE-mediumT-middlegood first issue

Metriche repository

Star
 (10.406 star)
Metriche merge PR
 (Merge medio 19g 22h) (113 PR mergiate in 30 g)

Descrizione

You know how I like to suggest E-hard new lints? Sorry, this time I only have an E-hard L-enhancement to report.

warning: large size difference between variants
  --> src/main.rs:66:1
   |
66 | / error_chain! {
67 | |     foreign_links {
68 | |         Io(::std::io::Error);
69 | |         Handlebars(::handlebars::TemplateRenderError);
70 | |         Yaml(::yaml::Error);
71 | |     }
72 | | }
   | |_^
   |
   = note: #[warn(large_enum_variant)] on by default
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.165/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
   |
113| err : Box<$ foreign_link_error_path> ) {
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro outside of the current crate
   = issue author's remark: this help message is not helpful

Is there a way to (easily) print the enum variants with their sizes? This might be helpful even in rather obvious cases.

Guida contributor