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 bounds on non-present generic type parameter #100684

Closed
ilyvion opened this issue Aug 17, 2022 · 0 comments · Fixed by #100688
Closed

ICE with bounds on non-present generic type parameter #100684

ilyvion opened this issue Aug 17, 2022 · 0 comments · Fixed by #100688
Labels
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.

Comments

@ilyvion
Copy link

ilyvion commented Aug 17, 2022

Code

trait HandlerFamily {
    type Target;
}
pub(self) struct HandlerWrapper<H: HandlerFamily>(H);
impl<H: HandlerFamily> HandlerWrapper<H> {
    pub fn set_handler(&self, handler: &H::Target)
    where
        T: Send + Sync + 'static,
    {
    }
}

playground

Meta

rustc --version --verbose:

rustc 1.63.0 (4b91a6ea7 2022-08-08)
rustc 1.64.0-beta.2 (fb2194acc 2022-08-14)
rustc 1.65.0-nightly (86c6ebee8 2022-08-16)

Error output

error[[E0412]](https://doc.rust-lang.org/nightly/error-index.html#E0412): cannot find type `T` in this scope
 --> src/lib.rs:8:9
  |
5 | impl<H: HandlerFamily> HandlerWrapper<H> {
  |      - similarly named type parameter `H` defined here
...
8 |         T: Send + Sync + 'static,
  |         ^ help: a type parameter with a similar name exists: `H`

thread 'rustc' panicked at 'expected only projection types from env, not [type error]', compiler/rustc_infer/src/infer/outlives/obligations.rs:369:22
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/86c6ebee8fa0a5ad1e18e375113b06bd2849b634/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/86c6ebee8fa0a5ad1e18e375113b06bd2849b634/library/core/src/panicking.rs:142:14
   2: <alloc::vec::Vec<rustc_middle::ty::sty::Binder<rustc_middle::ty::OutlivesPredicate<rustc_middle::ty::Ty, rustc_middle::ty::sty::Region>>>>::retain::<<rustc_infer::infer::outlives::obligations::TypeOutlives<&rustc_infer::infer::InferCtxt>>::projection_must_outlive::{closure#0}>
   3: <rustc_infer::infer::outlives::obligations::TypeOutlives<&rustc_infer::infer::InferCtxt>>::components_must_outlive
   4: <rustc_infer::infer::InferCtxt>::check_region_obligations_and_report_errors
   5: rustc_typeck::check::wfcheck::check_associated_item
   6: rustc_typeck::check::wfcheck::check_well_formed
   7: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
   8: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_well_formed
   9: rustc_data_structures::sync::par_for_each_in::<&[rustc_hir::hir::ImplItemId], <rustc_middle::hir::ModuleItems>::par_impl_items<rustc_typeck::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>
  10: rustc_typeck::check::wfcheck::check_mod_type_wf
  11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  12: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_type_wf, rustc_query_impl::plumbing::QueryCtxt>
  13: <rustc_middle::hir::map::Map>::for_each_module::<rustc_typeck::check_crate::{closure#5}::{closure#0}::{closure#0}>
  14: <rustc_session::session::Session>::track_errors::<rustc_typeck::check_crate::{closure#5}, ()>
  15: rustc_typeck::check_crate
  16: rustc_interface::passes::analysis
  17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  18: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  19: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  20: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  21: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  22: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  23: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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.65.0-nightly (86c6ebee8 2022-08-16) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [check_well_formed] checking that `<impl at src/lib.rs:5:1: 5:41>::set_handler` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack

@ilyvion ilyvion 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 17, 2022
@bors bors closed this as completed in c7a4942 Aug 18, 2022
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. 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.

1 participant