-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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-json] Assertion error on blanket impls #83718
Comments
MCVE: pub trait Load {
fn load() {}
}
impl<P> Load for P {
fn load() {}
}
pub struct Wrapper {} One has |
I have a similar MCVE generated from pub struct A {}
pub trait X {
fn do_thing() -> A;
}
impl<I> X for I {
fn do_thing() -> A {
unimplemented!()
}
} thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `Item { id: Id("0:8"), crate_id: 0, name: Some("do_thing"), span: Some(Span { filename: "src/lib.rs", begin: (18, 4), end: (20, 5) }), visibility: Public, docs: None, links: {}, attrs: [], deprecation: None, inner: Method(Method { decl: FnDecl { inputs: [], output: Some(ResolvedPath { name: "A", id: Id("0:3"), args: Some(AngleBracketed { args: [], bindings: [] }), param_names: [] }), c_variadic: false }, generics: Generics { params: [], where_predicates: [] }, header: {}, abi: "\"Rust\"", has_body: true }) }`,
right: `Item { id: Id("0:8"), crate_id: 0, name: Some("do_thing"), span: Some(Span { filename: "src/lib.rs", begin: (18, 4), end: (20, 5) }), visibility: Default, docs: None, links: {}, attrs: [], deprecation: None, inner: Method(Method { decl: FnDecl { inputs: [], output: Some(ResolvedPath { name: "A", id: Id("0:3"), args: Some(AngleBracketed { args: [], bindings: [] }), param_names: [] }), c_variadic: false }, generics: Generics { params: [], where_predicates: [] }, header: {}, abi: "\"Rust\"", has_body: true }) }`', src/librustdoc/json/mod.rs:195:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace The left has a visibility of A similar MCVE, with pub struct A {}
pub trait X {
fn do_thing(self) -> A;
}
impl<I> X for I {
fn do_thing(self) -> A {
unimplemented!()
}
} thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `Item { id: Id("0:8"), crate_id: 0, name: Some("do_thing"), span: Some(Span { filename: "src/lib.rs", begin: (18, 4), end: (20, 5) }), visibility: Public, docs: None, links: {}, attrs: [], deprecation: None, inner: Method(Method { decl: FnDecl { inputs: [("", Generic("Self"))], output: Some(ResolvedPath { name: "A", id: Id("0:3"), args: Some(AngleBracketed { args: [], bindings: [] }), param_names: [] }), c_variadic: false }, generics: Generics { params: [], where_predicates: [] }, header: {}, abi: "\"Rust\"", has_body: true }) }`,
right: `Item { id: Id("0:8"), crate_id: 0, name: Some("do_thing"), span: Some(Span { filename: "src/lib.rs", begin: (18, 4), end: (20, 5) }), visibility: Default, docs: None, links: {}, attrs: [], deprecation: None, inner: Method(Method { decl: FnDecl { inputs: [("self", Generic("Self"))], output: Some(ResolvedPath { name: "A", id: Id("0:3"), args: Some(AngleBracketed { args: [], bindings: [] }), param_names: [] }), c_variadic: false }, generics: Generics { params: [], where_predicates: [] }, header: {}, abi: "\"Rust\"", has_body: true }) }`', src/librustdoc/json/mod.rs:195:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
…r=jsha Fix errors on blanket impls by ignoring the children of generated impls Related to rust-lang#83718 We can safely skip the children, as they don't contain any new info, and may be subtly different for reasons hard to track down, in ways that are consistently worse than the actual generic impl.
…ency, r=GuillaumeGomez Fix inconsistency of local blanket impls When a blanket impl is local, go through HIR instead of middle. This fixes inconsistencies with data detected during JSON generation. Expected this change to take longer. I also tried doing the whole item through existing clean architecture, but it didn't work out trivially, and felt like it would have added more complexity than it removed. Properly fixes rust-lang#83718
rustdoc +stage1 trait.rs -w json
Interesingly, and shockingly If you remove
pub struct Wrapper<T>(T);
andimpl<T> Get for Wrapper<T>
, this doesn't panic.Whats up with the diff?
The assetion format is differnt to usual as I've patch rustc with
to make it readable, but this can also be repoduced with the latest nightly
@rustbot modify labels: +A-rustdoc-json +T-rustdoc
The text was updated successfully, but these errors were encountered: