Skip to content

ICE when passing nonexistent literal enum reference #23173

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
nukep opened this issue Mar 8, 2015 · 0 comments
Closed

ICE when passing nonexistent literal enum reference #23173

nukep opened this issue Mar 8, 2015 · 0 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nukep
Copy link

nukep commented Mar 8, 2015

The compiler seems to raise a ICE whenever an enum literal reference that's passed directly as a function parameter is missing or misspelled:

enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ }

fn use_token(token: &Token) { unimplemented!() }

fn main() {
    // Token::LeftParens is misspelled, should be Token::LeftParen.
    use_token(&Token::LeftParens);
}
thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 0, node: 4 }, true), last_private: LastMod(AllPublic), depth: 1 }', C:/bot/slave/nightly-dist-rustc-win-64/build/src/librustc\middle\def.rs:79

stack backtrace:
   1:         0x71217094 - sys::backtrace::write::h702ba69fda76a133UVA
   2:         0x71231708 - rt::unwind::register::h2807fa6be024d773ZpJ
   3:         0x71183427 - rt::unwind::begin_unwind_inner::h33dce4042bd21f85onJ
   4:         0x71183beb - rt::unwind::begin_unwind_fmt::hae30e0776fdf0958ZlJ
   5:           0xf5ba4a - middle::ty::resolve_expr::h3413f822b132c794uV6
   6:          0x108d876 - middle::ty::expr_kind::h7a4229e8cf2923d94W6
   7:          0x108d589 - middle::ty::expr_is_lval::hee14165bdb90e648xW6
   8:          0x1685988 - check::UnresolvedTypeAction...std..fmt..Debug::fmt::h6fea2f9b6c32405bN8o
   9:          0x1663989 - check::callee::CallResolution<'tcx>.DeferredCallResolution<'tcx>::resolve::h620708a97b262156Qlm
  10:          0x1660e5b - check::FnCtxt<'a, 'tcx>.AstConv<'tcx>::projected_ty::h3d9369be1c793797zjo
  11:          0x165fad8 - check::FnCtxt<'a, 'tcx>.AstConv<'tcx>::projected_ty::h3d9369be1c793797zjo
  12:          0x16af2f8 - check::UnresolvedTypeAction...std..fmt..Debug::fmt::h6fea2f9b6c32405bN8o
  13:          0x16751e1 - check::GatherLocalsVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::hccf69f0ad25ab806Xln
  14:          0x165d854 - check::FnCtxt<'a, 'tcx>.AstConv<'tcx>::projected_ty::h3d9369be1c793797zjo
  15:          0x1672a8c - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_ty::hb08a5401782be257man
  16:          0x166b304 - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::hbc63086752858e7d09m
  17:          0x17280d4 - check_crate::h490a1c107c2f6f04hfC
  18:          0x1723821 - check_crate::h490a1c107c2f6f04hfC
  19:         0x652deb3b - driver::phase_3_run_analysis_passes::h95f5e5d96e327896mGa
  20:         0x652c2669 - driver::compile_input::h5f994866bdbf7f9fNba
  21:         0x6538530d - run_compiler::h716ee0dff1e124acG6b
  22:         0x65383253 - run::h15ad65cc2cf082cdm6b
  23:         0x65381e1e - run::h15ad65cc2cf082cdm6b
  24:         0x7125f58c - rust_try
  25:         0x7125f569 - rust_try
  26:         0x65382597 - run::h15ad65cc2cf082cdm6b
  27:         0x71221c32 - sys::tcp::TcpListener::bind::h29247aa3f005ffa1WSE
  28:     0x7ffd672316ad - BaseThreadInitThunk

Version:

rustc 1.0.0-nightly (270a677d4 2015-03-07) (built 2015-03-07)
binary: rustc
commit-hash: 270a677d4d698916f5ad103f0afc3c070b8dbeb4
commit-date: 2015-03-07
build-date: 2015-03-07
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly

The compiler seems to only panic when the enum is misspelled or missing, and passed directly as a function argument. The following (erroneous) code will not cause any compiler panics:

enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ }

fn use_token(token: &Token) { unimplemented!() }

fn main() {
    // yields the error: type `Token` does not implement any method in scope named `LeftParens`
    // The compiler error is correct behavior.
    let token = &Token::LeftParens;
    use_token(token);
}
enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ }

fn use_token(token: &Token) { unimplemented!() }

fn main() {
    // spelled correctly; compiles successfully
    use_token(&Token::LeftParen);
}
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 8, 2015
arielb1 pushed a commit to arielb1/rust that referenced this issue Jun 21, 2015

Verified

This commit was signed with the committer’s verified signature.
Nemo157 Nemo157
Previously it also tried to find out the best way to translate the
expression, which could ICE during type-checking.

Fixes rust-lang#23173
Fixes rust-lang#24322
Fixes rust-lang#25757
bors added a commit that referenced this issue Jun 21, 2015
Previously it also tried to find out the best way to translate the
expression, which could ICE during type-checking.

Fixes #23173
Fixes #24322
Fixes #25757

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants