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: unexpected bound var resolution for HirId(...): None #123664

Closed
cushionbadak opened this issue Apr 9, 2024 · 1 comment · Fixed by #120639
Closed

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

cushionbadak opened this issue Apr 9, 2024 · 1 comment · Fixed by #120639
Labels
C-bug Category: This is a bug. F-effects `#![feature(effects)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

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

@cushionbadak cushionbadak 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 Apr 9, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 9, 2024
@fmease fmease added F-generic_const_exprs `#![feature(generic_const_exprs)]` F-effects `#![feature(effects)]` requires-incomplete-features and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 9, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 22, 2024
@cushionbadak
Copy link
Author

Add crate-feature in source and run cargo rustc-bisect.

#![feature(effects)]
#![feature(generic_const_exprs)]

const fn with_positive<F: ~const Fn()>() {}
bisected with cargo-bisect-rustc v0.6.8

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

cargo bisect-rustc --start 2023-01-01 --end 2024-04-12 --preserve --regress ice
checking the start range to find a passing nightly
installing nightly-2023-01-01
testing...
RESULT: nightly-2023-01-01, ===> No

checking the end range to verify it does not pass
installing nightly-2024-04-12
testing...
RESULT: nightly-2024-04-12, ===> Yes

234 versions remaining to test after this (roughly 8 steps)
installing nightly-2023-08-22
testing...
RESULT: nightly-2023-08-22, ===> Yes

117 versions remaining to test after this (roughly 7 steps)
installing nightly-2023-04-27
testing...
RESULT: nightly-2023-04-27, ===> No

59 versions remaining to test after this (roughly 6 steps)
installing nightly-2023-06-24
testing...
RESULT: nightly-2023-06-24, ===> No

30 versions remaining to test after this (roughly 5 steps)
installing nightly-2023-07-23
testing...
RESULT: nightly-2023-07-23, ===> No

15 versions remaining to test after this (roughly 4 steps)
installing nightly-2023-08-07
testing...
RESULT: nightly-2023-08-07, ===> No

8 versions remaining to test after this (roughly 4 steps)
installing nightly-2023-08-14
rust-std-nightly-x86_64-unknown-linux-gnu: 26.20 MB / 26.20 MB [=======] 100.00 % 7.79 MB/s testing...
RESULT: nightly-2023-08-14, ===> Yes

4 versions remaining to test after this (roughly 3 steps)
installing nightly-2023-08-10
rust-std-nightly-x86_64-unknown-linux-gnu: 26.17 MB / 26.17 MB [=======] 100.00 % 8.65 MB/s testing...
RESULT: nightly-2023-08-10, ===> Yes

2 versions remaining to test after this (roughly 2 steps)
installing nightly-2023-08-08
rust-std-nightly-x86_64-unknown-linux-gnu: 26.63 MB / 26.63 MB [=======] 100.00 % 8.33 MB/s testing...
RESULT: nightly-2023-08-08, ===> No

1 versions remaining to test after this (roughly 1 steps)
installing nightly-2023-08-09
rust-std-nightly-x86_64-unknown-linux-gnu: 26.66 MB / 26.66 MB [=======] 100.00 % 8.22 MB/s testing...
RESULT: nightly-2023-08-09, ===> Yes

searched toolchains nightly-2023-01-01 through nightly-2024-04-12


********************************************************************************
Regression in nightly-2023-08-09
********************************************************************************

fetching https://static.rust-lang.org/dist/2023-08-08/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2023-08-08: 40 B / 40 B [===========================] 100.00 % 703.14 KB/s converted 2023-08-08 to 03a119b0b0e310d22d94399b24ed030056050f13
fetching https://static.rust-lang.org/dist/2023-08-09/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2023-08-09: 40 B / 40 B [===========================] 100.00 % 743.79 KB/s converted 2023-08-09 to f88a8b71cebb730cbd5058c45ebcae1d4d9be377
looking for regression commit between 2023-08-08 and 2023-08-09
fetching (via remote github) commits from max(03a119b0b0e310d22d94399b24ed030056050f13, 2023-08-06) to f88a8b71cebb730cbd5058c45ebcae1d4d9be377
ending github query because we found starting sha: 03a119b0b0e310d22d94399b24ed030056050f13
get_commits_between returning commits, len: 9
  commit[0] 2023-08-07: Auto merge of #114344 - Kobzol:opt-dist-llvm-profdata, r=nikic
  commit[1] 2023-08-07: Auto merge of #114048 - nikic:llvm-17, r=cuviper
  commit[2] 2023-08-08: Auto merge of #114604 - matthiaskrgr:rollup-o1jltfn, r=matthiaskrgr
  commit[3] 2023-08-08: Auto merge of #114578 - petrochenkov:noplugin, r=cjgillot
  commit[4] 2023-08-08: Auto merge of #114520 - RalfJung:unsized-valtrees, r=oli-obk
  commit[5] 2023-08-08: Auto merge of #114339 - ttsugriy:unsafe-utf8, r=davidtwco
  commit[6] 2023-08-08: Auto merge of #114602 - compiler-errors:rpit-outlives-sadness, r=oli-obk
  commit[7] 2023-08-08: Auto merge of #114439 - Kobzol:remark-pgo-hotness, r=tmiasko
  commit[8] 2023-08-08: Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obk
ERROR: no CI builds available between 03a119b0b0e310d22d94399b24ed030056050f13 and f88a8b71cebb730cbd5058c45ebcae1d4d9be377 within last 167 days

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 28, 2024
…garing, r=oli-obk

Implement new effects desugaring

cc `@rust-lang/project-const-traits.` Will write down notes once I have finished.

* [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>`
* [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>`
* [ ] add types and traits to minicore test
* [ ] update rustc-dev-guide

Fixes rust-lang#119717
Fixes rust-lang#123664
Fixes rust-lang#124857
Fixes rust-lang#126148
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 29, 2024
…ring, r=oli-obk

Implement new effects desugaring

cc `@rust-lang/project-const-traits.` Will write down notes once I have finished.

* [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>`
* [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>`
* [ ] add types and traits to minicore test
* [ ] update rustc-dev-guide

Fixes rust-lang#119717
Fixes rust-lang#123664
Fixes rust-lang#124857
Fixes rust-lang#126148
@bors bors closed this as completed in ba1d7f4 Jun 29, 2024
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 11, 2024
…ring, r=oli-obk

Implement new effects desugaring

cc `@rust-lang/project-const-traits.` Will write down notes once I have finished.

* [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>`
* [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>`
* [ ] add types and traits to minicore test
* [ ] update rustc-dev-guide

Fixes rust-lang#119717
Fixes rust-lang#123664
Fixes rust-lang#124857
Fixes rust-lang#126148
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-effects `#![feature(effects)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-incomplete-features S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

4 participants