Skip to content

rustdoc-json: ICE when same item is represented in different ways #97986

Closed
@Enselic

Description

@Enselic

Minimal reproducer:

// src/lib.rs

pub mod m {
    pub struct S;
}

pub trait F {
    fn f() -> m::S;
}

impl<T> F for T {
    fn f() -> m::S {
        m::S
    }
}
% RUSTDOCFLAGS='-Z unstable-options --output-format json' cargo +nightly doc --lib --no-deps
thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Item { id: Id("0:10:601"), crate_id: 0, name: Some("f"), span: Some(Span { filename: "src/lib.rs", begin: (10, 4), end: (12, 5) }), visibility: Default, docs: None, links: {}, attrs: [], deprecation: None, inner: Method(Method { decl: FnDecl { inputs: [], output: Some(ResolvedPath { name: "S", id: Id("0:4:1544"), args: Some(AngleBracketed { args: [], bindings: [] }), param_names: [] }), c_variadic: false }, generics: Generics { params: [], where_predicates: [] }, header: Header { const_: false, unsafe_: false, async_: false, abi: Rust }, has_body: true }) }`,
 right: `Item { id: Id("0:10:601"), crate_id: 0, name: Some("f"), span: Some(Span { filename: "src/lib.rs", begin: (10, 4), end: (12, 5) }), visibility: Default, docs: None, links: {}, attrs: [], deprecation: None, inner: Method(Method { decl: FnDecl { inputs: [], output: Some(ResolvedPath { name: "m::S", id: Id("0:4:1544"), args: Some(AngleBracketed { args: [], bindings: [] }), param_names: [] }), c_variadic: false }, generics: Generics { params: [], where_predicates: [] }, header: Header { const_: false, unsafe_: false, async_: false, abi: Rust }, has_body: true }) }`', src/librustdoc/json/mod.rs:202:17

The panic happens because ResolvedPath { name: "S" != ResolvedPath { name: "m::S", but they are of course equivalent, so we should not panic because of that.

This is (at least partially) a minimal reproducer for #93588.

@rustbot labels +A-rustdoc-json +I-ICE +T-rustdoc

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsonArea: Rustdoc JSON backendI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions