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

Warnings caused by examples in libstd should fail the doc tests #18199

Closed
crumblingstatue opened this issue Oct 20, 2014 · 3 comments
Closed
Assignees
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@crumblingstatue
Copy link
Contributor

Recently, an incorrect example was discovered in the libstd documentation.

In this case, the compiler gives a warning for unused results on the I/O operations.
The example should have checked these results, uncovering a bug, which is the file being opened in read-only mode when it was intended to be written to.

If warnings would fail the doc tests, this issue would have been caught automatically.

In case an example wants to explicitly allow "questionable" constructs, it can use the allow(lint) attribute.

@steveklabnik steveklabnik added A-docs T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 20, 2014
@sfackler
Copy link
Member

We definitely want to allow some warnings, like dead_code, but it seems like adding a default #[deny(unused_result)] would be a good idea.

@crumblingstatue
Copy link
Contributor Author

How about allowing dead_code (and perhaps some other things that are commonly valid for examples), and denying everything else by default?

@steveklabnik
Copy link
Member

The reason warnings weren't happening is that they were actually suppressed.

@alexcrichton alexcrichton self-assigned this Apr 7, 2015
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 8, 2015
This adds support in rustdoc to blanket apply crate attributes to all doc tests
for a crate at once. The syntax for doing this is:

    #![doc(test(attr(...)))]

Each meta item in `...` will be applied to each doctest as a crate attribute.

cc rust-lang#18199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

4 participants