Skip to content

ICE (1.0.0-beta): "no type for node ... in fcx" with function-local static Fn #24446

Closed
@whipsch

Description

@whipsch

Abbreviated backtrace:

error: internal compiler error: no type for node 14: expr 0 (id=14) in fcx 0x43ed4e0
thread 'rustc' panicked at 'Box<Any>', C:/bot/slave/beta-dist-rustc-win-64/build/src/libsyntax\diagnostic.rs:190

stack backtrace:
   7:          0x1684ea2 - check::FnCtxt<'a, 'tcx>.ty..ClosureTyper<'tcx>::closure_upvars::hd9de0cb59cfad129xJn
   8:          0x16bb064 - check::regionck::Rcx<'a, 'tcx>.Visitor<'v>::visit_local::hf1f7eef7520e38941Ed
   9:          0x16bc301 - check::FnCtxt<'a, 'tcx>.mc..Typer<'tcx>::node_ty::h4717180cfe88525eQEn
  10:          0x1714e16 - check::FnCtxt<'a, 'tcx>.mc..Typer<'tcx>::is_method_call::ha5a9873524740db0vHn
  11:          0x171233f - check::FnCtxt<'a, 'tcx>.mc..Typer<'tcx>::is_method_call::ha5a9873524740db0vHn
  12:          0x170c90e - check::upvar::AdjustBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::h83a9049482b77a0e5Lk
  13:          0x170b644 - check::upvar::SeedBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::h96b2ebc2922ab678Yjk
  14:          0x170ada6 - check::upvar::SeedBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::h96b2ebc2922ab678Yjk
  15:          0x17487b1 - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_ty::hf5a010d1c8a756d3RNn
  16:          0x17426d2 - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::hcf32b798d03f5730vNn

Reproduce: (playpen)

fn main() {
    static foo: Fn() -> u32 = || -> u32 {
        0
    };
}

The error message provided when doing the above with a let binding instead may be useful:

kaboom.rs:2:28: 4:6 error: mismatched types:
(expected trait core::ops::Fn, found closure) [E0308]

kaboom.rs:2:9: 2:12 error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn() -> u32` [E0277]
kaboom.rs:2:9: 2:12 note: `core::ops::Fn() -> u32` does not have a constant size known at compile-time
kaboom.rs:2     let foo: Fn() -> u32 = || -> u32 {
                    ^~~

Looks to be related to PR #20897, however the change there has a rather catch-all appearance to it, so there is likely more to this particular ICE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions