profile
viewpoint

Ask questionsInternal compiler error: can't buffer lints after HIR lowering

Hi there,

I'm updating rust-sgx-sdk (solving rust-sgx-sdk #161) to use latest rust nightly compiler to help the error info more ergonomic by the help of #60561. However, the compiler always panics. Your help would be very much helpful.

The current code is at https://github.com/baidu/rust-sgx-sdk/tree/librustc-bug-report . To reproduce this bug, please checkout branch librustc-bug-report and build sgx_tstd as follows:

git clone https://github.com/baidu/rust-sgx-sdk.git --branch librustc-bug-report
cd sgx_tstd
cargo build

And the reproducible failure info is:

error: internal compiler error: src/librustc/session/mod.rs:379: can't buffer lints after HIR lowering

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:915:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

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: rustc 1.40.0-nightly (032a53a06 2019-10-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type rlib

note: some of the compiler flags provided by cargo are hidden

error: aborting due to previous error

error: could not compile `sgx_tstd`.

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

Meta

rustc --version --verbose: rustc 1.40.0-nightly (032a53a06 2019-10-03) binary: rustc commit-hash: 032a53a06ce293571e51bbe621a5c480e8a28e95 commit-date: 2019-10-03 host: x86_64-unknown-linux-gnu release: 1.40.0-nightly LLVM version: 9.0

Backtrace:

     Running `rustc --edition=2018 --crate-name sgx_tstd src/lib.rs --color always --crate-type rlib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="stdio"' -C metadata=efa82b20f3ba8732 -C extra-filename=-efa82b20f3ba8732 --out-dir /home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps -C incremental=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/incremental -L dependency=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps --extern sgx_alloc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_alloc-ad20d7e0fe6e7e8f.rmeta --extern sgx_backtrace_sys=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_backtrace_sys-fb71f2a27217c86f.rmeta --extern sgx_demangle=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_demangle-7efcf1000ae681fd.rmeta --extern sgx_libc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_libc-c007d9004d6eb876.rmeta --extern sgx_tprotected_fs=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_tprotected_fs-1993701cdf0742cc.rmeta --extern sgx_trts=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_trts-4601b4cac7f4f271.rmeta --extern sgx_types=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_types-e6e7a9a7cef74d06.rmeta --extern sgx_unwind=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_unwind-f3194af852ce8a4e.rmeta -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace/ -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_unwind-cde3a2cab833ed9c/out/libunwind/src/.libs`
error: internal compiler error: src/librustc/session/mod.rs:379: can't buffer lints after HIR lowering

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:915:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_context_opt
  18: rustc::ty::context::tls::with_opt
  19: rustc::util::bug::opt_span_bug_fmt
  20: rustc::util::bug::bug_fmt
  21: rustc::session::Session::buffer_lint
  22: rustc::middle::stability::report_unstable
  23: rustc::middle::stability::<impl rustc::ty::context::TyCtxt>::check_stability
  24: rustc::hir::intravisit::walk_item
  25: <rustc::middle::stability::Checker as rustc::hir::intravisit::Visitor>::visit_item
  26: rustc::middle::stability::check_mod_unstable_api_usage
  27: rustc::ty::query::__query_compute::check_mod_unstable_api_usage
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_mod_unstable_api_usage>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  32: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  33: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  34: rustc_interface::passes::analysis::{{closure}}
  35: rustc::util::common::time
  36: rustc_interface::passes::analysis
  37: rustc::ty::query::__query_compute::analysis
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  41: rustc_interface::passes::create_global_ctxt::{{closure}}
  42: rustc_interface::interface::run_compiler_in_existing_thread_pool
  43: std::thread::local::LocalKey<T>::with
  44: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.40.0-nightly (032a53a06 2019-10-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type rlib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_mod_unstable_api_usage] checking for unstable API usage in module `prelude::v1`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `sgx_tstd`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name sgx_tstd src/lib.rs --color always --crate-type rlib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="stdio"' -C metadata=efa82b20f3ba8732 -C extra-filename=-efa82b20f3ba8732 --out-dir /home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps -C incremental=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/incremental -L dependency=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps --extern sgx_alloc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_alloc-ad20d7e0fe6e7e8f.rmeta --extern sgx_backtrace_sys=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_backtrace_sys-fb71f2a27217c86f.rmeta --extern sgx_demangle=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_demangle-7efcf1000ae681fd.rmeta --extern sgx_libc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_libc-c007d9004d6eb876.rmeta --extern sgx_tprotected_fs=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_tprotected_fs-1993701cdf0742cc.rmeta --extern sgx_trts=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_trts-4601b4cac7f4f271.rmeta --extern sgx_types=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_types-e6e7a9a7cef74d06.rmeta --extern sgx_unwind=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_unwind-f3194af852ce8a4e.rmeta -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace/ -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_unwind-cde3a2cab833ed9c/out/libunwind/src/.libs` (exit code: 101)
rust-lang/rust

Answer questions dingelish

The minimum sample is as follows:

#![no_std]

pub use core::prelude::v1::bench;

and compile by

rustc --crate-type rlib fail.rs
useful!

Related questions

Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 3
Archive all nightlies hot 3
using 'cargo install xsv' on windows 10 triggers rustc internal error hot 2
if/while Some(n) = &mut foo sugar will leak a temporary mutable borrow to current scope in particular situation hot 2
under latest MinGW, cannot link with C code using stdout hot 2
chain() make collect very slow hot 1
build an empty project failed (undefined reference to `__onexitbegin') hot 1
Invalid collision with TryFrom implementation? hot 1
Crater runs for Rust 1.38.0 hot 1
Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 1
Building LLVM with Clang fails hot 1
E0373 help suggests `move async` but the correct syntax is `async move` hot 1
Tracking issue for `Option::contains` and `Result::contains` hot 1
async fn + rustfmt don't "just work" inside of RLS hot 1
Include images in rustdoc output hot 1
source:https://uonfu.com/
Github User Rank List