Skip to content

The new coherence rules disable very useful patterns #20974

Closed
@reem

Description

@reem

Specifically that input parameters cannot be used as proof of coherence, i.e. impl ExternTrait<LocalType> for ExternType, is no longer allowed.

I've hit this in Iron pretty hard, with this simplified example:

Crate 1: (rust-modifier)

trait Modifier<M> { .. }

Crate 2: (hyper)

pub enum Status { .. }

Crate 3: (iron)

struct Response { .. }

// None of these impls are legal anymore, which is a massive ergonomic
// regression, since it will require a series of wrapper types instead.

impl Modifier<Response> for Status { .. }
impl<'a> Modifier<Response> for &'a str { .. }
impl Modifier<Response> for String { .. }
impl Modifier<Response> for Vec<u8> { .. }
impl Modifier<Response> for Box<Reader + Send> { .. }

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