Skip to content

ICE: should be a function item #94629

@matthiaskrgr

Description

@matthiaskrgr
Member

Code

impl A for B {
	fn a(){{{{({{{ExprKind::Use {});(]),}}
	fn b()  {c!(<> []))}

#[rustc_legacy_const_generics(2)]
pub unsafe fn c<>() -> () {}

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (10913c000 2022-03-03)
binary: rustc
commit-hash: 10913c00018c76103b2fd4260d8c02ec728fd244
commit-date: 2022-03-03
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

error: this file contains an unclosed delimiter
 --> icemaker_4964.rs:6:30
  |
1 | impl A for B {
  |              - unclosed delimiter
...
6 | pub unsafe fn c<>() -> () {}
  |                              ^

error: expected expression, found `,`
 --> icemaker_4964.rs:2:37
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |                                        ^ expected expression

error: mismatched closing delimiter: `)`
 --> icemaker_4964.rs:2:15
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |               -  ^                ^ mismatched closing delimiter
  |               |  |
  |               |  unclosed delimiter
  |               closing delimiter possibly meant for this

error: mismatched closing delimiter: `]`
 --> icemaker_4964.rs:2:34
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |                                     ^^ mismatched closing delimiter
  |                                     |
  |                                     unclosed delimiter

error: mismatched closing delimiter: `)`
 --> icemaker_4964.rs:2:11
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |              ^ unclosed delimiter     ^ mismatched closing delimiter

error: mismatched closing delimiter: `)`
 --> icemaker_4964.rs:3:10
  |
3 |     fn b()  {c!(<> []))}
  |             ^         ^ mismatched closing delimiter
  |             |
  |             unclosed delimiter

error[E0449]: unnecessary visibility qualifier
 --> icemaker_4964.rs:6:1
  |
6 | pub unsafe fn c<>() -> () {}
  | ^^^ `pub` not permitted here because it's implied

error: cannot find macro `c` in this scope
 --> icemaker_4964.rs:3:11
  |
3 |     fn b()  {c!(<> []))}
  |              ^

error[E0433]: failed to resolve: use of undeclared type `ExprKind`
 --> icemaker_4964.rs:2:16
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |                   ^^^^^^^^ use of undeclared type `ExprKind`

error[E0405]: cannot find trait `A` in this scope
 --> icemaker_4964.rs:1:6
  |
1 | impl A for B {
  |      ^ not found in this scope

error[E0412]: cannot find type `B` in this scope
 --> icemaker_4964.rs:1:12
  |
1 | impl A for B {
  |            ^ not found in this scope

error[E0658]: this is an internal attribute that will never be stable
 --> icemaker_4964.rs:5:1
  |
5 | #[rustc_legacy_const_generics(2)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

warning: unnecessary braces around block return value
 --> icemaker_4964.rs:2:9
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |            ^                             ^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
2 -     fn a(){{{{({{{ExprKind::Use {});(]),}}
2 +     fn a(){{{({{{ExprKind::Use {});(]),}
  |

warning: unnecessary braces around block return value
 --> icemaker_4964.rs:2:14
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |                 ^                  ^
  |
help: remove these braces
  |
2 -     fn a(){{{{({{{ExprKind::Use {});(]),}}
2 +     fn a(){{{{({{ExprKind::Use {});(]),}}
  |

warning: unnecessary braces around block return value
 --> icemaker_4964.rs:2:15
  |
2 |     fn a(){{{{({{{ExprKind::Use {});(]),}}
  |                  ^                ^
  |
help: remove these braces
  |
2 -     fn a(){{{{({{{ExprKind::Use {});(]),}}
2 +     fn a(){{{{({{ExprKind::Use {};(]),}}
  |

error: internal compiler error: compiler/rustc_passes/src/check_attr.rs:1394:13: should be a function item

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1236:9
Backtrace

error: internal compiler error: compiler/rustc_passes/src/check_attr.rs:1394:13: should be a function item

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1236:9
stack backtrace:
   0:     0x7fd41f29cc5c - std::backtrace_rs::backtrace::libunwind::trace::hf0766e62d7eade0a
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fd41f29cc5c - std::backtrace_rs::backtrace::trace_unsynchronized::hfeabd612f0ca832b
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fd41f29cc5c - std::sys_common::backtrace::_print_fmt::he9db73d5ee638646
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fd41f29cc5c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1589ebb97e621cc4
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fd41f2f7dac - core::fmt::write::ha37bcdb331738e85
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/core/src/fmt/mod.rs:1190:17
   5:     0x7fd41f28d781 - std::io::Write::write_fmt::h718204eaedb628ac
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/io/mod.rs:1657:15
   6:     0x7fd41f29fbc5 - std::sys_common::backtrace::_print::ha178300e1fe9607f
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fd41f29fbc5 - std::sys_common::backtrace::print::hc7007f5e7ae2c2cd
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fd41f29fbc5 - std::panicking::default_hook::{{closure}}::he22cced35b2db4f8
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/panicking.rs:295:22
   9:     0x7fd41f29f874 - std::panicking::default_hook::hc232514524fdf7f9
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/panicking.rs:314:9
  10:     0x7fd41fac5561 - rustc_driver[df60e0066a970eb8]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fd41f2a044f - std::panicking::rust_panic_with_hook::h8f622f46b9144300
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/panicking.rs:702:17
  12:     0x7fd420b6db71 - std[d2b06600a978a9da]::panicking::begin_panic::<rustc_errors[1a4bb3cbefced23b]::ExplicitBug>::{closure#0}
  13:     0x7fd420b6da66 - std[d2b06600a978a9da]::sys_common::backtrace::__rust_end_short_backtrace::<std[d2b06600a978a9da]::panicking::begin_panic<rustc_errors[1a4bb3cbefced23b]::ExplicitBug>::{closure#0}, !>
  14:     0x7fd420b745ff - std[d2b06600a978a9da]::panicking::begin_panic::<rustc_errors[1a4bb3cbefced23b]::ExplicitBug>
  15:     0x7fd420b81306 - std[d2b06600a978a9da]::panic::panic_any::<rustc_errors[1a4bb3cbefced23b]::ExplicitBug>
  16:     0x7fd420b82a53 - <rustc_errors[1a4bb3cbefced23b]::HandlerInner>::bug
  17:     0x7fd420b824d0 - <rustc_errors[1a4bb3cbefced23b]::Handler>::bug
  18:     0x7fd420ad3c56 - rustc_middle[d2c2c4d42ddfe9db]::ty::context::tls::with_opt::<rustc_middle[d2c2c4d42ddfe9db]::util::bug::opt_span_bug_fmt<rustc_span[c03518380bcf3f86]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7fd420ad6800 - rustc_middle[d2c2c4d42ddfe9db]::util::bug::opt_span_bug_fmt::<rustc_span[c03518380bcf3f86]::span_encoding::Span>
  20:     0x7fd420ad6776 - rustc_middle[d2c2c4d42ddfe9db]::util::bug::bug_fmt
  21:     0x7fd42109464e - <rustc_passes[6667974d22481422]::check_attr::CheckAttrVisitor>::check_attributes
  22:     0x7fd4210b9756 - <rustc_middle[d2c2c4d42ddfe9db]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir[ac8a1b90366884e9]::intravisit::DeepVisitor<rustc_passes[6667974d22481422]::check_attr::CheckAttrVisitor>>
  23:     0x7fd421cc98d1 - rustc_passes[6667974d22481422]::check_attr::check_mod_attrs
  24:     0x7fd421391c0f - rustc_query_system[12c6c57c6519fd3c]::query::plumbing::try_execute_query::<rustc_query_impl[9f92f053cfcb6197]::plumbing::QueryCtxt, rustc_query_system[12c6c57c6519fd3c]::query::caches::DefaultCache<rustc_span[c03518380bcf3f86]::def_id::LocalDefId, ()>>
  25:     0x7fd421e38393 - rustc_query_system[12c6c57c6519fd3c]::query::plumbing::get_query::<rustc_query_impl[9f92f053cfcb6197]::queries::check_mod_attrs, rustc_query_impl[9f92f053cfcb6197]::plumbing::QueryCtxt>
  26:     0x7fd42197af9d - <core[a9132578ce6008ac]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[3ed5997e01d12d63]::passes::analysis::{closure#0}::{closure#1}> as core[a9132578ce6008ac]::ops::function::FnOnce<()>>::call_once
  27:     0x7fd4219724de - <rustc_session[1ec8f008caf3efe6]::session::Session>::time::<(), rustc_interface[3ed5997e01d12d63]::passes::analysis::{closure#0}>
  28:     0x7fd4219553ce - rustc_interface[3ed5997e01d12d63]::passes::analysis
  29:     0x7fd421e0b77b - rustc_query_system[12c6c57c6519fd3c]::query::plumbing::try_execute_query::<rustc_query_impl[9f92f053cfcb6197]::plumbing::QueryCtxt, rustc_query_system[12c6c57c6519fd3c]::query::caches::DefaultCache<(), core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>>
  30:     0x7fd421e4a5fe - rustc_query_system[12c6c57c6519fd3c]::query::plumbing::get_query::<rustc_query_impl[9f92f053cfcb6197]::queries::analysis, rustc_query_impl[9f92f053cfcb6197]::plumbing::QueryCtxt>
  31:     0x7fd42193cca4 - <rustc_interface[3ed5997e01d12d63]::passes::QueryContext>::enter::<rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>
  32:     0x7fd42191a57a - <rustc_interface[3ed5997e01d12d63]::interface::Compiler>::enter::<rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}::{closure#2}, core[a9132578ce6008ac]::result::Result<core[a9132578ce6008ac]::option::Option<rustc_interface[3ed5997e01d12d63]::queries::Linker>, rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>
  33:     0x7fd42192d3ad - rustc_span[c03518380bcf3f86]::with_source_map::<core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>, rustc_interface[3ed5997e01d12d63]::interface::create_compiler_and_run<core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>, rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}>::{closure#1}>
  34:     0x7fd42191b490 - rustc_interface[3ed5997e01d12d63]::interface::create_compiler_and_run::<core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>, rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}>
  35:     0x7fd421919432 - <scoped_tls[651cb9229c2f64c4]::ScopedKey<rustc_span[c03518380bcf3f86]::SessionGlobals>>::set::<rustc_interface[3ed5997e01d12d63]::interface::run_compiler<core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>, rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}>::{closure#0}, core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>
  36:     0x7fd42191771d - std[d2b06600a978a9da]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3ed5997e01d12d63]::util::run_in_thread_pool_with_globals<rustc_interface[3ed5997e01d12d63]::interface::run_compiler<core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>, rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}>::{closure#0}, core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>::{closure#0}, core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>
  37:     0x7fd421917a09 - <<std[d2b06600a978a9da]::thread::Builder>::spawn_unchecked_<rustc_interface[3ed5997e01d12d63]::util::run_in_thread_pool_with_globals<rustc_interface[3ed5997e01d12d63]::interface::run_compiler<core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>, rustc_driver[df60e0066a970eb8]::run_compiler::{closure#1}>::{closure#0}, core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>::{closure#0}, core[a9132578ce6008ac]::result::Result<(), rustc_errors[1a4bb3cbefced23b]::ErrorGuaranteed>>::{closure#1} as core[a9132578ce6008ac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7fd41f2aa9d3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he4379d5c274940c6
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/alloc/src/boxed.rs:1854:9
  39:     0x7fd41f2aa9d3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2db866a59e058c86
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/alloc/src/boxed.rs:1854:9
  40:     0x7fd41f2aa9d3 - std::sys::unix::thread::Thread::new::thread_start::h2eda9002b1b74dd5
                               at /rustc/10913c00018c76103b2fd4260d8c02ec728fd244/library/std/src/sys/unix/thread.rs:108:17
  41:     0x7fd41f0835c2 - start_thread
  42:     0x7fd41f108584 - __clone
  43:                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.61.0-nightly (10913c000 2022-03-03) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 13 previous errors; 3 warnings emitted

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

Activity

added
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Mar 4, 2022
compiler-errors

compiler-errors commented on Mar 6, 2022

@compiler-errors
Member

minimized:

impl () {
    #[rustc_legacy_const_generics(0)]
    fn c() {}
}

I think it's just that this attr ICEs when attached to methods and not functions.

ChayimFriedman2

ChayimFriedman2 commented on Mar 7, 2022

@ChayimFriedman2
Contributor

@rustbot claim

added 2 commits that reference this issue on Mar 9, 2022
f2b9fc2
3ce01f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @matthiaskrgr@compiler-errors@ChayimFriedman2@rust-lang-glacier-bot

    Issue actions

      ICE: should be a function item · Issue #94629 · rust-lang/rust