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

rustdoc: rustdoc -W help prints error unless a file argument is given #88756

Closed
lilyball opened this issue Sep 8, 2021 · 4 comments · Fixed by #98331
Closed

rustdoc: rustdoc -W help prints error unless a file argument is given #88756

lilyball opened this issue Sep 8, 2021 · 4 comments · Fixed by #98331
Assignees
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@lilyball
Copy link
Contributor

lilyball commented Sep 8, 2021

Compiler lints can be printed with rustc -W help, with no filename arguments given. Unfortunately this doesn't work the same way for rustdoc:

rustdoc -W help
error: missing file operand

If I pass it an arbitrary file, it will print any errors produced by parsing the file as rust. This includes errors from using async without passing --edition 2018. This part is actually the same as rustc -W help, in that passing arbitrary files to that produces the same behavior.

If I pass it a file that parses cleanly (either 2015 rust, or 2018 rust with --edition 2018 specified) then and only then will rustdoc -W help actually print the lint groups. In this way it behaves similarly to rustc -W help $filename in that rustc will also print the lint groups when passed a filename that parses cleanly. The difference is that rustc -W help doesn't require a filename at all.

The simplest workaround here is to type rustdoc -W help /dev/null as the empty /dev/null file does not trigger any parse errors.

Potential root cause

It's possible that the root cause here is that calling rustdoc with no args produces the same error:

rustdoc
error: missing file operand

Compare this with rustc, which prints the help:

rustc
Usage: rustc [OPTIONS] INPUT

Options:
    -h, --help          Display this message
        --cfg SPEC      Configure the compilation environment
    -L [KIND=]PATH      Add a directory to the library search path. The

This suggests that rustdoc is checking for filename arguments and erroring out early on, whereas rustc skips that check and then later interprets "no filename args" as "fallback to help".

Meta

rustdoc --version --verbose
rustdoc 1.54.0 (a178d0322 2021-07-26)
binary: rustdoc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-apple-darwin
release: 1.54.0
LLVM version: 12.0.1rustdoc +nightly --version --verbose
rustdoc 1.57.0-nightly (fdf65053e 2021-09-07)
binary: rustdoc
commit-hash: fdf65053e99e8966f9bd83b5a8491326cb33d638
commit-date: 2021-09-07
host: x86_64-apple-darwin
release: 1.57.0-nightly
LLVM version: 13.0.0
@lilyball lilyball added the C-bug Category: This is a bug. label Sep 8, 2021
@camelid camelid added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Sep 8, 2021
@jyn514 jyn514 added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Sep 9, 2021
@jyn514
Copy link
Member

jyn514 commented Sep 9, 2021

Mentoring instructions: move

let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
to before
diag.struct_err("missing file operand").emit();

@jyn514 jyn514 added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Sep 9, 2021
@inashivb
Copy link
Contributor

inashivb commented Sep 9, 2021

Hi @jyn514 !
May I claim this issue if no one else is working on it?

@jyn514
Copy link
Member

jyn514 commented Sep 9, 2021

@inashivb go for it :)

@inashivb
Copy link
Contributor

inashivb commented Sep 9, 2021

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 24, 2022
…mez,notriddle

Fix `rustdoc` argument error

This is the fix is corresponding to rust-lang#88756 mentored by ``@jyn514``
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 24, 2022
…mez,notriddle

Fix `rustdoc` argument error

This is the fix is corresponding to rust-lang#88756 mentored by ```@jyn514```
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 24, 2022
…mez,notriddle

Fix `rustdoc` argument error

This is the fix is corresponding to rust-lang#88756 mentored by ````@jyn514````
@bors bors closed this as completed in 38bfa9c Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants