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

regression when relating two opaque types in canonical queries #116877

Closed
aliemjay opened this issue Oct 18, 2023 · 3 comments · Fixed by #122077
Closed

regression when relating two opaque types in canonical queries #116877

aliemjay opened this issue Oct 18, 2023 · 3 comments · Fixed by #122077
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@aliemjay
Copy link
Member

aliemjay commented Oct 18, 2023

Each revision of this test is an ICE in 1.75.0-nightly (2023-10-17 09df610):

// revisions: sized clone

#[cfg(sized)] fn rpit() -> impl Sized {}
#[cfg(clone)] fn rpit() -> impl Clone {}

fn same_output<Out>(_: impl Fn() -> Out, _: impl Fn() -> Out) {}

pub fn foo() -> impl Sized {
    same_output(rpit, foo);
    same_output(foo, rpit);
    rpit()
}

Both revisions have a somewhat convoluted history best shown in a table form:

sized clone
stable 1.73 PASS 🆗 ICE 🧊
#114586 (1.74.0-beta) PASS 🆗 PASS 🆗
#116530 (1.75.0-nightly) ICE 🧊 ICE 🧊

While it may seem like #116530 is the culprit, I'd argue that the PR #114586 introduced an incomplete fix that I don't believe we should commit to in stable. Additionally, reverting #114586 while keeping #116530 would fix sized version as well as an other regression #114586 (comment), making it the right choice in my opinion.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 18, 2023
@aliemjay aliemjay added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 18, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 18, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-critical

@rustbot rustbot added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 18, 2023
aliemjay added a commit to aliemjay/rust that referenced this issue Oct 18, 2023
…li-obk

revert rust-lang#114586

Reverts rust-lang#114586.

cc rust-lang#116877 (not closing until this gets a beta backport)
fixes rust-lang#116684
fixes rust-lang#114586 (comment)

r? `@oli-obk` or `@lcnr`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 18, 2023
Rollup merge of rust-lang#116879 - aliemjay:revert-opaque-bubble, r=oli-obk

revert rust-lang#114586

Reverts rust-lang#114586.

cc rust-lang#116877 (not closing until this gets a beta backport)
fixes rust-lang#116684
fixes rust-lang#114586 (comment)

r? `@oli-obk` or `@lcnr`
@aliemjay
Copy link
Member Author

#116879 was backported to beta; clone revision of the test above no longer passes in beta and sized revision is no longer an ICE in nightly.

@matthiaskrgr
Copy link
Member

looks like sized no longer crashes, clone does now 🤔

rustc 116877.rs --edition=2021 --cfg=clone --crate-type lib

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: {OpaqueTypeKey { def_id: DefId(0:7 ~ 116877[6766]::rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(0:10 ~ 116877[6766]::foo::{opaque#0}) }) } }}
  |
  = note: delayed at compiler/rustc_infer/src/infer/opaque_types/table.rs:43:43
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxt>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: rustc_traits::type_op::type_op_prove_predicate
             4: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_op_prove_predicate::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             5: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_type_ir::canonical::Canonical<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
             6: rustc_query_impl::query_impl::type_op_prove_predicate::get_query_non_incr::__rust_end_short_backtrace
             7: <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<(), rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>
             8: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
             9: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
            10: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
            11: rustc_borrowck::type_check::type_check
            12: rustc_borrowck::nll::compute_regions
            13: rustc_borrowck::do_mir_borrowck
            14: rustc_borrowck::mir_borrowck
            15: 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]>>
            16: 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, false>
            17: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
            18: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
            19: rustc_hir_analysis::collect::type_of::type_of_opaque
            20: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            22: rustc_query_impl::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
            23: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            24: rustc_hir_analysis::collect::type_of::type_of
            25: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            27: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
            28: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            29: rustc_hir_analysis::check::check::check_item_type
            30: rustc_hir_analysis::check::wfcheck::check_well_formed
            31: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            32: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            33: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
            34: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            35: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            36: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            37: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
            38: rustc_hir_analysis::check_crate
            39: rustc_interface::passes::analysis
            40: 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]>>
            41: 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, false>
            42: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            43: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
            44: 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>>
            45: <<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}
            46: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/alloc/src/boxed.rs:2018:9
            47: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/alloc/src/boxed.rs:2018:9
            48: std::sys::pal::unix::thread::Thread::new::thread_start
                       at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/sys/pal/unix/thread.rs:108:17
            49: <unknown>
            50: <unknown>


error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(0:3 ~ 116877[6766]::rpit), []), ()], def_id: DefId(2:3360 ~ core[e11b]::ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(0:10 ~ 116877[6766]::foo::{opaque#0}) }))), bound_vars: [] } } }
 --> 116877.rs:8:5
  |
8 |     same_output(foo, rpit);
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
note: delayed at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs:165:29
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<(), rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>
         4: <rustc_borrowck::type_check::TypeChecker>::normalize_and_prove_instantiated_predicates
         5: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_constant
         6: <rustc_borrowck::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body
         7: rustc_borrowck::type_check::type_check
         8: rustc_borrowck::nll::compute_regions
         9: rustc_borrowck::do_mir_borrowck
        10: rustc_borrowck::mir_borrowck
        11: 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]>>
        12: 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, false>
        13: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
        14: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        15: rustc_hir_analysis::collect::type_of::type_of_opaque
        16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        18: rustc_query_impl::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
        19: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
        20: rustc_hir_analysis::collect::type_of::type_of
        21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        23: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
        24: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
        25: rustc_hir_analysis::check::check::check_item_type
        26: rustc_hir_analysis::check::wfcheck::check_well_formed
        27: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        28: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        29: rustc_query_impl::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
        30: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
        31: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        32: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        33: rustc_query_impl::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
        34: rustc_hir_analysis::check_crate
        35: rustc_interface::passes::analysis
        36: 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]>>
        37: 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, false>
        38: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        39: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
        40: 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>>
        41: <<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}
        42: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/alloc/src/boxed.rs:2018:9
        43: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/alloc/src/boxed.rs:2018:9
        44: std::sys::pal::unix::thread::Thread::new::thread_start
                   at /rustc/c9f8f3438a8134a413aa5d4903e0196e44e37bbc/library/std/src/sys/pal/unix/thread.rs:108:17
        45: <unknown>
        46: <unknown>
 --> 116877.rs:8:5
  |
8 |     same_output(foo, rpit);
  |     ^^^^^^^^^^^^^^^^^^^^^^

note: it seems that this compiler `1.79.0-nightly (c9f8f3438 2024-03-27)` is outdated, a newer nightly should have been released in the mean time
  |
  = note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
  = note: if the problem still persists, 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: please attach the file at `/tmp/rustc-ice-2024-03-29T23_05_34-262372.txt` to your bug report

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

4 participants