Skip to content

ICE: unexpected bound var resolution for HirId(...): None #123664

Closed

Description

Note

  • Requires feature(effects) & feature(generic_const_exprs) 😅
  • ICE-loc: compiler/rustc_middle/src/ty/consts.rs impl<'tcx> Const<'tcx> fn try_from_lit_or_param
    arg => bug!("unexpected bound var resolution for {:?}: {arg:?}", expr.hir_id),

Code

#![feature(generic_const_exprs)]

const fn with_positive<F: ~const Fn()>() {}
Original Code

//@ known-bug: #103507

#![feature(type_alias_impl_trait)]
#![feature(const_trait_impl)]
#![feature(const_refs_to_cell)]
#![feature(generic_const_exprs, transmutability)]

use std::marker::Destruct;

trait T {
    type Item;
}

type Alias<'a> = impl T<Item = &'a ()>;

struct S;
impl<'a> T for &'a S {
    type Item = &'a (
//~^ WARN anonymous parameters are deprecated and will be removed in the next edition
//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
    );
}

const fn filter_positive<'a>() -> &'a Alias<'a> {
    &&S
}

const fn with_positive<F: ~const for<'a> Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
    fun(filter_positive());
}

const fn foo(_: &Alias<'_>) {}

const BAR: () = {
    with_positive(foo);
};

fn line_different() {}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (ab5bda1aa 2024-04-08)
binary: rustc
commit-hash: ab5bda1aa70f707014e2e691e43bc37a8819252a
commit-date: 2024-04-08
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3

Command

rustc -Zcrate-attr="feature(effects)"

Error output

error[E0658]: const trait impls are experimental
 --> r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976.rs:3:27
  |
3 | const fn with_positive<F: ~const Fn()>() {}
  |                           ^^^^^^
  |
  = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
  = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
  = note: this compiler was built on 2024-04-08; consider upgrading it if it is out of date

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976`
 --> r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976.rs:3:44
  |
3 | const fn with_positive<F: ~const Fn()>() {}
  |                                            ^ consider adding a `main` function to `r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976.rs`

error: `~const` can only be applied to `#[const_trait]` traits
 --> r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976.rs:3:34
  |
3 | const fn with_positive<F: ~const Fn()>() {}
  |                                  ^^^^


Backtrace


error: internal compiler error: compiler/rustc_middle/src/ty/consts.rs:293:28: unexpected bound var resolution for HirId(DefId(0:3 ~ r_339FA25DEA248E54DF34B3917EB626464222971D2E44676562E8953DE677E976[9210]::with_positive).8): None

thread 'rustc' panicked at compiler/rustc_middle/src/ty/consts.rs:293:28:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_middle::ty::consts::Const>::from_anon_const
   7: rustc_hir::intravisit::walk_poly_trait_ref::<rustc_hir_analysis::collect::predicates_of::const_evaluatable_predicates_of::ConstCollector>
   8: rustc_hir_analysis::collect::predicates_of::gather_explicit_predicates_of
   9: rustc_hir_analysis::collect::predicates_of::explicit_predicates_of
      [... omitted 2 frames ...]
  10: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
  11: rustc_hir_analysis::collect::predicates_defined_on
      [... omitted 2 frames ...]
  12: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
  13: rustc_hir_analysis::collect::predicates_of::predicates_of
      [... omitted 2 frames ...]
  14: rustc_hir_analysis::collect::lower_item
  15: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  16: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  17: rustc_middle::query::plumbing::query_ensure_error_guaranteed::<rustc_query_system::query::caches::VecCache<rustc_hir::hir_id::OwnerId, rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
  18: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 1 frame ...]
  19: rustc_hir_analysis::check_crate
  20: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  21: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  22: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please attach the file at `/Volumes/T7/workspace/placeholder_rustexec/0408/rustc-ice-2024-04-09T04_51_03-62717.txt` to your bug report

note: compiler flags: -Z crate-attr=feature(effects)

query stack during panic:
#0 [explicit_predicates_of] computing explicit predicates of `with_positive`
#1 [predicates_defined_on] computing predicates of `with_positive`
#2 [predicates_of] computing predicates of `with_positive`
#3 [check_well_formed] checking that `with_positive` is well-formed
#4 [check_mod_type_wf] checking that types are well-formed in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-effects`#![feature(effects)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions