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

Closed
chengniansun opened this issue Jan 17, 2022 · 3 comments · Fixed by #93024 or #96806
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@chengniansun
Copy link

chengniansun commented Jan 17, 2022

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

@chengniansun chengniansun 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 Jan 17, 2022
@compiler-errors
Copy link
Member

This doesn't require #![feature(trivial_bounds)] (but still requires mir-opt-level=3):

This code is a slight variation of the test case in ui/trait-bounds/issue-75961.rs, with an unused type parameter:

pub fn foo<'a, T>(s: &'a mut ()) where &'a mut (): Clone {
    <&mut () as Clone>::clone(&s);
}

fn main() {}

And -Ztreat-err-as-bug=1 suggests that this is due to the Inline mir pass.

I'll try to find a way to suppress this ICE.
@rustbot claim

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 23, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 17, 2022
…ds, r=estebank

Do not ICE when inlining a function with un-satisfiable bounds

Fixes rust-lang#93008
This is kinda a hack... but it's the fix I thought had the least blast-radius.

We use `normalize_param_env_or_error` to verify that the predicates in the param env are self-consistent, since with RevealAll, a bad predicate like `<&'static () as Clone>` will be evaluated with an empty ParamEnv (since it references no generics), and we'll raise an error for it.
@bors bors closed this as completed in cf3cd4c Feb 18, 2022
@JohnTitor
Copy link
Member

Triage: The test added in #93024 has mir-opt-level=4, not mir-opt-level=3, and the original issue still remains, re-opening.

@JohnTitor JohnTitor reopened this Feb 24, 2022
@compiler-errors
Copy link
Member

Thanks for catching this. I will look into this and be more careful about reproducing the issue in question.

@bors bors closed this as completed in cb9cb4d May 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 18, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 22, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 22, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
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. glacier ICE tracked in rust-lang/glacier. 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
4 participants