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

tidy: Run tidy style against markdown files. #81402

Merged
merged 3 commits into from
Feb 6, 2021
Merged

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jan 26, 2021

This adds tidy checks for markdown files. I think it is useful to have some style enforcement (for the same reasons the style is enforced on other files). I think it is worthwhile to avoid ignore on rust examples since having broken code in documentation is frustrating. Avoiding trailing whitespace is good because it has semantic meaning in markdown, which I think should be avoided.

@rust-highfive
Copy link
Collaborator

r? @steveklabnik

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 26, 2021
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 29 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiii

 finished in 0.066 seconds
Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 116 tests
iiiiiiiiii.i.i..i..i..ii....i.i.....ii.........iiii.........i.....i...i.......ii.i.ii.....iiii.....i 100/116
test result: ok. 78 passed; 0 failed; 38 ignored; 0 measured; 0 filtered out; finished in 2.23s

 finished in 2.305 seconds
Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
---
doc tests for: /checkout/src/doc/unstable-book/src/language-features/intrinsics.md
doc tests for: /checkout/src/doc/unstable-book/src/language-features/lang-items.md


command did not execute successfully: "/checkout/obj/build/bootstrap/debug/rustdoc" "-Winvalid_codeblock_attributes" "-Dwarnings" "-Znormalize-docs" "--test" "/checkout/src/doc/unstable-book/src/language-features/lang-items.md" "--test-args" ""

stdout ----

running 3 tests
running 3 tests
test /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_::_::Writing_an_executable_without_stdlib (line 144) ... FAILED
test /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_ (line 18) ... FAILED
test /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_::_::Writing_an_executable_without_stdlib (line 108) ... FAILED

failures:

---- /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_::_::Writing_an_executable_without_stdlib (line 144) stdout ----
error[E0464]: multiple matching crates for `libc`
   |
10 | extern crate libc;
   | ^^^^^^^^^^^^^^^^^^
   |
   |
   = note: candidates:
           crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d630318955afa9cb.rlib
           crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-c4a7f3f5739debac.rlib
error: aborting due to previous error

Couldn't compile the test.
---- /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_ (line 18) stdout ----
---- /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_ (line 18) stdout ----
error[E0464]: multiple matching crates for `libc`
  |
7 | extern crate libc;
  | ^^^^^^^^^^^^^^^^^^
  |
  |
  = note: candidates:
          crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d630318955afa9cb.rlib
          crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-c4a7f3f5739debac.rlib
error: aborting due to previous error

Couldn't compile the test.
---- /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_::_::Writing_an_executable_without_stdlib (line 108) stdout ----
---- /checkout/src/doc/unstable-book/src/language-features/lang-items.md - The_tracking_issue_for_this_feature_is__None_::_::Writing_an_executable_without_stdlib (line 108) stdout ----
error[E0464]: multiple matching crates for `libc`
  |
9 | extern crate libc;
  | ^^^^^^^^^^^^^^^^^^
  |
  |
  = note: candidates:
          crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d630318955afa9cb.rlib
          crate `libc`: /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-c4a7f3f5739debac.rlib
error: aborting due to previous error

Couldn't compile the test.

@@ -47,16 +47,15 @@ all type errors and name resolution errors with function bodies. Note that this
work for anything outside a function body: since Rustdoc documents your types, it has to
know what those types are! For example, this code will work regardless of the platform:

<!-- `ignore` because doc-tests are run with `rustc`, not `rustdoc` -->
```ignore
```rust,ignore (platform-specific)
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't preserve the info from the comment IMO. The issue is that - regardless of whether rustc gives an error or not - it may not match rustdoc's behavior, so it would be confusing to show it.

Suggested change
```rust,ignore (platform-specific)
```rust,ignore (tests rustdoc, not rustc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that is a good explanation of why it is ignored. If it was just about the different output, then noplayground would be a more appropriate marker.

The important difference is that with ignore, there's nothing to validate that the example contains valid rust code. With noplayground, it'll be validated, but won't show the play button (which I assume is what the concern is about). Generally it is best to avoid ignore if at all possible.

That being said, I added an annotation for that.

Copy link
Member

Choose a reason for hiding this comment

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

. If it was just about the different output, then noplayground would be a more appropriate marker.

It's not about the output - there is code that rustdoc accepts that rustc doesn't. So if this is marked with no_playground a) it will break on Linux because it's tested with rustc and b) even if it didn't break it would be misleading, because rustdoc and rustc are fundamentally treating this code differently.

If it makes you feel better, ignore still validates that the syntax is valid, just not that the program typechecks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't mean to seem like I was contradicting you; I could have worded that better. I was just trying to explain the reasoning I had for changing it. I understand there is a subtle reasoning here.

ignore does not validate syntax for tests. That validation is only run when building API documentation with rustdoc (and even then, I think it is only a warning). When running rustdoc --test you can put any text in an ignore block and it is completely ignored, and that's how the books are tested.

Copy link
Member

@jyn514 jyn514 Feb 4, 2021

Choose a reason for hiding this comment

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

Ah ok, that makes sense.

ignore does not validate syntax for tests.

Well, maybe it shouldn't, but currently it does: #30032 Never mind, you were talking specifically about --test I think.

pub fn f() {
use std::os::windows::ffi::OsStrExt;
}
```

but this will not, because the unknown type is part of the function signature:

```ignore
```rust,ignore (platform-specific)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
```rust,ignore (platform-specific)
```rust,ignore (tests rustdoc, not rustc)

@jyn514 jyn514 added A-testsuite Area: The testsuite used to check the correctness of rustc C-cleanup Category: PRs that clean code up or issues documenting cleanup. labels Jan 26, 2021
@jyn514
Copy link
Member

jyn514 commented Jan 26, 2021

The other changes LGTM, feel free to r? me if you like.

@ehuss
Copy link
Contributor Author

ehuss commented Jan 26, 2021

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned steveklabnik Jan 26, 2021
@camelid
Copy link
Member

camelid commented Jan 28, 2021

Did he mean r=me?

@jyn514
Copy link
Member

jyn514 commented Feb 4, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Feb 4, 2021

📌 Commit 07cd499 has been approved by jyn514

@bors bors 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 Feb 4, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Feb 4, 2021
tidy: Run tidy style against markdown files.

This adds tidy checks for markdown files.  I think it is useful to have some style enforcement (for the same reasons the style is enforced on other files).  I think it is worthwhile to avoid `ignore` on rust examples since having broken code in documentation is frustrating.  Avoiding trailing whitespace is good because it has semantic meaning in markdown, which I think should be avoided.
global_asm!(include_str!("something_neato.s"));
```

And a more complicated usage looks like this:

```rust,ignore
```rust,no_run
Copy link
Member

Choose a reason for hiding this comment

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

@m-ou-se
Copy link
Member

m-ou-se commented Feb 4, 2021

#81748 (comment)

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 4, 2021
The cfg isn't actually necessary, since `--emit=metadata` does not
actually do enough validation for it to fail on any platform. However,
I feel a little more comfortable leaving it in.

Unhide the feature flag, since I think that is important to display.
@ehuss
Copy link
Contributor Author

ehuss commented Feb 4, 2021

I have tweaked the test to work on non-x86 platforms. I don't have an aarch64 linux system to test, but I manually tested a variety of arm targets and at least the unstable book passes the tests.

@bors r=jyn514

@bors
Copy link
Contributor

bors commented Feb 4, 2021

📌 Commit 900648c has been approved by jyn514

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 4, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2021
…as-schievink

Rollup of 7 pull requests

Successful merges:

 - rust-lang#81402 (tidy: Run tidy style against markdown files.)
 - rust-lang#81434 (BTree: fix documentation of unstable public members)
 - rust-lang#81680 (Refactor `PrimitiveTypeTable` for Clippy)
 - rust-lang#81737 (typeck: Emit structured suggestions for tuple struct syntax)
 - rust-lang#81738 (Miscellaneous small diagnostics cleanup)
 - rust-lang#81766 (Enable 'task list' markdown extension)
 - rust-lang#81812 (Add a test for escaping LLVMisms in inline asm)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7acf9ec into rust-lang:master Feb 6, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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.

9 participants