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

thread 'rustc' panicked at 'no label after fn' #100875

Closed
psionic12 opened this issue Aug 22, 2022 · 6 comments · Fixed by #99249
Closed

thread 'rustc' panicked at 'no label after fn' #100875

psionic12 opened this issue Aug 22, 2022 · 6 comments · Fixed by #99249
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

@psionic12
Copy link

Code

use std::cell::UnsafeCell;

struct Foo<T> {}

impl<T> Foo<T> {
    thread_local! {
        static TL: UnsafeCell<Vec<T>> = UnsafeCell::new(Vec::new());
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: x86_64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5

Error output

/Users/x/.cargo/bin/cargo +stable build --color=always --message-format=json-diagnostic-rendered-ansi --package rust_hello_world --bin rust_hello_world
   Compiling rust_hello_world v0.1.0 (/Users/x/CLionProjects/rust_hello_world)
thread 'rustc' panicked at 'no label after fn', compiler/rustc_span/src/source_map.rs:972:18
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_display
   3: core::panicking::panic_str
   4: core::option::expect_failed
   5: <rustc_span::source_map::SourceMap>::generate_fn_name_span
   6: <rustc_resolve::Resolver>::into_struct_error
   7: <rustc_resolve::Resolver>::report_error
   8: <rustc_resolve::Resolver>::resolve_ident_in_lexical_scope
   9: <rustc_resolve::Resolver>::resolve_path_with_ribs
  10: <rustc_resolve::late::LateResolutionVisitor>::smart_resolve_path_fragment
  11: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_ty
  12: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_generic_arg
  13: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_path_segment
  14: rustc_ast::visit::walk_ty::<rustc_resolve::late::LateResolutionVisitor>
  15: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_ty
  16: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_generic_arg
  17: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_path_segment
  18: rustc_ast::visit::walk_ty::<rustc_resolve::late::LateResolutionVisitor>
  19: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_ty
  20: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_fn
  21: rustc_ast::visit::walk_item::<rustc_resolve::late::LateResolutionVisitor>
  22: <rustc_resolve::late::LateResolutionVisitor>::resolve_item
  23: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_item
  24: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_block
  25: <rustc_resolve::late::LateResolutionVisitor>::resolve_expr
  26: <rustc_resolve::late::LateResolutionVisitor>::resolve_impl_item
  27: <rustc_resolve::late::LateResolutionVisitor>::resolve_item
  28: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_item
  29: <rustc_resolve::Resolver>::late_resolve_crate
  30: <rustc_session::session::Session>::time::<(), <rustc_resolve::Resolver>::resolve_crate::{closure#0}>
  31: rustc_interface::passes::configure_and_expand
  32: <rustc_interface::queries::Queries>::expansion
  33: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  34: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  35: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
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.63.0 (4b91a6ea7 2022-08-08) running on x86_64-apple-darwin
note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: could not compile `rust_hello_world`
Process finished with exit code 101

Backtrace

<backtrace>

@psionic12 psionic12 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 Aug 22, 2022
@ChayimFriedman2
Copy link
Contributor

Simpler reproduction:

struct Foo<T> {}

impl<T> Foo<T> {
    thread_local! {
        static TL: T = {};
    }
}

@Noratrieb
Copy link
Member

I can't reproduce this on the latest nightly.

@TaKO8Ki TaKO8Ki self-assigned this Aug 22, 2022
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Aug 22, 2022

I think #98609 fixed this problem.

@estebank
Copy link
Contributor

These should be easy to fix. We need to change the expect with return None; in generate_local_type_param_snippet and generate_fn_name_span. We should also look at all the callers and replace them with alternatives, instead of synthesizing spans.

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Aug 22, 2022

@estebank I will work on this!

@cjgillot
Copy link
Contributor

#99249 should fix it.

@TaKO8Ki TaKO8Ki linked a pull request Aug 23, 2022 that will close this issue
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.

6 participants