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 feature(non_lifetime_binders) #119941

Closed
rebenkoy opened this issue Jan 13, 2024 · 0 comments · Fixed by #119947
Closed

ICE with feature(non_lifetime_binders) #119941

rebenkoy opened this issue Jan 13, 2024 · 0 comments · Fixed by #119947
Assignees
Labels
C-bug Category: This is a bug. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@rebenkoy
Copy link

Code

#![feature(non_lifetime_binders)]

use std::marker::PhantomData;

pub trait Foo<T: ?Sized> {
    type Bar<K: ?Sized>;
}

pub struct Bar<T: ?Sized> {
    pd: PhantomData<T>
}

pub struct Baz {}

impl Foo<usize> for Baz {
    type Bar<K: ?Sized> = Bar<K>;
}

pub fn f<T1, T2>(a: T1, b: T2)
where
    T1: for <T> Foo<usize, Bar<T> = Bar<T>>, 
    T2: for <T> Foo<usize, Bar<T> = T1::Bar<T>>,
{}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        f(Baz{}, Baz{});
    }
}

minimal project with full compiler output can be found here
https://github.com/rebenkoy/rust-ice-non_lifetime_binders/blob/main/src/lib.rs

Meta

cargo 1.77.0-nightly (3e428a38a 2024-01-09)

rustc --version --verbose:

rustc 1.77.0-nightly (a2d9d73e6 2024-01-10)
binary: rustc
commit-hash: a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01
commit-date: 2024-01-10
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Error output


error: internal compiler error: no errors encountered even though `span_delayed_bug` issued

error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: Normalize { value: Binder { value: ProjectionPredicate(AliasTy { args: [Baz, usize, ^"T"], def_id: DefId(0:6 ~ rust_bug_non_lifetime_binders[0776]::Foo::Bar) }, Term::Ty(Alias(Projection, AliasTy { args: [Baz, usize, ^"T"], def_id: DefId(0:6 ~ rust_bug_non_lifetime_binders[0776]::Foo::Bar) }))), bound_vars: [Ty(Param(DefId(0:19 ~ rust_bug_non_lifetime_binders[0776]::f::T#1), "T"))] } } }
Backtrace

note: delayed at /rustc/a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs:157:29
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
         4: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
         5: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
         6: rustc_borrowck::type_check::type_check
         7: rustc_borrowck::nll::compute_regions
         8: rustc_borrowck::do_mir_borrowck
         9: rustc_borrowck::mir_borrowck
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        12: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        13: rustc_interface::passes::analysis
        14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        16: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        17: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
        18: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01/library/alloc/src/boxed.rs:2016:9
        21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01/library/alloc/src/boxed.rs:2016:9
        22: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/a2d9d73e608f1b24eba840c4fd2d68dbe3b65e01/library/std/src/sys/unix/thread.rs:108:17
        23: start_thread
                   at ./nptl/pthread_create.c:442:8
        24: clone3
                   at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  --> src/lib.rs:31:9
   |
31 |         f(Baz{}, Baz{});
   |         ^^^^^^^^^^^^^^^

@rebenkoy rebenkoy 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 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 13, 2024
@compiler-errors compiler-errors added requires-nightly This issue requires a nightly compiler in some way. T-types Relevant to the types team, which will review and decide on the PR/issue. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 13, 2024
@compiler-errors compiler-errors self-assigned this Jan 13, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 15, 2024
…te-response, r=<try>

Make sure to instantiate placeholders correctly in old solver

When creating the query substitution guess for an input placeholder type like `!1_T` (in universe 1), we were guessing the response substitution with something like `!0_T`. This failed to unify with `!1_T`, causing an ICE.

This PR reworks the query substitution guess code to work a bit more like the new solver. I'm *pretty* sure this is correct, though I'd really appreciate some scrutiny from someone (*cough* lcnr) who knows a bit more about query instantiation :)

Fixes rust-lang#119941

r? lcnr
@bors bors closed this as completed in 533cfde Jan 16, 2024
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. F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants