Skip to content

Conditional compilation fails if enum variants use from() #47

Description

@yawor

Hi,
I've stumbled upon an error when I've tried to add conditional compilation to my quick_error defined Error enum. Here's an example:

quick_error!{
#[derive(Debug)]pubenumError{Io(err: std::io::Error){
cause(err)
from()
display("I/O error: {}", err)}
#[cfg(feature="ssh2")]Ssh(err: ssh2::Error){
cause(err)
from()
display("SSH error: {}", err)}Net(err: std::net::AddrParseError){
cause(err)
from()
display("Network error: {}", err)}Zmq(err: zmq::Error){
cause(err)
from()
display("ZMQ error: {}", err)}Other(desc:String){
description(desc)
from(desc:&str) -> (String::from(desc))
from(err:Box<dyn std::error::Error>) -> (String::from(err.description()))}}}

If I remove the from() from Ssh variant, then it compiles correctly. When I'm expanding the macro, I can see the #[cfg(feature="ssh2")] everywhere except for the

implFrom<ssh2::Error>forError{fnfrom(err: ssh2::Error) -> Error{Error::Ssh(err)}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions