Skip to content
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

Broken links when linking to publicly re-exported private items from another crate. #159

Open
Shadow53 opened this issue Nov 4, 2022 · 4 comments
Labels
S-waiting-on-author Status: Waiting on the author of this PR or issue

Comments

@Shadow53
Copy link

Shadow53 commented Nov 4, 2022

I ran into this with miette::Report and miette::Diagnostic, but I believe it is not specific to just miette.

I have a struct defined something like this (simplified):

use miette::{Diagnostic, Report};

/// This implements [`Diagnostic`] and contains a [`Report`].
#[derive(Diagnostic)]
struct MyDiagnostic {
    #[diagnostic_source]
    source: Report,
}

When running cargo deadlinks --check-intra-doc-links, Report and Diagnostic get flagged, as well as Diagnostic::labels and Diagnostic::source_code, where the latter two are linked in echo other's doc strings.

Report and Diagnostic are only publicly accessible at the top level, as shown in the example, but are privately defined at miette::eyreish::Report and miette::protocol::Diagnostic, respectively.

If I view the generated docs, clicking a link takes me to a page that redirects to the correct page, so these links are not actually "broken".

@jyn514
Copy link
Contributor

jyn514 commented Nov 27, 2022

I can't reproduce this.

; cargo new --lib issue-159
; cd issue-159
; cargo add miette
    Updating crates.io index
      Adding miette v5.5.0 to dependencies.
; cargo deadlinks --check-intra-doc-links
 Documenting issue-159 v0.1.0 (/home/jnelson/rust-community/cargo-deadlinks/issue-159)
    Finished dev [unoptimized + debuginfo] target(s) in 5.43s

@jyn514 jyn514 added the S-waiting-on-author Status: Waiting on the author of this PR or issue label Nov 27, 2022
@Shadow53
Copy link
Author

Did you add a custom struct that derives Diagnostic, as in the example snippet? That's where the error occurs, in the docs for the Diagnostic trait implementation on MyDiagnostic.

Am on mobile, but I can double check with latest cargo-deadlinks in a little bit.

@jyn514
Copy link
Contributor

jyn514 commented Nov 27, 2022

Yes, like so:

use miette::{Diagnostic, Report};
use std::error::Error;
use std::fmt;

/// This implements [`Diagnostic`] and contains a [`Report`].
#[derive(Diagnostic, Debug)]
struct MyDiagnostic {
    #[diagnostic_source]
    source: Report,
}

impl Error for MyDiagnostic {}
impl fmt::Display for MyDiagnostic {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        todo!()
    }
}

@Shadow53
Copy link
Author

I'm able to reproduce with the snippet you mentioned, after changing struct MyDiagnostic to pub struct Diagnostic so that docs are generate for it.

Alternatively:

 cargo deadlinks --check-intra-doc-links -- --document-private-items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: Waiting on the author of this PR or issue
Projects
None yet
Development

No branches or pull requests

2 participants