struct Bar(i32);
mod a {
pub fn same_name() {} /// isolated
use ::std::io::*;
impl Read for super::Bar { //clash
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
Ok(0)
}
}
}
mod b {
pub fn same_name() {} /// isolated
use ::std::io::*;
impl Read for super::Bar { //clash
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
Ok(0)
}
}
}
fn main() {
}
пример рафинированный.
два модуля a и b
с одинаковым содержимым.
функции с одинаковыми именами s в модулях изолируются и все с ними хорошо
а имплементация trait Read НЕ изолируется ??? ошибка вида
> error[E0119]: conflicting implementations of trait std::io::Read for type Bar:
> --> src\main.rs:20:5
> |
> 8 | impl Read for super::Bar {
> | ------------------------ first implementation here
> ...
> 20 | impl Read for super::Bar {
> | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for Bar
>
> error: aborting due to previous error
>
> For more information about this error, try rustc --explain E0119.
> error[E0119]: conflicting implementations of trait std::io::Read for type Bar:
> --> src\main.rs:20:5
> |
> 8 | impl Read for super::Bar {
> | ------------------------ first implementation here
> ...
> 20 | impl Read for super::Bar {
> | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for Bar
всю голову сломал. выручайте.
запилил в багрепорт. будем посмотреть…