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 caused by question mark in parantheses in place of type #104582

Closed
FireFragment opened this issue Nov 18, 2022 · 3 comments · Fixed by #105547
Closed

ICE caused by question mark in parantheses in place of type #104582

FireFragment opened this issue Nov 18, 2022 · 3 comments · Fixed by #105547
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

@FireFragment
Copy link

Code

fn main(){
    let my_var: String(String?);
}

Meta

At the time of writing this, the crash is present in both stable and nightly release channel

rustc --version --verbose:

Stable
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0
Nightly
rustc 1.67.0-nightly (83356b78c 2022-11-17)
binary: rustc
commit-hash: 83356b78c4ff3e7d84e977aa6143793545967301
commit-date: 2022-11-17
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4
Error & Backtrace

   Compiling test-project v0.1.0 (/media/firefragment/DATA/Users/*****/Programs/rust/compiler-crash)
error: invalid `?` in type
 --> src/main.rs:2:30
  |
2 |     let my_var: String(String?);
  |                              ^ `?` is only allowed on expressions, not types
  |
help: if you meant to express that the type might not contain a value, use the `Option` wrapper type
  |
2 |     let my_var: String(Option<String>);
  |                        +++++++      ~

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/main.rs:2:17
  |
2 |     let my_var: String(String?);
  |                 ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
  |
help: use angle brackets instead
  |
2 |     let my_var: String<String?>;
  |                       ~       ~

