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: No HirID for DefId(...) with feature generic_assert #123629

Open
cushionbadak opened this issue Apr 8, 2024 · 4 comments
Open

ICE: No HirID for DefId(...) with feature generic_assert #123629

cushionbadak opened this issue Apr 8, 2024 · 4 comments
Labels
C-bug Category: This is a bug. F-generic_assert `#![feature(generic_assert)]` F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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

Code

(reduced)

fn foo()
where
    for<const N: usize = {
        || {
            assert!(u1 == u2);
        };
    }> ():,
{
}
Original Code

// test for ICE "no entry found for key" in generics_of.rs #113017

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

pub fn foo()
where
    for<const N: usize = { || {
    let u = U { b: 0 };
    let u1 = u;
    let u2 = u.clone();
    assert!(u1 == u2);

    let w = W { a: 0 };
    let w1 = w.clone();
    assert!(w == w1);
}; 1 }> ():,
    //~^ ERROR only lifetime parameters can be used in this context
    //~^^  ERROR defaults for generic parameters are not allowed in `for<...>` binders
{}

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (9d5cdf75a 2024-04-07)
binary: rustc
commit-hash: 9d5cdf75aa42faaf0b58ba21a510117e8d0051a3
commit-date: 2024-04-07
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3

Command

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

Error output

error[E0425]: cannot find value `u1` in this scope
 --> r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B.rs:5:21
  |
5 |             assert!(u1 == u2);
  |                     ^^ not found in this scope

error[E0425]: cannot find value `u2` in this scope
 --> r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B.rs:5:27
  |
5 |             assert!(u1 == u2);
  |                           ^^ not found in this scope

error[E0658]: only lifetime parameters can be used in this context
 --> r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B.rs:3:15
  |
3 |     for<const N: usize = {
  |               ^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
  = note: this compiler was built on 2024-04-07; consider upgrading it if it is out of date

error: defaults for generic parameters are not allowed in `for<...>` binders
 --> r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B.rs:3:9
  |
3 |       for<const N: usize = {
  |  _________^
4 | |         || {
5 | |             assert!(u1 == u2);
6 | |         };
7 | |     }> ():,
  | |_____^

error[E0601]: `main` function not found in crate `r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B`
 --> r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B.rs`
Backtrace


error: internal compiler error: /rustc/9d5cdf75aa42faaf0b58ba21a510117e8d0051a3/compiler/rustc_middle/src/hir/mod.rs:168:32: No HirId for DefId(0:6 ~ r_A95E66CAB86034DA3FA9192088ADD18A7364FEB318508290E83C5B9C99E7388B[c8dc]::foo::{constant#0}::{closure#0})

thread 'rustc' panicked at /rustc/9d5cdf75aa42faaf0b58ba21a510117e8d0051a3/compiler/rustc_middle/src/hir/mod.rs:168:32:
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::hir::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
      [... omitted 1 frame ...]
   7: 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]>>>
   8: <rustc_middle::hir::provide::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_hir::hir_id::OwnerId)>>::call_once
      [... omitted 1 frame ...]
   9: 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]>>>
  10: <rustc_middle::ty::context::TyCtxt>::parent_hir_id
  11: <rustc_middle::lint::ShallowLintLevelMap>::probe_for_lint_level
  12: <rustc_middle::lint::ShallowLintLevelMap>::lint_level_id_at_node
  13: <rustc_lint::levels::LintLevelsBuilder<rustc_lint::levels::LintLevelQueryMap>>::insert_spec
  14: <rustc_lint::levels::LintLevelsBuilder<rustc_lint::levels::LintLevelQueryMap>>::add
  15: rustc_lint::levels::shallow_lint_levels_on
      [... omitted 1 frame ...]
  16: 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]>>>
  17: rustc_hir_analysis::check_unused::check_unused_traits
      [... omitted 1 frame ...]
  18: rustc_hir_analysis::check_crate
  19: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  20: <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}>
  21: 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: it seems that this compiler `1.79.0-nightly (9d5cdf75a 2024-04-07)` 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 `/Volumes/T7/workspace/placeholder_rustexec/0408/rustc-ice-2024-04-08T12_46_17-87853.txt` to your bug report

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

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `foo::{constant#0}::{closure#0}`
#1 [hir_owner_parent] getting HIR parent of `foo::{constant#0}::{closure#0}::{use#1}`
#2 [shallow_lint_levels_on] looking up lint levels for `foo::{constant#0}::{closure#0}::{use#1}`
#3 [check_unused_traits] checking unused trait imports in crate
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors

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

@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 8, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 8, 2024
@jieyouxu jieyouxu added the requires-nightly This issue requires a nightly compiler in some way. label Apr 8, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Apr 8, 2024

Related: #120612

@fmease
Copy link
Member

fmease commented Apr 8, 2024

Very much relates to the fixed issues #118697 and #119489. CC my merged PR #119494 which I thought would fix every issue related to defaults on higher-ranked generic parameters. Oh, well ^^'.

@fmease fmease added F-non_lifetime_binders `#![feature(non_lifetime_binders)]` F-generic_assert `#![feature(generic_assert)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 8, 2024
@cushionbadak
Copy link
Author

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

#![feature(generic_assert)]

fn foo()
where
    for<const N: usize = {
        || {
            assert!(u1 == u2);
        };
    }> ():,
{
}
bisected with cargo-bisect-rustc v0.6.8

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

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

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

52 versions remaining to test after this (roughly 6 steps)
installing nightly-2024-02-22
testing...
RESULT: nightly-2024-02-22, ===> Yes

26 versions remaining to test after this (roughly 5 steps)
installing nightly-2024-01-27
testing...
RESULT: nightly-2024-01-27, ===> Yes

13 versions remaining to test after this (roughly 4 steps)
installing nightly-2024-01-14
testing...
RESULT: nightly-2024-01-14, ===> Yes

7 versions remaining to test after this (roughly 3 steps)
installing nightly-2024-01-07
testing...
RESULT: nightly-2024-01-07, ===> Yes

3 versions remaining to test after this (roughly 2 steps)
installing nightly-2024-01-04
testing...
RESULT: nightly-2024-01-04, ===> Yes

2 versions remaining to test after this (roughly 2 steps)
installing nightly-2024-01-02
2 versions remaining to test after this (roughly 2 steps)
installing nightly-2024-01-03
searched toolchains nightly-2024-01-01 through nightly-2024-04-14


********************************************************************************
Regression in nightly-2024-01-04
********************************************************************************

fetching https://static.rust-lang.org/dist/2024-01-03/channel-rust-nightly-git-commit-hash.txt
ERROR: Tarball not found at https://static.rust-lang.org/dist/2024-01-03/channel-rust-nightly-git-commit-hash.txt

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 8, 2024
Rollup merge of rust-lang#129869 - cyrgani:master, r=Mark-Simulacrum

add a few more crashtests

Added them for rust-lang#123629, rust-lang#127033 and rust-lang#129372.
@cyrgani
Copy link
Contributor

cyrgani commented Sep 8, 2024

@rustbot label +S-bug-has-test

@rustbot rustbot added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Sep 8, 2024
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-generic_assert `#![feature(generic_assert)]` F-non_lifetime_binders `#![feature(non_lifetime_binders)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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

No branches or pull requests

5 participants