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 "only ConstKind::Param should be encountered here" #104209

Closed
jruderman opened this issue Nov 9, 2022 · 6 comments · Fixed by #104233
Closed

ICE "only ConstKind::Param should be encountered here" #104209

jruderman opened this issue Nov 9, 2022 · 6 comments · Fixed by #104233
Assignees
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

@jruderman
Copy link
Contributor

Found with a modified fuzz-rustc

Code

fn f() -> impl {
    2E
}
fn main() {}

Error output

error: expected at least one digit in exponent
error: at least one trait must be specified
error: internal compiler error: compiler/rustc_mir_transform/src/required_consts.rs:21:22: only ConstKind::Param should be encountered here, got Const { ty: f64, kind: Error(ErrorGuaranteed(())) }
Full output including backtrace

error: expected at least one digit in exponent
 --> a.rs:2:5
  |
2 |     2E
  |     ^^

error: at least one trait must be specified
 --> a.rs:1:11
  |
1 | fn f() -> impl {
  |           ^^^^

error: internal compiler error: compiler/rustc_mir_transform/src/required_consts.rs:21:22: only ConstKind::Param should be encountered here, got Const { ty: f64, kind: Error(ErrorGuaranteed(())) }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/7eef946fc0e0eff40e588eab77b09b287accbec3/compiler/rustc_errors/src/lib.rs:1551:9
stack backtrace:
   0:        0x10db287a2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hde9930b8710af522
   1:        0x10db805ea - core::fmt::write::hd25ec0bfc1849a2f
   2:        0x10db1a87c - std::io::Write::write_fmt::hca36d7396c5dc18b
   3:        0x10db2856a - std::sys_common::backtrace::print::hc155979e9e33e658
   4:        0x10db2b946 - std::panicking::default_hook::{{closure}}::h03db778ae686f347
   5:        0x10db2b697 - std::panicking::default_hook::h0d9e8bcb55be071f
   6:        0x11ccc17dd - rustc_driver[77a613ab63d15aac]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10db2c145 - std::panicking::rust_panic_with_hook::h758520931cfdfde5
   8:        0x121447b87 - std[11391ffec397fd56]::panicking::begin_panic::<rustc_errors[ec87cacb996b1da1]::ExplicitBug>::{closure#0}
   9:        0x1214472f9 - std[11391ffec397fd56]::sys_common::backtrace::__rust_end_short_backtrace::<std[11391ffec397fd56]::panicking::begin_panic<rustc_errors[ec87cacb996b1da1]::ExplicitBug>::{closure#0}, !>
  10:        0x121aefdf9 - std[11391ffec397fd56]::panicking::begin_panic::<rustc_errors[ec87cacb996b1da1]::ExplicitBug>
  11:        0x12143fee9 - std[11391ffec397fd56]::panic::panic_any::<rustc_errors[ec87cacb996b1da1]::ExplicitBug>
  12:        0x12143fc4d - <rustc_errors[ec87cacb996b1da1]::HandlerInner>::bug::<&alloc[a05f3e7fdaf4d80f]::string::String>
  13:        0x12143f717 - <rustc_errors[ec87cacb996b1da1]::Handler>::bug::<&alloc[a05f3e7fdaf4d80f]::string::String>
  14:        0x12159b3d2 - rustc_middle[b315a0ebd84f913d]::ty::context::tls::with_context_opt::<rustc_middle[b315a0ebd84f913d]::ty::context::tls::with_opt<rustc_middle[b315a0ebd84f913d]::util::bug::opt_span_bug_fmt<rustc_span[48482e0f8f724117]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  15:        0x12159c331 - rustc_middle[b315a0ebd84f913d]::util::bug::opt_span_bug_fmt::<rustc_span[48482e0f8f724117]::span_encoding::Span>
  16:        0x121af17ae - rustc_middle[b315a0ebd84f913d]::util::bug::bug_fmt
  17:        0x11fa9438a - <rustc_mir_transform[908f959bb72ad5af]::required_consts::RequiredConstsVisitor as rustc_middle[b315a0ebd84f913d]::mir::visit::Visitor>::visit_operand
  18:        0x11fa946eb - <rustc_mir_transform[908f959bb72ad5af]::required_consts::RequiredConstsVisitor as rustc_middle[b315a0ebd84f913d]::mir::visit::Visitor>::visit_basic_block_data
  19:        0x11f9ffb29 - rustc_mir_transform[908f959bb72ad5af]::mir_promoted
  20:        0x1205020e0 - rustc_query_system[69ea88315c8057f7]::query::plumbing::try_execute_query::<rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt, rustc_query_system[69ea88315c8057f7]::query::caches::DefaultCache<rustc_middle[b315a0ebd84f913d]::ty::WithOptConstParam<rustc_span[48482e0f8f724117]::def_id::LocalDefId>, (&rustc_data_structures[d9a04b93d3448b55]::steal::Steal<rustc_middle[b315a0ebd84f913d]::mir::Body>, &rustc_data_structures[d9a04b93d3448b55]::steal::Steal<rustc_index[975aea96e92c3aa6]::vec::IndexVec<rustc_middle[b315a0ebd84f913d]::mir::Promoted, rustc_middle[b315a0ebd84f913d]::mir::Body>>)>>
  21:        0x1206188c8 - rustc_query_system[69ea88315c8057f7]::query::plumbing::get_query::<rustc_query_impl[44c1f9c305efea75]::queries::mir_promoted, rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt>
  22:        0x1206d2e87 - <rustc_query_impl[44c1f9c305efea75]::Queries as rustc_middle[b315a0ebd84f913d]::ty::query::QueryEngine>::mir_promoted
  23:        0x1200a9996 - rustc_borrowck[92a4f20c78c2d7a9]::mir_borrowck
  24:        0x12008a685 - <rustc_borrowck[92a4f20c78c2d7a9]::provide::{closure#0} as core[cfd2f0869b685cd6]::ops::function::FnOnce<(rustc_middle[b315a0ebd84f913d]::ty::context::TyCtxt, rustc_span[48482e0f8f724117]::def_id::LocalDefId)>>::call_once
  25:        0x1205307c9 - rustc_query_system[69ea88315c8057f7]::query::plumbing::try_execute_query::<rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt, rustc_query_system[69ea88315c8057f7]::query::caches::DefaultCache<rustc_span[48482e0f8f724117]::def_id::LocalDefId, &rustc_middle[b315a0ebd84f913d]::mir::query::BorrowCheckResult>>
  26:        0x120618633 - rustc_query_system[69ea88315c8057f7]::query::plumbing::get_query::<rustc_query_impl[44c1f9c305efea75]::queries::mir_borrowck, rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt>
  27:        0x11f7e1f6a - rustc_hir_analysis[ad14f4770cb1b48d]::collect::type_of::find_opaque_ty_constraints_for_rpit
  28:        0x11f7e105d - rustc_hir_analysis[ad14f4770cb1b48d]::collect::type_of::type_of
  29:        0x1205549a5 - rustc_query_system[69ea88315c8057f7]::query::plumbing::try_execute_query::<rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt, rustc_query_system[69ea88315c8057f7]::query::caches::DefaultCache<rustc_span[48482e0f8f724117]::def_id::DefId, rustc_middle[b315a0ebd84f913d]::ty::Ty>>
  30:        0x12062be04 - rustc_query_system[69ea88315c8057f7]::query::plumbing::get_query::<rustc_query_impl[44c1f9c305efea75]::queries::type_of, rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt>
  31:        0x11f7903aa - rustc_hir_analysis[ad14f4770cb1b48d]::check::check::check_item_type
  32:        0x11f79ab0e - rustc_hir_analysis[ad14f4770cb1b48d]::check::check::check_mod_item_types
  33:        0x120533e45 - rustc_query_system[69ea88315c8057f7]::query::plumbing::try_execute_query::<rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt, rustc_query_system[69ea88315c8057f7]::query::caches::DefaultCache<rustc_span[48482e0f8f724117]::def_id::LocalDefId, ()>>
  34:        0x120621d05 - rustc_query_system[69ea88315c8057f7]::query::plumbing::get_query::<rustc_query_impl[44c1f9c305efea75]::queries::check_mod_item_types, rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt>
  35:        0x11f7bf828 - <rustc_middle[b315a0ebd84f913d]::hir::map::Map>::for_each_module::<rustc_hir_analysis[ad14f4770cb1b48d]::check_crate::{closure#6}::{closure#0}>
  36:        0x11f7aee79 - <rustc_session[ae5bb785c2cd4c22]::session::Session>::time::<(), rustc_hir_analysis[ad14f4770cb1b48d]::check_crate::{closure#6}>
  37:        0x11f75ac8f - rustc_hir_analysis[ad14f4770cb1b48d]::check_crate
  38:        0x11ce0884a - rustc_interface[a0d981abc9377f30]::passes::analysis
  39:        0x1205b1b5c - rustc_query_system[69ea88315c8057f7]::query::plumbing::try_execute_query::<rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt, rustc_query_system[69ea88315c8057f7]::query::caches::DefaultCache<(), core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>>
  40:        0x12062bf19 - rustc_query_system[69ea88315c8057f7]::query::plumbing::get_query::<rustc_query_impl[44c1f9c305efea75]::queries::analysis, rustc_query_impl[44c1f9c305efea75]::plumbing::QueryCtxt>
  41:        0x11ccdd7e6 - <rustc_interface[a0d981abc9377f30]::passes::QueryContext>::enter::<rustc_driver[77a613ab63d15aac]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>
  42:        0x11cd21f5d - rustc_span[48482e0f8f724117]::with_source_map::<core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>, rustc_interface[a0d981abc9377f30]::interface::run_compiler<core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>, rustc_driver[77a613ab63d15aac]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  43:        0x11cd11a7c - <scoped_tls[46b3c18c0a12f0bc]::ScopedKey<rustc_span[48482e0f8f724117]::SessionGlobals>>::set::<rustc_interface[a0d981abc9377f30]::interface::run_compiler<core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>, rustc_driver[77a613ab63d15aac]::run_compiler::{closure#1}>::{closure#0}, core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>
  44:        0x11cce13ca - std[11391ffec397fd56]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a0d981abc9377f30]::util::run_in_thread_pool_with_globals<rustc_interface[a0d981abc9377f30]::interface::run_compiler<core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>, rustc_driver[77a613ab63d15aac]::run_compiler::{closure#1}>::{closure#0}, core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>
  45:        0x11ccc74cb - <<std[11391ffec397fd56]::thread::Builder>::spawn_unchecked_<rustc_interface[a0d981abc9377f30]::util::run_in_thread_pool_with_globals<rustc_interface[a0d981abc9377f30]::interface::run_compiler<core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>, rustc_driver[77a613ab63d15aac]::run_compiler::{closure#1}>::{closure#0}, core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cfd2f0869b685cd6]::result::Result<(), rustc_errors[ec87cacb996b1da1]::ErrorGuaranteed>>::{closure#1} as core[cfd2f0869b685cd6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:        0x10db351f7 - std::sys::unix::thread::Thread::new::thread_start::ha121f0b94f5d418a
  47:     0x7ff814d514e1 - __pthread_start

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.67.0-nightly (7eef946fc 2022-11-06) running on x86_64-apple-darwin

query stack during panic:
#0 [mir_promoted] processing MIR for `f`
#1 [mir_borrowck] borrow-checking `f`
#2 [type_of] computing type of `f::{opaque#0}`
#3 [check_mod_item_types] checking item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Regression

Regression in nightly-2022-09-18 from #98588 (@b-naber, @lcnr)

Bisect info

searched nightlies: from nightly-2022-09-04 to nightly-2022-11-07
regressed nightly: nightly-2022-09-18
searched commit range: 95a992a...98ad6a5
regressed commit: c524c7d

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-apple-darwin

Version

rustc 1.67.0-nightly (7eef946fc 2022-11-06)
binary: rustc
commit-hash: 7eef946fc0e0eff40e588eab77b09b287accbec3
commit-date: 2022-11-06
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
@jruderman jruderman 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 Nov 9, 2022
@compiler-errors
Copy link
Member

For the record, this isn't dependent on -> impl return type, which is a separate error. This also ICEs:

fn f() -> impl Sized {
    2E
}

fn main() {}

@chenyukang
Copy link
Member

This don't ICE:

trait Demo {}

fn f() -> impl Demo {
    2E
}

fn main() {}

I guess it's because terminated because the error type error.

@compiler-errors
Copy link
Member

Yeah, f64 still needs to implement the trait in the impl Trait -- this ICEs, for example:

trait Demo {}

impl Demo for f64 {}

fn f() -> impl Demo {
    2E
}

fn main() {}

@b-naber
Copy link
Contributor

b-naber commented Nov 10, 2022

I can take a look at this, unless you're already working on this @compiler-errors.

@Rageking8
Copy link
Contributor

Rageking8 commented Nov 10, 2022

@b-naber I think compiler-errors already submitted a PR to fix this, #104233

  • PR linked above, but he did not claim this issue.

@b-naber
Copy link
Contributor

b-naber commented Nov 10, 2022

Oh thanks, didn't see this.

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.

5 participants