Possibly spurious overlapping impl (even with specialization)

a6b8b13
Opened by Eira Fransham at 2024-04-19 14:22:49

The following code leads to an "overlapping impl" error despite the fact that the bool impl is clearly more specific (totally concrete).

#![feature(specialization)]

trait Encodable {
    fn encode() {}
}
trait Decodable {
    fn decode() {}
}

impl Encodable for bool {
    fn encode() {}
}

impl Decodable for bool {
    fn decode() {}
}

impl<D> Encodable for D where for<'a> &'a D: AsRef<[u8]> {
    default fn encode() {}
}

impl<T: for<'a> From<&'a [u8]>> Decodable for T {
    default fn decode() {}
}
  1. Now that I think about it, this is probably because bool and AsRef are defined in the same crate and therefore conceivably AsRef<[u8]> could be implemented for bool without it being considered a breaking change.

    Eira Fransham at 2017-07-07 09:06:06

  2. triage: no change

    Maayan Hanin at 2022-10-17 10:16:34