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

assertion failed: (left == right) in relate_tys.rs #88446

Closed
sffc opened this issue Aug 29, 2021 · 2 comments · Fixed by #88811
Closed

assertion failed: (left == right) in relate_tys.rs #88446

sffc opened this issue Aug 29, 2021 · 2 comments · Fixed by #88811
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

@sffc
Copy link

sffc commented Aug 29, 2021

This is a bug potentially related to #86702 or #84937, possibly relating to lifetime resolution in a function argument that involves HRTBs.

I did my best to reduce the example, but I couldn't do it completely in isolation from the rest of the ICU4X project code.

To reproduce:

  1. Check out sffc/omnicu@30eaa22
  2. cd to provider/core
  3. Run cargo +nightly-2021-08-27 check --all-targets

Code

// This depends on DataPayload from ICU4X (see link above)

struct Options {}

fn demo(options: &Options) {
    let p1: DataPayload<HelloWorldV1Marker> = todo!();
    let p2: DataPayload<HelloWorldV1MessageMarker> =
        p1.map_project_with_capture(options, |obj, options, _| todo!());
}

Here is the definition of the function map_project_with_capture, which you can also find in the linked branch:

    pub fn map_project_with_capture<M2, T>(
        self,
        capture: T,
        f: for<'a> fn(
            <M::Yokeable as Yokeable<'a>>::Output,
            capture: T,
            PhantomData<&'a ()>,
        ) -> <M2::Yokeable as Yokeable<'a>>::Output,
    ) -> DataPayload<'data, M2>
    where
        M2: DataMarker<'data, Cart = M::Cart>,
    {
        use DataPayloadInner::*;
        match self.inner {
            RcStruct(yoke) => DataPayload {
                inner: RcStruct(yoke.project_with_capture(capture, f)),
            },
            Owned(yoke) => DataPayload {
                inner: Owned(yoke.project_with_capture(capture, f)),
            },
            RcBuf(yoke) => DataPayload {
                inner: RcBuf(yoke.project_with_capture(capture, f)),
            },
        }
    }

Yoke::project_with_capture can be found in the yoke crate on crates.io:

https://docs.rs/yoke/0.2.3/yoke/struct.Yoke.html#method.project_with_capture

Meta

rustc --version --verbose:

$ cargo +nightly-2021-08-27 rustc -- --version --verbose
rustc 1.56.0-nightly (ad02dc46b 2021-08-26)
binary: rustc
commit-hash: ad02dc46badee510bd3a2c093edf80fcaade91b1
commit-date: 2021-08-26
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `U3`,
 right: `U4`', compiler/rustc_mir/src/borrow_check/type_check/relate_tys.rs:86:9
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.56.0-nightly (ad02dc46b 2021-08-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `demo::{closure#0}`
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/ad02dc46badee510bd3a2c093edf80fcaade91b1/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/ad02dc46badee510bd3a2c093edf80fcaade91b1/library/core/src/panicking.rs:101:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: <rustc_mir::borrow_check::type_check::relate_tys::NllTypeRelatingDelegate as rustc_infer::infer::nll_relate::TypeRelatingDelegate>::create_next_universe
   5: rustc_infer::infer::nll_relate::TypeRelating<D>::create_scope::{{closure}}
   6: <rustc_infer::infer::nll_relate::ScopeInstantiator as rustc_middle::ty::fold::TypeVisitor>::visit_region
   7: <core::iter::adapters::copied::Copied<I> as core::iter::traits::iterator::Iterator>::try_fold
   8: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_visit_with
   9: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_visit_with
  10: <core::iter::adapters::copied::Copied<I> as core::iter::traits::iterator::Iterator>::try_fold
  11: <rustc_infer::infer::nll_relate::TypeRelating<D> as rustc_middle::ty::relate::TypeRelation>::binders
  12: rustc_middle::ty::relate::super_relate_tys
  13: rustc_infer::infer::combine::<impl rustc_infer::infer::InferCtxt>::super_combine_tys
  14: rustc_middle::ty::relate::TypeRelation::relate
  15: <rustc_middle::ty::subst::GenericArg as rustc_middle::ty::relate::Relate>::relate
  16: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  17: <core::result::Result<T,E> as rustc_middle::ty::context::InternIteratorElement<T,R>>::intern_with
  18: rustc_middle::ty::relate::super_relate_tys
  19: rustc_infer::infer::combine::<impl rustc_infer::infer::InferCtxt>::super_combine_tys
  20: rustc_middle::ty::relate::TypeRelation::relate
  21: rustc_middle::ty::relate::super_relate_tys
  22: rustc_infer::infer::combine::<impl rustc_infer::infer::InferCtxt>::super_combine_tys
  23: rustc_middle::ty::relate::TypeRelation::relate
  24: rustc_mir::borrow_check::type_check::TypeChecker::relate_types
  25: rustc_mir::borrow_check::type_check::input_output::<impl rustc_mir::borrow_check::type_check::TypeChecker>::equate_normalized_input_or_output
  26: rustc_mir::borrow_check::type_check::type_check
  27: rustc_mir::borrow_check::nll::compute_regions
  28: rustc_mir::borrow_check::do_mir_borrowck
  29: rustc_infer::infer::InferCtxtBuilder::enter
  30: rustc_mir::borrow_check::mir_borrowck
  31: core::ops::function::FnOnce::call_once
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_data_structures::stack::ensure_sufficient_stack
  34: rustc_query_system::query::plumbing::force_query_with_job
  35: rustc_query_system::query::plumbing::get_query_impl
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  37: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  38: rustc_interface::passes::analysis
  39: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  40: rustc_data_structures::stack::ensure_sufficient_stack
  41: rustc_query_system::query::plumbing::force_query_with_job
  42: rustc_query_system::query::plumbing::get_query_impl
  43: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  44: rustc_interface::passes::QueryContext::enter
  45: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  46: rustc_span::with_source_map
  47: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

CC @Manishearth

@sffc sffc 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 Aug 29, 2021
@hellow554
Copy link
Contributor

MCVE:

trait Yokeable<'a> {
    type Output: 'a;
}
impl<'a> Yokeable<'a> for () {
    type Output = ();
}

trait DataMarker<'data> {
    type Yokeable: for<'a> Yokeable<'a>;
}
impl<'data> DataMarker<'data> for () {
    type Yokeable = ();
}

struct DataPayload<'data, M>(&'data M);

impl DataPayload<'static, ()> {
    pub fn map_project_with_capture<M2, T>(
        _: for<'a> fn(
            capture: T,
            std::marker::PhantomData<&'a ()>,
        ) -> <M2::Yokeable as Yokeable<'a>>::Output,
    ) -> DataPayload<'static, M2>
    where
        M2: DataMarker<'static>,
    {
        todo!()
    }
}

fn main() {
    let _: DataPayload<()> = DataPayload::<()>::map_project_with_capture::<_, &()>(|_, _| todo!());
}

Bisecting now

@hellow554
Copy link
Contributor

searched nightlies: from nightly-2021-07-21 to nightly-2021-08-30
regressed nightly: nightly-2021-08-26
searched commits: from b03ccac to 0afc208
regressed commit: 0afc208

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --end=2021-08-30 --regress ice --access=github

cc #85499 @jackh726

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
Development

Successfully merging a pull request may close this issue.

3 participants