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

Deny warnings for doc tests #1672

Merged
merged 1 commit into from
Jun 14, 2019
Merged

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Jun 13, 2019

We cleaned this up with some PRs (#1590, #1381, etc.), so we are not warned at the moment, but it will be useful to maintain the quality of the examples. (EDIT: I missed unused being allowed by default.)

It would have been nice if this was supported as a cargo doc or clippy option (maybe like cargo doc --test -- --Dwarnings?), but it does not seem to be supported yet (rust-lang/rust#56232).

@@ -397,9 +405,8 @@ pub trait FutureExt: Future {
///
/// # Examples
///
// TODO: minimize and open rust-lang/rust ticket, currently errors:
// 'assertion failed: !value.has_escaping_regions()'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this seems to have already been fixed.

@cramertj
Copy link
Member

It would have been nice if this was supported as a cargo doc or clippy option (maybe like cargo doc --test -- --Dwarnings?)

Could we maybe bypass it by setting RUSTFLAGS directly?

@taiki-e
Copy link
Member Author

taiki-e commented Jun 13, 2019

Could we maybe bypass it by setting RUSTFLAGS directly?

I'll try it.

UPDATE: RUSTFLAGS did not go well.

@Nemo157
Copy link
Member

Nemo157 commented Jun 14, 2019

I found this while looking through the rustdoc source trying to figure out why RUSTFLAGS doesn't actually apply (docs here):

#![doc(test(attr(deny(warnings))))]

adding that at the crate root will inject the contained attribute into all tests automatically.

EDIT: Although that has what I consider the wrong semantics still, there's no way to trigger it from just CI, it will make the examples fail when building locally. The only workaround I can think of is to use something like #![cfg_attr(feature = "ci-only-fail-doc-test-warnings", doc(test(attr(deny(warnings)))))], but then you won't be shown the warnings when building locally (rustdoc suppresses compiler output if the test passes). So probably better to have them denied everywhere until it's possible to run the lints against them independently.

@taiki-e
Copy link
Member Author

taiki-e commented Jun 14, 2019

@Nemo157 Thanks for finding it out.

#![doc(test(attr(deny(warnings))))]

It seems that it also denies the lints that rustdoc allows by default, so I feel that it is better to allow dead_code and so on. Probably like:

#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]

I also agree that it is preferable to deny everywhere until it's possible to run the lints against them independently.

@taiki-e taiki-e force-pushed the docs-warnings branch 2 times, most recently from 7babf7d to e527030 Compare June 14, 2019 12:10
@cramertj
Copy link
Member

Nice! Thanks to both of you for the investigation and the fixes.

@cramertj cramertj merged commit eccfa19 into rust-lang:master Jun 14, 2019
@taiki-e taiki-e deleted the docs-warnings branch June 15, 2019 02:49
bors bot added a commit to crossbeam-rs/crossbeam that referenced this pull request May 25, 2020
515: Deny warnings for doc tests r=jeehoonkang a=taiki-e

There are some unused imports/`mut`s.

Refs: rust-lang/futures-rs#1672, tokio-rs/tokio#1539



Co-authored-by: Taiki Endo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants