Skip to content

ICE with "--crate-type lib --Z mir-opt-level-3": Unimplemented selecting Binder(<&str as Foo>, []) during codegen #93008

@chengniansun

Description

@chengniansun

Code

#![feature(trivial_bounds)]
trait Foo {
    fn test(self);
}
fn baz<T>()
where
    &'static str: Foo,
{
    "Foo".test()
}

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (bd3cb5256 2022-01-16)
binary: rustc
commit-hash: bd3cb52565faab2755ff1bdb54d88bc91f47b4b9
commit-date: 2022-01-16
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Error output

warning: function is never used: `baz`
 --> mutant_7722893.rs:5:4
  |
5 | fn baz<T>()
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters
 --> mutant_7722893.rs:7:19
  |
7 |     &'static str: Foo,
  |                   ^^^
  |
  = note: `#[warn(trivial_bounds)]` on by default

warning: 2 warnings emitted

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<&str as Foo>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.60.0-nightly (bd3cb5256 2022-01-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 --crate-type lib

query stack during panic:
end of query stack
Backtrace

warning: function is never used: `baz`
 --> mutant_7722893.rs:5:4
  |
5 | fn baz<T>()
  |    ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: trait bound &'static str: Foo does not depend on any type or lifetime parameters
 --> mutant_7722893.rs:7:19
  |
7 |     &'static str: Foo,
  |                   ^^^
  |
  = note: `#[warn(trivial_bounds)]` on by default

warning: 2 warnings emitted

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<&str as Foo>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/bd3cb52565faab2755ff1bdb54d88bc91f47b4b9/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/bd3cb52565faab2755ff1bdb54d88bc91f47b4b9/library/core/src/panicking.rs:110:14
   2: core::panicking::panic_display::<&str>
   3: <rustc_errors::HandlerInner>::flush_delayed
   4: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   6: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   7: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   8: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   9: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
  10: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.60.0-nightly (bd3cb5256 2022-01-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 --crate-type lib

query stack during panic:
end of query stack

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions