-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
large_enum_variant triggered in error-chain macro has unhelpful help message #2121
Comments
is there a point in reporting anything inside that macro? We can just turn it off in macros. |
Well, the concern is valid: It's a large enum. Question is, if the programmer can do anything about it (in this case: probably). It's just the quoted code that's not really useful here. |
can you tell error_chain to box the args? Something like error_chain! {
foreign_links {
Io(Box<::std::io::Error>);
}
} ? |
That is trivial. Figuring out how to produce nice error spans is a little involved, but sound like "just some detective work" |
Doesn't look like it: https://play.rust-lang.org/?gist=0007d7af1676d861d6cb534f4fa735c1&version=stable
😞 |
error-chain already seems to box its contents: https://play.rust-lang.org/?gist=232208cd5ee6f1fcf95c4eb52562dfde&version=stable |
Hahaha, sorry, hadn't had enough coffee yet. That's basically the quoted macro line from above! 😆
|
error-chain is totally fine with letting you have a foreign link of The error in your link is because you told error-chain that the foreign link is over
No, error-chain's codegen does not box foreign links. The size of mod foo {
pub enum ErrorKind {
Msg(String),
Io(Box<::std::io::Error>),
#[doc(hidden)]
__Nonexhaustive { },
}
}
mod bar {
pub enum ErrorKind {
Msg(String),
Io(::std::io::Error),
#[doc(hidden)]
__Nonexhaustive { },
}
}
fn main() {
println!("{}", std::mem::size_of::<foo::ErrorKind>()); // 32
println!("{}", std::mem::size_of::<bar::ErrorKind>()); // 32
println!("{}", std::mem::size_of::<String>()); // 24
println!("{}", std::mem::size_of::<::std::io::Error>()); // 16
println!("{}", std::mem::size_of::<Box<::std::io::Error>>()); // 8
} |
You know how I like to suggest E-hard new lints? Sorry, this time I only have an E-hard L-enhancement to report.
Is there a way to (easily) print the enum variants with their sizes? This might be helpful even in rather obvious cases.
The text was updated successfully, but these errors were encountered: