Skip to content
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

internal compiler error: librustc/hir/def.rs:249: attempted .def_id() on invalid def: Local(NodeId(767)) #2865

Closed
mmstick opened this issue Jun 21, 2018 · 6 comments
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mmstick
Copy link

mmstick commented Jun 21, 2018

  • clippy: commit 5f5fa0

Found another issue with Clippy (maybe Rust?) when using it on distinst. With the previous issue fixed, everything works now except for building the ffi workspace member. It builds fine without clippy, but fails with clippy.

/m/d/S/distinst (unit-tests:fe5ff0|+148 -113) # cargo build --manifest-path ffi/Cargo.toml
   Compiling distinst_ffi v0.3.2 (file:///mnt/data/Sources/distinst/ffi)
    Finished dev [unoptimized + debuginfo] target(s) in 2.15s
/m/d/S/distinst (unit-tests:fe5ff0|+148 -113) # env RUST_BACKTRACE=1 cargo +nightly clippy --manifest-path ffi/Cargo.toml
    Checking distinst_ffi v0.3.2 (file:///mnt/data/Sources/distinst/ffi)
error: internal compiler error: librustc/hir/def.rs:249: attempted .def_id() on invalid def: Local(NodeId(767))

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:515
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::session::opt_span_bug_fmt
  13: rustc::session::bug_fmt
  14: rustc::hir::def::Def::def_id
  15: <clippy_lints::fallible_impl_from::lint_impl_body::FindPanicUnwrap<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at clippy_lints/src/fallible_impl_from.rs:68
  16: rustc::hir::intravisit::walk_expr
             at /checkout/src/librustc/hir/intravisit.rs:997
  17: <clippy_lints::fallible_impl_from::lint_impl_body::FindPanicUnwrap<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at clippy_lints/src/fallible_impl_from.rs:85
  18: rustc::hir::intravisit::walk_arm
             at /checkout/src/librustc/hir/intravisit.rs:1111
  19: rustc::hir::intravisit::Visitor::visit_arm
             at /checkout/src/librustc/hir/intravisit.rs:270
  20: rustc::hir::intravisit::walk_expr
             at /mnt/data/Sources/rust-clippy/<walk_list macros>:2
  21: <clippy_lints::fallible_impl_from::lint_impl_body::FindPanicUnwrap<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at clippy_lints/src/fallible_impl_from.rs:85
  22: rustc::hir::intravisit::walk_block
             at /mnt/data/Sources/rust-clippy/<walk_list macros>:2
  23: rustc::hir::intravisit::Visitor::visit_block
             at /checkout/src/librustc/hir/intravisit.rs:264
  24: rustc::hir::intravisit::walk_expr
             at /checkout/src/librustc/hir/intravisit.rs:1051
  25: <clippy_lints::fallible_impl_from::lint_impl_body::FindPanicUnwrap<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at clippy_lints/src/fallible_impl_from.rs:85
  26: rustc::hir::intravisit::walk_block
             at /mnt/data/Sources/rust-clippy/<walk_list macros>:2
  27: rustc::hir::intravisit::Visitor::visit_block
             at /checkout/src/librustc/hir/intravisit.rs:264
  28: rustc::hir::intravisit::walk_expr
             at /checkout/src/librustc/hir/intravisit.rs:1051
  29: <clippy_lints::fallible_impl_from::lint_impl_body::FindPanicUnwrap<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at clippy_lints/src/fallible_impl_from.rs:85
  30: clippy_lints::fallible_impl_from::lint_impl_body
             at clippy_lints/src/fallible_impl_from.rs:107
  31: <clippy_lints::fallible_impl_from::FallibleImplFrom as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
             at clippy_lints/src/fallible_impl_from.rs:46
  32: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  33: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  34: rustc::hir::intravisit::walk_item
  35: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  36: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  37: rustc::hir::intravisit::walk_crate
  38: rustc::lint::context::check_crate
  39: rustc::util::common::time
  40: rustc::ty::context::tls::enter_context
  41: <std::thread::local::LocalKey<T>>::with
  42: rustc::ty::context::TyCtxt::create_and_enter
  43: rustc_driver::driver::compile_input
  44: rustc_driver::run_compiler_with_pool
  45: <scoped_tls::ScopedKey<T>>::set
  46: syntax::with_globals
  47: rustc_driver::run_compiler
  48: clippy_driver::main
             at src/driver.rs:136
  49: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  50: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  51: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  52: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  53: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  54: main
  55: __libc_start_main
  56: _start
query stack during panic:
end of query stack
@mati865
Copy link
Contributor

mati865 commented Jun 21, 2018

I can see tomorrow if I can find the reason unless somebody does it sooner.

So far distinst looks like a good candidate for testing clippy stability. 😁

@phansch
Copy link
Member

phansch commented Jun 21, 2018

@mati865 Feel free to add it integration tests, we don't have a lot of ffi code in there, yet 👍

@phansch phansch added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 21, 2018
@mati865
Copy link
Contributor

mati865 commented Jun 22, 2018

Running clippy on this code shows huge amount of warnings and error so I'm not sure if it's ready for our integration test.


I don't have enough knowledge about hir to solve it but this should be helpful:

Minimal repro:

struct Ice {
    size: String
}

impl<'a> From<String> for Ice {
    fn from(ice: String) -> Self {
        let text = || "iceberg".to_string();
        Self { size: text() }
    }
}

Closure is crucial here, it becomes rustc::hir::def::Def::Local(..) which is not supported by def_id().

Code triggering this bug:
https://github.com/rust-lang-nursery/rust-clippy/blob/5f5fa084ec89d692c251e28ca8923a75b29cb1af/clippy_lints/src/fallible_impl_from.rs#L67-L69

@mmstick
Copy link
Author

mmstick commented Jun 22, 2018

The errors in the master branch are just due to opaque FFI pointers. Clippy doesn't seem to like the concept at all, although it's necessary for sharing complex Rust types with C.

@mati865
Copy link
Contributor

mati865 commented Jun 22, 2018

@mmstick unfortunately it's kinda expected. If you want to use clippy in that project you will have to whitelist specific lints, for whole project it's:

#![cfg_attr(feature = "cargo-clippy", allow(lint_name))]
// OR
#![allow(unknown_lints)]
#![allow(lint_name)]

@mmstick
Copy link
Author

mmstick commented Jun 22, 2018

@mati865 That's basically what this PR is doing: pop-os/distinst#114, with #![allow(cast_ptr_alignment)] in the ffi member.

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

No branches or pull requests

3 participants