Skip to content

Regression: Using T: Bound in method impl and where T: Bound in method declaration yields an error #20107

Closed
@japaric

Description

@japaric

STR

#![crate_type = "lib"]

trait Bound {}

trait Trait {
    fn a<T>(&self, T) where T: Bound;
    fn b<T>(&self, T) where T: Bound;
    fn c<T: Bound>(&self, T);
    fn d<T: Bound>(&self, T);
}

impl Trait for bool {
    fn a<T: Bound>(&self, _: T) {}  //~ This gets rejected but should be accepted
    fn b<T>(&self, _: T) where T: Bound {}
    fn c<T: Bound>(&self, _: T) {}
    fn d<T>(&self, _: T) where T: Bound {}
}

Output

where.rs:13:5: 13:35 error: in method `a`, type parameter 0 requires bound `Bound`, which is not required by the corresponding type parameter in the trait declaration [E0052]
where.rs:13     fn a<T: Bound>(&self, _: T) {}
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Version

Doesn't compile on:

rustc 0.13.0-nightly (cc19e3380 2014-12-20 20:00:36 +0000)

This used to compile in:

rustc 0.13.0-nightly (99d6956c3 2014-12-18 20:32:07 +0000)

These 4 formms are equivalent and should continue to be accepted. Some changes to the where clause parser landed yesterday (#20073), perhaps that caused the regression?

cc @nikomatsakis @jroesch

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