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

ice when running clippy-driver on ./ui/trivial-bounds/trivial-bounds-inconsistent.rs #69874

Closed
matthiaskrgr opened this issue Mar 10, 2020 · 1 comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

I'm reporting this in the rustc repo because this crash seems to happen in rustc code.
Feel free to move this to the clippy repo if its a clippy bug.

Code

This code is reduced from ./ui/trivial-bounds/trivial-bounds-inconsistent.rs

#![feature(trivial_bounds)]
fn use_for() where i32: Iterator { //~ WARNING trivial_bounds
    for _ in 2i32 {}
}
fn main() {}

Meta

rustc --version --verbose:

rustc 1.43.0-nightly (564758c4c 2020-03-08)
binary: rustc
commit-hash: 564758c4c329e89722454dd2fbb35f1ac0b8b47c
commit-date: 2020-03-08
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

clippy 0.0.212 (329923e 2020-03-04)

Error output

warning: function is never used: `use_for`
 --> ./ui/trivial-bounds/trivial-bounds-inconsistent.rs:2:4
  |
2 | fn use_for() where i32: Iterator { //~ WARNING trivial_bounds
  |    ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:35: could not fully normalize `std::option::Option<<i32 as std::iter::Iterator>::Item>`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:875:9
Backtrace

warning: function is never used: `use_for`
 --> ./ui/trivial-bounds/trivial-bounds-inconsistent.rs:2:4
  |
2 | fn use_for() where i32: Iterator { //~ WARNING trivial_bounds
  |    ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:35: could not fully normalize `std::option::Option<<i32 as std::iter::Iterator>::Item>`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:875:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1063
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   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:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: clippy_driver::report_clippy_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  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_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc::ty::context::GlobalCtxt::enter_local
  21: rustc_traits::normalize_erasing_regions::normalize_ty_after_erasing_regions
  22: rustc::ty::query::__query_compute::normalize_ty_after_erasing_regions
  23: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::normalize_ty_after_erasing_regions>::compute
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  26: <rustc::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc::ty::fold::TypeFolder>::fold_ty
  27: rustc::ty::util::<impl rustc::ty::TyS>::needs_drop
  28: rustc_mir::dataflow::drop_flag_effects::on_all_children_bits::on_all_children_bits
  29: <rustc_mir::transform::elaborate_drops::ElaborateDrops as rustc_mir::transform::MirPass>::run_pass
  30: rustc_mir::transform::run_passes
  31: rustc_mir::transform::run_optimization_passes
  32: rustc_mir::transform::optimized_mir
  33: rustc::ty::query::__query_compute::optimized_mir
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: <clippy_lints::implicit_return::ImplicitReturn as rustc_lint::passes::LateLintPass>::check_fn
  38: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_fn
  39: rustc_hir::intravisit::walk_item
  40: rustc_hir::intravisit::Visitor::visit_nested_item
  41: rustc_hir::intravisit::walk_crate
  42: rustc_lint::late::late_lint_pass_crate
  43: rustc_session::utils::<impl rustc_session::session::Session>::time
  44: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  45: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  46: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:86
  47: rustc_session::utils::<impl rustc_session::session::Session>::time
  48: rustc_interface::passes::analysis
  49: rustc::ty::query::__query_compute::analysis
  50: rustc::dep_graph::graph::DepGraph::with_task_impl
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  52: rustc::ty::context::tls::enter_global
  53: rustc_interface::interface::run_compiler_in_existing_thread_pool
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-clippy/issues/new

note: Clippy version: clippy 0.0.212 (329923e 2020-03-04)

query stack during panic:
#0 [normalize_ty_after_erasing_regions] normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: std::option::Option<<i32 as std::iter::Iterator>::Item> }`
#1 [optimized_mir] processing `use_for`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 10, 2020
@sinkuu
Copy link
Contributor

sinkuu commented Mar 10, 2020

This is indeed an clippy bug. Under trivial_bounds functions may have unsatisfiable predicates, which prohibits instantiating them. implicit_return unconditionally tries to build MIRs for functions, but it should not.

bors added a commit to rust-lang/rust-clippy that referenced this issue Mar 10, 2020
Fix ICE with trivial_bounds feature

rust-lang/rust#69874 (comment)

changelog: Fix ICE with trivial_bounds feature
@Centril Centril closed this as completed Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants