Skip to content

ICE when using a reference incorrectly in quick_error #68449

Closed
@milkey-mouse

Description

@milkey-mouse

I was using the latest version of quick-error and tried to store a reference without a lifetime annotated in a macro-generated error. This shouldn't (and doesn't) work, but rustc should at least throw an error instead of blowing up, right?

Code sample:

use quick_error::quick_error;

quick_error! {
    pub enum AReferenceInQuickError {
        CrashesRustc(s: &str) {
            display("hello, {}!", s)
        }
    }
}

fn main() {
    let world = "world";
    AReferenceInQuickError::CrashesRustc(world);
}

I expected an error of some sort about lifetimes or macros, but instead, the compiler paniced:

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src/main.rs"), BytePos(0)), end: (Macros("::quick_error::quick_error"), BytePos(7612215)) })', src/librustc_errors/lib.rs:197:29

Meta

This rustc was compiled on Gentoo from a recent master.

$ rustc --version --verbose
rustc 1.42.0-dev (2cf24ab89 2020-01-21)
binary: rustc
commit-hash: 2cf24ab89123532f0e84995301ee734a88bf4701
commit-date: 2020-01-21
host: x86_64-unknown-linux-gnu
release: 1.42.0-dev
LLVM version: 9.0

Minimal example: https://github.com/milkey-mouse/quick-error-ice
Backtrace: https://github.com/milkey-mouse/quick-error-ice/blob/master/backtrace

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions