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: add #[allow(unused)] to every doctest #45764

Merged
merged 2 commits into from
Nov 7, 2017

Conversation

QuietMisdreavus
Copy link
Member

More information in #45750 - this is behavior that was documented but not actually implemented.

I also reordered how outer attributes are applied to doctests. Previously, attributes from #![doc(test(attr(...)))] would be applied after attributes from within the test itself, meaning if a doctest tried to override lints that would be set crate-wide, it wouldn't work at all. This gives a better scope of how lints can be applied.

Closes #45750

@rust-highfive
Copy link
Collaborator

r? @frewsxcv

(rust_highfive has picked a reviewer for you, use r? to override)

@QuietMisdreavus
Copy link
Member Author

r? @GuillaumeGomez

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 5, 2017
@kennytm
Copy link
Member

kennytm commented Nov 5, 2017

Some CI failures regarding playground.

The rustdoc/no-run-still-checks-lints.rs failure should be expected?

[01:00:27] failures:
[01:00:27] 
[01:00:27] ---- [rustdoc] rustdoc/playground-arg.rs stdout ----
[01:00:27] 	
[01:00:27] error: htmldocck failed!
[01:00:27] status: exit code: 1
[01:00:27] command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/playground-arg.stage2-x86_64-unknown-linux-gnu" "/checkout/src/test/rustdoc/playground-arg.rs"
[01:00:27] stdout:
[01:00:27] ------------------------------------------
[01:00:27] 
[01:00:27] ------------------------------------------
[01:00:27] stderr:
[01:00:27] ------------------------------------------
[01:00:27] 24: @matches check failed
[01:00:27] 	`XPATH PATTERN` did not match
[01:00:27] 	// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=extern%20crate%20foo%3B%0Afn%20main()%20%7B%0Ause%20foo%3A%3Adummy%3B%0Adummy()%3B%0A%7D"]' "Run"
[01:00:27] 
[01:00:27] Encountered 1 errors
[01:00:27] 
[01:00:27] ------------------------------------------
[01:00:27] 
[01:00:27] thread '[rustdoc] rustdoc/playground-arg.rs' panicked at 'explicit panic', /checkout/src/tools/compiletest/src/runtest.rs:2497:8
[01:00:27] 
[01:00:27] ---- [rustdoc] rustdoc/playground.rs stdout ----
[01:00:27] 	
[01:00:27] error: htmldocck failed!
[01:00:27] status: exit code: 1
[01:00:27] command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/playground.stage2-x86_64-unknown-linux-gnu" "/checkout/src/test/rustdoc/playground.rs"
[01:00:27] stdout:
[01:00:27] ------------------------------------------
[01:00:27] 
[01:00:27] ------------------------------------------
[01:00:27] stderr:
[01:00:27] ------------------------------------------
[01:00:27] 37: @matches check failed
[01:00:27] 	`XPATH PATTERN` did not match
[01:00:27] 	// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=fn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D%0A"]' "Run"
[01:00:27] 38: @matches check failed
[01:00:27] 	`XPATH PATTERN` did not match
[01:00:27] 	// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=fn%20main()%20%7B%0Aprintln!(%22Hello%2C%20world!%22)%3B%0A%7D"]' "Run"
[01:00:27] 39: @matches check failed
[01:00:27] 	`XPATH PATTERN` did not match
[01:00:27] 	// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Bfeature(something)%5D%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D%0A&version=nightly"]' "Run"
[01:00:27] 
[01:00:27] Encountered 3 errors
[01:00:27] 
[01:00:27] ------------------------------------------
[01:00:27] 
[01:00:27] thread '[rustdoc] rustdoc/playground.rs' panicked at 'explicit panic', /checkout/src/tools/compiletest/src/runtest.rs:2497:8
[01:00:27] 
[01:00:27] 
[01:00:27] failures:
[01:00:27]     [rustdoc] rustdoc/no-run-still-checks-lints.rs
[01:00:27]     [rustdoc] rustdoc/playground-arg.rs
[01:00:27]     [rustdoc] rustdoc/playground.rs
[01:00:27] 
[01:00:27] test result: FAILED. 167 passed; 3 failed; 1 ignored; 0 measured; 0 filtered out

@QuietMisdreavus
Copy link
Member Author

It looks like no-run-still-checks-lints.rs passed tests when it was supposed to fail, and that's because supplying #![allow(unused)] followed by #![deny(warnings)] still allows the unused group, because you didn't specifically re-enable it. I'll change that code to only add it if no #![doc(test(attr(...)))] were supplied.

As for the playground ones, it seems like the playground links also use this code to assemble the run links, so i'll need to update those tests to include the new attribute.

also modify the order crate attributes are applied, to have a better
order of how things can override lints, either per-crate or per-test
@QuietMisdreavus
Copy link
Member Author

I've force-pushed to address the test failures.

@GuillaumeGomez
Copy link
Member

Perfect, thanks!

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 6, 2017

📌 Commit ce2768a has been approved by GuillaumeGomez

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2017
kennytm added a commit to kennytm/rust that referenced this pull request Nov 7, 2017
…ts, r=GuillaumeGomez

rustdoc: add #[allow(unused)] to every doctest

More information in rust-lang#45750 - this is behavior that was documented but not actually implemented.

I also reordered how outer attributes are applied to doctests. Previously, attributes from `#![doc(test(attr(...)))]` would be applied *after* attributes from within the test itself, meaning if a doctest tried to override lints that would be set crate-wide, it wouldn't work at all. This gives a better scope of how lints can be applied.

Closes rust-lang#45750
kennytm added a commit to kennytm/rust that referenced this pull request Nov 7, 2017
…ts, r=GuillaumeGomez

rustdoc: add #[allow(unused)] to every doctest

More information in rust-lang#45750 - this is behavior that was documented but not actually implemented.

I also reordered how outer attributes are applied to doctests. Previously, attributes from `#![doc(test(attr(...)))]` would be applied *after* attributes from within the test itself, meaning if a doctest tried to override lints that would be set crate-wide, it wouldn't work at all. This gives a better scope of how lints can be applied.

Closes rust-lang#45750
bors added a commit that referenced this pull request Nov 7, 2017
Rollup of 9 pull requests

- Successful merges: #45470, #45588, #45682, #45714, #45751, #45764, #45778, #45782, #45784
- Failed merges:
@bors bors merged commit ce2768a into rust-lang:master Nov 7, 2017
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 18, 2017
…ol, r=frewsxcv

rustdoc book: talk about #![doc(test(no_crate_inject))] and #![doc(test(attr(...)))]

While investigating rust-lang#45750 i noticed that `#![doc(test(attr(...)))]` wasn't documented at all. Since this is useful for making your examples follow the same coding guidelines as your code, i wanted to add it to the Rustdoc Book. I also added `#![doc(test(no_crate_inject))]` since it's used in the same place and might be useful for macro-heavy crates. I added mentions for these to "The `doc` attribute" as well as "Documentation tests" since it's useful information in both places.

Technically the step reordering in the second commit is gated on rust-lang#45764, since before that lands attributes from the doctest come before the ones from `#![doc(test(attr(...)))]`.
@QuietMisdreavus QuietMisdreavus deleted the rustdoc-doctest-lints branch February 26, 2018 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants