Open CohenArthur opened 5 months ago
the issue only arises upon adding this implementation:
impl<T: ?Sized> DerefMut for &mut T {
fn deref_mut(&mut self) -> &mut T {
*self
}
}
which is part of the core
library but isn't present in our existing testcases, as they focused on Deref
and its behavior
we're also running into this with this code example - I suspect the fix would be the same and there is something wrong when it comes to references/pointers and mutability:
#![feature(intrinsics)]
#[lang = "sized"]
trait Sized {}
pub struct VaListImpl<'f>;
mod sealed_trait {
pub trait VaArgSafe {}
}
impl<T> sealed_trait::VaArgSafe for *mut T {}
impl<T> sealed_trait::VaArgSafe for *const T {}
impl<'f> VaListImpl<'f> {
/// Advance to the next arg.
#[inline]
pub unsafe fn arg<T: sealed_trait::VaArgSafe>(&mut self) {
va_arg2(self);
}
}
fn va_arg2<T: sealed_trait::VaArgSafe>(ap: &mut VaListImpl<'_>) {}
I don't even understand how it makes sense for the last example - the type bound is unused, so it shouldn't affect anything
we're also running into this with this code example - I suspect the fix would be the same and there is something wrong when it comes to references/pointers and mutability:
#![feature(intrinsics)] #[lang = "sized"] trait Sized {} pub struct VaListImpl<'f>; mod sealed_trait { pub trait VaArgSafe {} } impl<T> sealed_trait::VaArgSafe for *mut T {} impl<T> sealed_trait::VaArgSafe for *const T {} impl<'f> VaListImpl<'f> { /// Advance to the next arg. #[inline] pub unsafe fn arg<T: sealed_trait::VaArgSafe>(&mut self) { va_arg2(self); } } fn va_arg2<T: sealed_trait::VaArgSafe>(ap: &mut VaListImpl<'_>) {}
This is a seperate issue i am going to open this into a seperate issue as the original issue is different and fix is up now
This code is the base implementation of
Deref
andDerefMut
:If we remove the
#[lang = "deref{_mut}"]
attributes, then the code works, but otherwise it errors out:the reason is that there is an ambiguity and that the compiler finds two associated trait impls:
Deref
for&mut T
andDeref
for&T