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

stdio module description "stutters" #12386

Closed
Valloric opened this issue Feb 19, 2014 · 8 comments
Closed

stdio module description "stutters" #12386

Valloric opened this issue Feb 19, 2014 · 8 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Valloric
Copy link
Contributor

This page: http://static.rust-lang.org/doc/master/std/io/stdio/index.html

The starting paragraph:

Non-blocking access to stdin, stdout, stderr Non-blocking access to stdin, stdout, stderr This modules provides bindings to the local [...]

The "Non-blocking access to stdin, stdout, stderr" section repeats itself and there are some periods missing.

@zslayton
Copy link
Contributor

I looked into this a bit. It turns out it's actually a problem for all of the module-level documentation pages. The rustdoc comment from the mod.rs file appears to be getting pulled into the documentation page multiple times.

For other examples, see:

I'm happy to take this issue, but I'm new to the documentation build system. Could someone point me to the template that I'd need to modify?

@zslayton
Copy link
Contributor

It appears that this is only a problem for modules found in std::io, where the mod.rs file has a summary comment above each pub mod line. The summary is not-quite-verbatim repeated in the module file itself.

For example, std::io::fs has the following opening line:

Synchronous, non-blocking filesystem operations. Synchronous, non-blocking filesystem operations. Synchronous File I/O

mod.rs contains:

/// Synchronous, non-blocking filesystem operations.
pub mod fs;

and fs.rs contains:

/*! Synchronous File I/O

The mod.rs lines are inserted twice, followed by the file's summary line. The double-insertion appears to be a rustdoc bug, but the standard in the rest of libstd seems to be not having any comments above pub mod. I'm going to make a PR to remove the mod.rs comments.

Could someone more knowledgeable than I comment on the double-insert?

@sfackler
Copy link
Member

I think rustdoc is correct to include both chunks of docs and that removing the docs from mod.rs is the right approach.

@huonw
Copy link
Member

huonw commented Feb 23, 2014

@sfackler it's not correct to include the /// comment 3 times though.

@zslayton
Copy link
Contributor

@huonw @sfackler

It appears to include the /// comment twice, followed by the file summary once for a total of three.

@sfackler
Copy link
Member

Oh, interesting.

@huonw
Copy link
Member

huonw commented Feb 23, 2014

@zslayton if you are interested in debugging this, creating a minimal example, and using -Z ast-json will print the AST as (prettified) JSON, so you can see if the compiler is passing the correct thing to rustdoc.

The collapse_docs function in librustdoc/passes.rs is probably also worth some investigation.

Other than that... I don't really know. (It'd be worth seeing if it is specific to modules, or if, e.g.,

/// foo
fn bar() {
     //! baz
}

confuses it too.)

@zslayton
Copy link
Contributor

@huonw Thanks, I'll do that.

In the meantime, I'm going to make a PR to convert the comments in mod.rs to plain // comments. Then we can close out this issue.

If I can make a minimal, reproducible example of the double-insert problem, I'll open a new issue so we can track it separately.

bors added a commit that referenced this issue Feb 26, 2014
@bors bors closed this as completed in 90f2d1d Feb 26, 2014
pzol pushed a commit to pzol/rust that referenced this issue Feb 27, 2014
…od.rs file. Added summary doc-comments to test.rs, util.rs and stdio.rs.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…, r=Veykril

Add test for rust-lang#12372 (generate enum variant in different file)

The test currently fails but I'm not sure why.

The "Right" output seems to contain only the contents of `foo.rs`, without the magic comments:

<img width="967" alt="image" src="https://user-images.githubusercontent.com/7998310/170310707-e69b21eb-d4f8-46c1-8a0a-9b4071289e26.png">

cc `@Veykril`
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
[`use_self`]: Make it aware of lifetimes

Have the lint trigger even if `Self` has generic lifetime parameters.

```rs
impl<'a> Foo<'a> {
    type Item = Foo<'a>; // Can be replaced with Self

    fn new() -> Self {
        Foo { // No lifetime, but they are inferred to be that of Self
              // Can be replaced as well
            ...
        }
    }

    // Don't replace `Foo<'b>`, the lifetime is different!
    fn eq<'b>(self, other: Foo<'b>) -> bool {
        ..
    }
```

Fixes rust-lang#12381

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`use_self`]: Have the lint trigger even if `Self` has generic lifetime parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants