Skip to content

Using enclosing function's type parameter in enum definition yields ICE instead of error #5997

Closed
@jld

Description

@jld
Contributor
fn f<T>() { enum E { V(T) } }
pub fn main() { f::<int>(); }

⇒ error: internal compiler error: fictitious type ty_param({idx: 0, def_id: {crate: 0, node: 1}}) in sizing_type_of()

fn f<T>() { struct S(T); }
pub fn main() { f::<int>(); }

⇒ error: attempt to use a type argument out of scope

Activity

metajack

metajack commented on Jun 20, 2013

@metajack
Contributor

This still happens on today's master.

Nominating for production ready.

nikomatsakis

nikomatsakis commented on Aug 22, 2013

@nikomatsakis
Contributor

To be clear: I think the expected behavior here is an error
because the T is not in scope for nested items. So the
code ought to be enum<T> { Foo(T) } (similar to how a nested
fn couldn't reference T)

graydon

graydon commented on Aug 22, 2013

@graydon
Contributor

just a bug, removing milestone/nomination.

huonw

huonw commented on Dec 19, 2013

@huonw
Member

Triage, we're still creating types that are apparently fictitious and crashing.

flaper87

flaper87 commented on Mar 12, 2014

@flaper87
Contributor

This no longer ICE, it now outputs an error: error: missing type param T in the substitution of T

Adding the type parameter to the enum succeeds. Flagging as needs test.

added a commit that references this issue on Apr 17, 2014
3b9ade0
added a commit that references this issue on Apr 18, 2014

auto merge of #13525 : Ryman/rust/issue_5997, r=alexcrichton

29a3970
added a commit that references this issue on Sep 10, 2020

Auto merge of rust-lang#5997 - giraffate:fix_fp_about_clone_in_same_i…

added a commit that references this issue on Oct 9, 2020

Auto merge of rust-lang#6115 - ebroto:changelog_1_48, r=flip1995

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-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

      Participants

      @flaper87@graydon@metajack@nikomatsakis@jld

      Issue actions

        Using enclosing function's type parameter in enum definition yields ICE instead of error · Issue #5997 · rust-lang/rust