Skip to content

Changing module order causes specialization to fail #50452

Closed
@tuxmark5

Description

@tuxmark5

The below example fails to compile with error "not all trait items implemented, missing: trait_1".
Swapping modules one and two causes the code to compile correctly.
The same issue happens when one and two are defined in external files.

Version: rustc 1.27.0-nightly (e82261d 2018-05-03)

#![feature(specialization)]

mod two {
    use one::{Foo, Trait};

    impl Trait for Foo<i32> {
        fn trait_2(&self) {}
    }
    
    impl Trait for Foo<i64> { // not all trait items implemented, missing: `trait_1`
        fn trait_2(&self) {}
    }
}

mod one {
    pub struct Foo<A> { data: A }
    
    pub trait Trait {
        fn trait_1(&self);
        fn trait_2(&self);
    }
    
    impl<A> Trait for Foo<A> {
        fn trait_1(&self) {}
        default fn trait_2(&self) {}
    }
}

fn main() {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-specializationArea: Trait impl specializationC-bugCategory: This is a bug.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions