-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rustdoc ICE "Unable to fulfill trait" #80233
Comments
might be a duplicate of #79466 |
I think there are important differences: this code doesn't use feature gates, and it successfully builds, so rustdoc should be expected to succeed instead of erroring or ICE, and the rationale for prioritizing that low (that the input is invalid) doesn't apply. |
MCVE (although it panics in a slightly different place): pub trait Trait2 {
type Type2;
}
pub trait Trait3 {
type Type3;
}
pub struct Question {
pub ins: <<usize as Trait3>::Type3 as Trait2>::Type2,
}
|
Oh interesting my MCVE is not correct - that panics because the impls are missing:
If I add those impls, suddenly rustdoc works: impl Trait3 for usize {
type Type3 = isize;
}
impl Trait2 for isize {
type Type2 = i32;
} |
In fact there are some programs rustdoc accepts that rustc doesn't: #![crate_type = "lib"]
pub trait Trait1 {}
pub trait Trait2 {
type Type2;
}
pub trait Trait3 {
type Type3;
}
/*
impl<T: Trait1> Trait2 for Struct1<T> {
type Type2 = Struct1<T>;
}
*/
impl<I: Trait2> Trait2 for Vec<I> {
type Type2 = Vec<I::Type2>;
}
impl<T: Trait1> Trait3 for T {
type Type3 = Struct1<T>;
}
impl<T: Trait3> Trait3 for Vec<T> {
type Type3 = Vec<T::Type3>;
}
pub struct Struct1<T: Trait1> {
pub ty: T,
}
pub struct Question<T: Trait1> {
pub ins: <<Vec<T> as Trait3>::Type3 as Trait2>::Type2,
}
|
Slightly smaller repro: #![crate_type = "lib"]
pub trait Trait1 {}
pub trait Trait2 {
type Type2;
}
pub trait Trait3 {
type Type3;
}
impl Trait2 for Struct1 {
type Type2 = Struct1;
}
impl<I: Trait2> Trait2 for Vec<I> {
type Type2 = Vec<I::Type2>;
}
impl<T: Trait1> Trait3 for T {
type Type3 = Struct1;
}
impl<T: Trait3> Trait3 for Vec<T> {
type Type3 = Vec<T::Type3>;
}
pub struct Struct1 {}
pub struct Question<T: Trait1> {
pub ins: <<Vec<T> as Trait3>::Type3 as Trait2>::Type2,
} |
…=estebank Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv` Fixes rust-lang#80233 We already have logic in `evaluate_predicates` that tries to add unimplemented predicates to our `ParamEnv`. Trying to add a predicate that already holds can lead to errors later on, since projection will prefer trait candidates from the `ParamEnv` to predicates from an impl.
…=estebank Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv` Fixes rust-lang#80233 We already have logic in `evaluate_predicates` that tries to add unimplemented predicates to our `ParamEnv`. Trying to add a predicate that already holds can lead to errors later on, since projection will prefer trait candidates from the `ParamEnv` to predicates from an impl.
This bug occurs with
cargo doc
.cargo build
works fine.Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: