Skip to content

ICE: trivial_numeric_casts when using SDL on nightly #42007

Description

@andrewhickman

Compiling this short snippet causes a compiler panic

extern crate sdl2;

use sdl2::mouse::MouseButton;

enum Input {
    MouseButton(MouseButton),
}

fn main() {}

Compiler version:

PS C:\Users\me\Documents\rust\sdltest> rustc --version --verbose
rustc 1.17.0 (56124baa9 2017-04-24)
binary: rustc
commit-hash: 56124baa9e73f28c0709e59e74783cf234a978cf
commit-date: 2017-04-24
host: x86_64-pc-windows-msvc
release: 1.17.0
LLVM version: 3.9

SDL version was 0.29.0.

Backtrace:

PS C:\Users\me\Documents\rust\sdltest> cargo +nightly build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling sdl2-sys v0.27.3
   Compiling sdltest v0.1.0 (file:///C:/Users/me/Documents/rust/sdltest)
   Compiling sdl2 v0.29.1
error: internal compiler error: unexpected panic

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

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'invalid lint-id `trivial_numeric_casts`', src\librustc\lint\context.rs:1322
stack backtrace:
   0: <std::time::SystemTimeError as core::fmt::Display>::fmt
   1: std::panicking::Location::line
   2: std::panicking::Location::line
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic_fmt
   5: std::panicking::begin_panic_fmt
   6: <unknown>
   7: rustc_metadata::decoder::<impl rustc_metadata::cstore::CrateMetadata>::item_body_tables
   8: rustc_metadata::cstore_impl::provide
   9: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  10: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  11: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  12: rustc_const_eval::eval::provide
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  14: rustc::ty::maps::TyCtxtAt::const_eval
  15: rustc::ty::layout::Layout::compute_uncached
  16: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::needs_drop_uncached
  17: <rustc::util::common::Indenter as core::ops::Drop>::drop
  18: rustc::ty::layout::Layout::compute_uncached
  19: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  20: rustc::lint::context::gather_attrs
  21: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  22: rustc::lint::context::check_crate
  23: rustc_driver::driver::count_nodes
  24: rustc_driver::driver::count_nodes
  25: rustc_driver::driver::compile_input
  26: rustc_driver::run_compiler
  27: <unknown>
  28: _rust_maybe_catch_panic
  29: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_impl_item
  30: std::sys::imp::thread::Thread::new
  31: BaseThreadInitThunk

error: Could not compile `sdltest`.

To learn more, run the command again with --verbose.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on May 15, 2017
  2. est31 commented on May 15, 2017

    @est31
    Member

    Minimal reproducible example (without sdl2 requirement):

    lib.rs of crate "s":

    #[repr(u8)]
    pub enum E {
        B = 1 as u8,
    }

    main.rs of crate "t":

    extern crate s;
    
    enum I {
        E(s::E),
    }
    
    fn main() {}
  3. kennytm commented on May 15, 2017

    @kennytm
    Member

    No repro on stable (Regression).

    The error on this line (<LintId as Decodable>::decode()) is FindLintError::NotFound. The LintStore is actually empty at this point.

    The LintStore becomes empty due to check_crate temporarily moving out the LintStore until the end of the function. But walk_crate eventually needs to decode the crate "s", which has an trivial_numeric_casts lint that is not found in the empty LintStore.

    Very detailed stack trace when nothing is inlined
       7: std::panicking::begin_panic_fmt
       8: rustc::lint::context::<impl serialize::serialize::Decodable for rustc::lint::LintId>::decode::{{closure}}
       9: rustc::ty::context::tls::with::{{closure}}
      10: <std::thread::local::LocalKey<T>>::with
      11: rustc::ty::context::tls::with
      12: rustc::lint::context::<impl serialize::serialize::Decodable for rustc::lint::LintId>::decode
      13: core::ops::FnOnce::call_once
      14: serialize::serialize::Decoder::read_struct_field
      15: <rustc::lint::context::EarlyLint as serialize::serialize::Decodable>::decode::{{closure}}
      16: serialize::serialize::Decoder::read_struct
      17: <rustc::lint::context::EarlyLint as serialize::serialize::Decodable>::decode
      18: <collections::vec::Vec<T> as serialize::serialize::Decodable>::decode::{{closure}}::{{closure}}
      19: serialize::serialize::Decoder::read_seq_elt
      20: <collections::vec::Vec<T> as serialize::serialize::Decodable>::decode::{{closure}}
      21: serialize::serialize::Decoder::read_seq
      22: <collections::vec::Vec<T> as serialize::serialize::Decodable>::decode
      23: serialize::collection_impls::<impl serialize::serialize::Decodable for std::collections::hash::map::HashMap<K, V, S>>::decode::{{closure}}::{{closure}}
      24: serialize::serialize::Decoder::read_map_elt_val
      25: serialize::collection_impls::<impl serialize::serialize::Decodable for std::collections::hash::map::HashMap<K, V, S>>::decode::{{closure}}
      26: serialize::serialize::Decoder::read_map
      27: serialize::collection_impls::<impl serialize::serialize::Decodable for std::collections::hash::map::HashMap<K, V, S>>::decode
      28: core::ops::FnOnce::call_once
      29: serialize::serialize::Decoder::read_struct_field
      30: <rustc::lint::table::LintTable as serialize::serialize::Decodable>::decode::{{closure}}
      31: serialize::serialize::Decoder::read_struct
      32: <rustc::lint::table::LintTable as serialize::serialize::Decodable>::decode
      33: core::ops::FnOnce::call_once
      34: serialize::serialize::Decoder::read_struct_field
      35: <rustc::ty::context::TypeckTables<'tcx> as serialize::serialize::Decodable>::decode::{{closure}}
      36: serialize::serialize::Decoder::read_struct
      37: <rustc::ty::context::TypeckTables<'tcx> as serialize::serialize::Decodable>::decode
      38: rustc_metadata::decoder::<impl rustc_metadata::schema::Lazy<T>>::decode
      39: rustc_metadata::decoder::<impl rustc_metadata::cstore::CrateMetadata>::item_body_tables
      40: rustc_metadata::cstore_impl::provide::typeck_tables_of
      41: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get_with::{{closure}}
      42: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
      43: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get_with
      44: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
      45: rustc::ty::maps::TyCtxtAt::typeck_tables_of
      46: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
      47: rustc_const_eval::eval::const_eval
      48: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get_with::{{closure}}
      49: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
      50: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get_with
      51: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
      52: rustc::ty::maps::TyCtxtAt::const_eval
      53: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::const_eval
      54: rustc::ty::AdtDef::discriminants::{{closure}}
      55: core::ops::impls::<impl core::ops::FnOnce<A> for &'a mut F>::call_once
      56: <core::option::Option<T>>::map
      57: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
      58: rustc::ty::layout::Layout::compute_uncached
      59: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::layout
      60: rustc::ty::layout::Layout::compute_uncached::{{closure}}
      61: core::ops::impls::<impl core::ops::FnOnce<A> for &'a mut F>::call_once
      62: <core::option::Option<T>>::map
      63: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
      64: <<core::result::Result<V, E> as core::iter::traits::FromIterator<core::result::Result<A, E>>>::from_iter::Adapter<Iter, E> as core::iter::iterator::Iterator>::next
      65: <&'a mut I as core::iter::iterator::Iterator>::next
      66: <collections::vec::Vec<T> as collections::vec::SpecExtend<T, I>>::from_iter
      67: <collections::vec::Vec<T> as core::iter::traits::FromIterator<T>>::from_iter
      68: <core::result::Result<V, E> as core::iter::traits::FromIterator<core::result::Result<A, E>>>::from_iter
      69: core::iter::iterator::Iterator::collect
      70: rustc::ty::layout::Layout::compute_uncached
      71: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::layout
      72: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item::{{closure}}
      73: rustc::infer::InferCtxtBuilder::enter::{{closure}}
      74: rustc::ty::context::tls::enter::{{closure}}
      75: <std::thread::local::LocalKey<T>>::with
      76: rustc::ty::context::tls::enter
      77: rustc::ty::context::GlobalCtxt::enter_local
      78: rustc::infer::InferCtxtBuilder::enter
      79: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
      80: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::{{closure}}
      81: rustc::lint::context::LintContext::with_lint_attrs
      82: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
      83: rustc::hir::intravisit::Visitor::visit_nested_item
      84: rustc::hir::intravisit::walk_mod
      85: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
      86: rustc::hir::intravisit::walk_crate
      87: rustc::lint::context::check_crate::{{closure}}
      88: rustc::lint::context::LintContext::with_lint_attrs
      89: rustc::lint::context::check_crate
      90: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}
    
  4. added a commit that references this issue on May 17, 2017
    b384b18
  5. added a commit that references this issue on May 23, 2017
    b2310e1
  6. added 2 commits that reference this issue on May 24, 2017
    72ac47a
    2211464
  7. added a commit that references this issue on May 25, 2017
    deb90c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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