Skip to content

Tuples should be fundamental #31682

@SimonSapin

Description

@SimonSapin

Test case:

use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs};
use std::{vec, io};

pub enum Host {
    Domain(String),
    Ipv4(Ipv4Addr),
    Ipv6(Ipv6Addr),
}

impl ToSocketAddrs for (Host, u16) {
    type Iter = vec::IntoIter<SocketAddr>;
    fn to_socket_addrs(&self) -> io::Result<Self::Iter> {
        unimplemented!()
    }
}

Output with rustc 1.8.0-nightly (fae5162 2016-02-13):

a.rs:10:1: 15:2 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:10 impl ToSocketAddrs for (Host, u16) {
a.rs:11     type Iter = vec::IntoIter<SocketAddr>;
a.rs:12     fn to_socket_addrs(&self) -> io::Result<Self::Iter> {
a.rs:13         unimplemented!()
a.rs:14     }
a.rs:15 }
a.rs:10:1: 15:2 help: run `rustc --explain E0117` to see a detailed explanation
error: aborting due to previous error

But the impl does define a type defined in this crate, Host.

Is this impl fundamentally problematic, or could coherence rules be extended for tuples?

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions