Skip to content

impl Error on Enum with str type #34934

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

Closed
adjivas opened this issue Jul 20, 2016 · 1 comment
Closed

impl Error on Enum with str type #34934

adjivas opened this issue Jul 20, 2016 · 1 comment

Comments

@adjivas
Copy link

adjivas commented Jul 20, 2016

Hello, I repport this issue.

I tried this code:

use std::fmt;
use std::fmt::{Display, Debug};

use std::error::Error;

enum PartError {
    UnknownPart(str),
    ForbiddenGlyph(char),
}

impl Error for PartError {
    fn description(&self) -> &str {
        match *self {
            PartError::UnknownPart(_) => "the name of part is unknown",
            PartError::ForbiddenGlyph(_) => "the glyph is on a forbidden range",
        }
    }
}

impl Display for PartError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self)
    }
}

impl Debug for PartError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self)
    }
}

fn main() {
}

I expected to see this happen:

error: internal compiler error: ../src/librustc_trans/type_of.rs:178: Unexpected tail in unsized_info_ty: PartError for ty=PartError

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:634
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@apasel422
Copy link
Contributor

Thanks for the report! Closing as duplicate of #16812.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants