Skip to content

Can not impl trait from another crate for Vec<T> with T from this crate #24745

Closed
@SimonSapin

Description

@SimonSapin

Test case:

a.rs

pub trait Foo {}

b.rs

extern crate a;
struct Bar;
impl a::Foo for Vec<Bar> {}
fn main() {}

In rustc 1.1.0-nightly (90cc830 2015-04-22) (built 2015-04-23):

$ rustc --crate-type lib a.rs
$ rustc -L . a.rs
a.rs:3:1: 3:28 error: the impl does not reference any types defined in this crate; only traits defined in the current crate can be implemented for arbitrary types [E0117]
a.rs:3 impl b::Foo for Vec<Bar> {}
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Note the impl does not reference any types defined in this crate. This is not true, Bar is defined is this crate.

This indicates a bug either in the coherence rules (this program should be valid and the error not be shown) or in the error message, which is misleading.

CC @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler 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