Closed
Description
This looks like a stable-to-nightly regression.
I tried this code:
#![crate_type = "lib"]
use std::marker::PhantomData;
trait Receiver {
type Target: ?Sized;
}
trait Deref: Receiver<Target = <Self as Deref>::Target> {
type Target: ?Sized;
}
impl<T: Deref> Receiver for T {
type Target = <T as Deref>::Target;
}
trait ArrayLike: Deref<Target = [Self::Element]> {
type Element;
}
trait CuPool<T: ArrayLike> {
fn copy_from<O>(&self, from: &mut O) -> CuHandle<T>
where
O: ArrayLike<Element = T::Element>;
}
#[derive(Clone, Debug)]
struct CuHandle<T: ArrayLike>(PhantomData<T>);
I expected to see this happen: it should compile, which is the case with stable rustc 1.85.0 (4d91de4e4 2025-02-17)
Instead, this happened:
error[E0284]: type annotations needed
--> test2.rs:22:5
|
22 | / fn copy_from<O>(&self, from: &mut O) -> CuHandle<T>
23 | | where
24 | | O: ArrayLike<Element = T::Element>;
| |___________________________________________^ cannot infer type
|
= note: cannot satisfy `<O as Deref>::Target == _`
Meta
rustc --version --verbose
:
rustc 1.88.0-nightly (e2014e876 2025-04-01)
binary: rustc
commit-hash: e2014e876e3efaa69bf51c19579adb16c3df5f81
commit-date: 2025-04-01
host: <sorry>
release: 1.88.0-nightly
LLVM version: 20.1.1
Backtrace
<backtrace>
My investigation
rustc_trait_selection::traits::do_normalize_predicates
generate an ErrorGuaranteed
even though it should bubble the unnormalized projection up. I am experimenting a fix, which is to perform the "bubbling". Meanwhile, I would like to hear your verdicts on this issue.