Skip to content

Type parameters on static methods don't work right #4096

Closed

Description

@brson

This test specifies the type parameters to from_inty but rustc says it didn't.

pub trait Nummy {
    static pure fn from_inty<T>() -> self;
}

impl float: Nummy {
    static pure fn from_inty<T>() -> float { 0.0 }
}

fn main() {
    let _1:float = Nummy::from_inty::<int>(1i);
}
/home/brian/dev/rust/src/test/run-pass/test.rs:10:19: 10:42 error: not enough type parameters provided for this item
/home/brian/dev/rust/src/test/run-pass/test.rs:10     let _1:float = Nummy::from_inty::<int>(1i);
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~
/home/brian/dev/rust/src/test/run-pass/test.rs:10:19: 10:47 error: this function takes 0 parameters but 1 parameter was supplied
/home/brian/dev/rust/src/test/run-pass/test.rs:10     let _1:float = Nummy::from_inty::<int>(1i);
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors

Activity

  1. msullivan commented on Jul 3, 2013

    @msullivan
    Contributor

    Static methods have an implicit type parameter for the self type. Calling it with
    Nummy::from_inty::<float, int>().

    This is, at least, my intended behavior when I implemented them. It isn't clear to me what else would be sensible. This mostly sounds like a documentation problem?

  2. catamorphism commented on Aug 12, 2013

    @catamorphism
    Contributor

    Fixed in #8477 -- close this when it lands.

  3. added a commit that references this issue on Aug 14, 2013
    0efbb25
  4. added a commit that references this issue on Aug 21, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions