Conflicting implementation with slices and trait objects
⚓ Rust 📅 2026-02-03 👤 surdeus 👁️ 8Hi. I'm trying to compile this code, but it unexpectedly fails (I tried to reduce it to the smallest example possible).
#![feature(ptr_metadata)]
use std::ptr::{Pointee, DynMetadata};
trait Bar {}
impl<T> Bar for [T] {}
// error[E0119]: conflicting implementations of trait `Bar` for type `[_]`
impl<T> Bar for T
where
T: Pointee<Metadata = DynMetadata<T>> + ?Sized,
{}
try on playground: Rust Playground
Rust version: 1.95.0-nightly (2026-02-02), playground.
So, is something I'm doing wrong or is it too complex for the compiler to understand that [T] never implements Pointee<Metadata = DynMetadata<T>>?
11 posts - 4 participants
🏷️ Rust_feed