error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs:541:17: no type for node HirId { owner: DefId(0:3 ~ test_project[01a1]::main), local_id: 3 }: type String? (hir_id=HirId { owner: DefId(0:3 ~ test_project[01a1]::main), local_id: 3 }) in fcx 0x7f87421f0e80

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/compiler/rustc_errors/src/lib.rs:1462:9
stack backtrace:
   0:     0x7f8748396d40 - std::backtrace_rs::backtrace::libunwind::trace::h32eb3e08e874dd27
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8748396d40 - std::backtrace_rs::backtrace::trace_unsynchronized::haa3f451d27bc11a5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8748396d40 - std::sys_common::backtrace::_print_fmt::h5b94a01bb4289bb5
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f8748396d40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb070b7fa7e3175df
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f87483f1bfe - core::fmt::write::hd5207aebbb9a86e9
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f8748387935 - std::io::Write::write_fmt::h3bd699bbd129ab8a
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/io/mod.rs:1679:15
   6:     0x7f87483999f3 - std::sys_common::backtrace::_print::h7a21be552fdf58da
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f87483999f3 - std::sys_common::backtrace::print::ha85c41fe4dd80b13
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f87483999f3 - std::panicking::default_hook::{{closure}}::h04cca40023d0eeca
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:295:22
   9:     0x7f87483996df - std::panicking::default_hook::haa3ca8c310ed5402
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:314:9
  10:     0x7f874abc72e1 - rustc_driver[cfb34b1539811fe8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f874839a22d - std::panicking::rust_panic_with_hook::h7b190ce1a948faac
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:702:17
  12:     0x7f874bb4de51 - std[71cb4861428b0c25]::panicking::begin_panic::<rustc_errors[f77a66b68db622d5]::ExplicitBug>::{closure#0}
  13:     0x7f874bb4b966 - std[71cb4861428b0c25]::sys_common::backtrace::__rust_end_short_backtrace::<std[71cb4861428b0c25]::panicking::begin_panic<rustc_errors[f77a66b68db622d5]::ExplicitBug>::{closure#0}, !>
  14:     0x7f874bba5316 - std[71cb4861428b0c25]::panicking::begin_panic::<rustc_errors[f77a66b68db622d5]::ExplicitBug>
  15:     0x7f874bb485f6 - std[71cb4861428b0c25]::panic::panic_any::<rustc_errors[f77a66b68db622d5]::ExplicitBug>
  16:     0x7f874bb471dd - <rustc_errors[f77a66b68db622d5]::HandlerInner>::bug::<&alloc[188ed69dc0d14b4b]::string::String>
  17:     0x7f874bb46c10 - <rustc_errors[f77a66b68db622d5]::Handler>::bug::<&alloc[188ed69dc0d14b4b]::string::String>
  18:     0x7f874bc037ed - rustc_middle[a9ca1c3f9fd197cd]::ty::context::tls::with_context_opt::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::tls::with_opt<rustc_middle[a9ca1c3f9fd197cd]::util::bug::opt_span_bug_fmt<rustc_span[8f00505efff112e2]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7f874bc06c86 - rustc_middle[a9ca1c3f9fd197cd]::util::bug::opt_span_bug_fmt::<rustc_span[8f00505efff112e2]::span_encoding::Span>
  20:     0x7f87495a4a83 - rustc_middle[a9ca1c3f9fd197cd]::util::bug::bug_fmt
  21:     0x7f87495f0158 - <rustc_typeck[4a3b2f91c49b3c3e]::check::writeback::WritebackCx as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_ty
  22:     0x7f87495ef6c2 - <rustc_typeck[4a3b2f91c49b3c3e]::check::writeback::WritebackCx as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_ty
  23:     0x7f87495ef41e - <rustc_typeck[4a3b2f91c49b3c3e]::check::writeback::WritebackCx as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_local
  24:     0x7f87495e88d8 - <rustc_typeck[4a3b2f91c49b3c3e]::check::writeback::WritebackCx as rustc_hir[f29014e7b3f8eb6c]::intravisit::Visitor>::visit_expr
  25:     0x7f874a1f47ac - <rustc_typeck[4a3b2f91c49b3c3e]::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
  26:     0x7f874a1ed73d - <rustc_infer[ed26b14e1208c12f]::infer::InferCtxtBuilder>::enter::<&rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults, <rustc_typeck[4a3b2f91c49b3c3e]::check::inherited::InheritedBuilder>::enter<rustc_typeck[4a3b2f91c49b3c3e]::check::typeck_with_fallback<rustc_typeck[4a3b2f91c49b3c3e]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>::{closure#0}>
  27:     0x7f874a1eac29 - rustc_typeck[4a3b2f91c49b3c3e]::check::typeck
  28:     0x7f874a4968ad - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, rustc_span[8f00505efff112e2]::def_id::LocalDefId, &rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>
  29:     0x7f874a489664 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<rustc_span[8f00505efff112e2]::def_id::LocalDefId, &rustc_middle[a9ca1c3f9fd197cd]::ty::context::TypeckResults>>
  30:     0x7f874ab03cae - <rustc_query_impl[d6191eea714bd250]::Queries as rustc_middle[a9ca1c3f9fd197cd]::ty::query::QueryEngine>::typeck
  31:     0x7f874a944057 - rustc_data_structures[62ce3989ce8140ee]::sync::par_for_each_in::<&[rustc_span[8f00505efff112e2]::def_id::LocalDefId], <rustc_middle[a9ca1c3f9fd197cd]::hir::map::Map>::par_body_owners<rustc_typeck[4a3b2f91c49b3c3e]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  32:     0x7f874a943e13 - rustc_typeck[4a3b2f91c49b3c3e]::check::typeck_item_bodies
  33:     0x7f874a84e2e5 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (), ()>
  34:     0x7f874a84d2be - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(), ()>>
  35:     0x7f874a84ccc7 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::typeck_item_bodies, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  36:     0x7f8749f3aa9f - <rustc_session[c5946fac61f8bc34]::session::Session>::time::<(), rustc_typeck[4a3b2f91c49b3c3e]::check_crate::{closure#7}>
  37:     0x7f8749f3a65f - rustc_typeck[4a3b2f91c49b3c3e]::check_crate
  38:     0x7f8749f39c27 - rustc_interface[3182dd864eff9d7d]::passes::analysis
  39:     0x7f874a998382 - <rustc_query_system[860ed7b39cdfb46b]::dep_graph::graph::DepGraph<rustc_middle[a9ca1c3f9fd197cd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a9ca1c3f9fd197cd]::ty::context::TyCtxt, (), core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  40:     0x7f874a997a4a - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::try_execute_query::<rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt, rustc_query_system[860ed7b39cdfb46b]::query::caches::DefaultCache<(), core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>>
  41:     0x7f874a997517 - rustc_query_system[860ed7b39cdfb46b]::query::plumbing::get_query::<rustc_query_impl[d6191eea714bd250]::queries::analysis, rustc_query_impl[d6191eea714bd250]::plumbing::QueryCtxt>
  42:     0x7f8749a83897 - <rustc_interface[3182dd864eff9d7d]::passes::QueryContext>::enter::<rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  43:     0x7f8749a7728c - rustc_interface[3182dd864eff9d7d]::interface::create_compiler_and_run::<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>
  44:     0x7f8749a75ac1 - <scoped_tls[e395fa6e23b19669]::ScopedKey<rustc_span[8f00505efff112e2]::SessionGlobals>>::set::<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  45:     0x7f8749a757af - std[71cb4861428b0c25]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>
  46:     0x7f874aa2ad70 - <<std[71cb4861428b0c25]::thread::Builder>::spawn_unchecked_<rustc_interface[3182dd864eff9d7d]::util::run_in_thread_pool_with_globals<rustc_interface[3182dd864eff9d7d]::interface::run_compiler<core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>, rustc_driver[cfb34b1539811fe8]::run_compiler::{closure#1}>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#0}, core[8c92e53db3fc2eaa]::result::Result<(), rustc_errors[f77a66b68db622d5]::ErrorGuaranteed>>::{closure#1} as core[8c92e53db3fc2eaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  47:     0x7f87483a4003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49f797984e2121bf
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  48:     0x7f87483a4003 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa4f3d0ee6440e0b
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/alloc/src/boxed.rs:1940:9
  49:     0x7f87483a4003 - std::sys::unix::thread::Thread::new::thread_start::h62ca48b42d48a8fc
                               at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/thread.rs:108:17
  50:     0x7f874824d609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  51:     0x7f8748170133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  52:                0x0 - <unknown>

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 (897e37553 2022-11-02) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0214`.
error: could not compile `test-project` due to 2 previous errors

@FireFragment FireFragment 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 18, 2022
@jruderman
Copy link
Contributor

Regression in nightly-2022-01-17 (ec4bcaa...bd3cb52)

@bombless
Copy link
Contributor

it doesn't reproduce on nightly now
(still reproduce on stable and beta FYI

@jruderman
Copy link
Contributor

Fixed in nightly-2022-11-26, somewhere in rollup 65a6e22

bisected with cargo-bisect-rustc v0.6.4

searched nightlies: from nightly-2022-11-17 to nightly-2022-11-28
"regressed" nightly: nightly-2022-11-26
searched commit range: b3bc6bf...8681d4c
"regressed" commit: 65a6e22

Host triple: x86_64-apple-darwin
Reproduce with:

cargo bisect-rustc --start 2022-11-17 --script ./not_outputs.sh

not_outputs.sh:

rustc src/main.rs 2>&1 | grep "internal compiler error"

@cjgillot cjgillot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 2, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Dec 11, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2022
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#105411 (Introduce `with_forced_trimmed_paths`)
 - rust-lang#105532 (Document behaviour of `--remap-path-prefix` with several matches)
 - rust-lang#105537 (compiler: remove unnecessary imports and qualified paths)
 - rust-lang#105539 (rustdoc: Only hide lines starting with `#` in rust code blocks )
 - rust-lang#105546 (Add some regression tests for rust-lang#44454)
 - rust-lang#105547 (Add regression test for rust-lang#104582)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 49027db Dec 11, 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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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.

4 participants