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

Enforce even more the code blocks attributes check through rustdoc #71670

Merged

Conversation

GuillaumeGomez
Copy link
Member

rustdoc now has a lint which allows it to warn if a code block attribute is malformated (which can end up in bad situations, even more in case of testing examples!). Now it'll fail if such a situation is encountered when testing markdown code blocks examples.

r? @Mark-Simulacrum

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 29, 2020
@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Apr 29, 2020

I would expect this to apply to more than just markdown tests (e.g. for us to set it when doc-testing std, etc.). Is there a reason you've not done that?

If that's just by accident, then I'd recommend setting this via RUSTDOCFLAGS. (I guess we'd also need to add it to rustdoc_cmd).

@Mark-Simulacrum Mark-Simulacrum 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-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2020
@GuillaumeGomez
Copy link
Member Author

Fine by me!

@joelpalmer joelpalmer 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2020
@Elinvynia Elinvynia 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 27, 2020
@GuillaumeGomez GuillaumeGomez force-pushed the enforce-codeblocks-attribute-check branch from edeeb71 to 62dc5c6 Compare June 10, 2020 09:59
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Linux mingw-check
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 54'
Agent machine name: 'fv-az578'
Current agent version: '2.170.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200604.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200604.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.163.3)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/44641377-1a63-4bfa-b1fc-a2b6ff7086a0.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/71670/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/71670/merge:refs/remotes/pull/71670/merge
---
 ---> f883e675ad62
Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
 ---> Using cache
 ---> c0b156eb069c
Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            python3 ../x.py doc --stage 0 src/libstd &&            /scripts/validate-toolstate.sh
 ---> 8541bab6b38c
Successfully built 8541bab6b38c
Successfully tagged rust-ci:latest
Built container sha256:8541bab6b38c07f1b7eb787539b9cbe93daa6ac4458d3d7bd8a8921622a14ba1
---
   Compiling bootstrap v0.0.0 (/checkout/src/bootstrap)
error[E0599]: no method named `push` found for struct `builder::Rustflags` in the current scope
    --> src/bootstrap/builder.rs:806:15
     |
806  |     rustdocflags.push("--deny");
     |                  ^^^^ method not found in `builder::Rustflags`
1353 | struct Rustflags(String);
1353 | struct Rustflags(String);
     | ------------------------- method `push` not found for this
error[E0599]: no method named `push` found for struct `builder::Rustflags` in the current scope
    --> src/bootstrap/builder.rs:807:15
     |
807  |     rustdocflags.push("invalid_codeblock_attribute");
807  |     rustdocflags.push("invalid_codeblock_attribute");
     |                  ^^^^ method not found in `builder::Rustflags`
...
1353 | struct Rustflags(String);
     | ------------------------- method `push` not found for this
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `bootstrap`.
---
  local time: Wed Jun 10 10:05:01 UTC 2020
  network time: Wed, 10 Jun 2020 10:05:01 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/71670/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/71670/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (3963) (python)
##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@GuillaumeGomez GuillaumeGomez force-pushed the enforce-codeblocks-attribute-check branch from 62dc5c6 to ad1d46a Compare June 10, 2020 11:13
@GuillaumeGomez
Copy link
Member Author

Updated!

@Elinvynia Elinvynia added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2020
@Mark-Simulacrum
Copy link
Member

Does rustdoc not support the rustc syntax of -D<lint name>? If it does, I would prefer to use that for consistency.

I would also like to move the deny in builder.rs to somewhere in here:

and adjust the one in rustdoc_cmd to also use deny_warnings to enable deny.

@Mark-Simulacrum Mark-Simulacrum 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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2020
@GuillaumeGomez GuillaumeGomez force-pushed the enforce-codeblocks-attribute-check branch from ad1d46a to 1fab9c0 Compare July 13, 2020 14:29
@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 13, 2020
@GuillaumeGomez
Copy link
Member Author

Updated!

@Mark-Simulacrum
Copy link
Member

Hm, I think the lint name has been updated since then to be plural but r=me with that fixed.

@GuillaumeGomez
Copy link
Member Author

Ah the PR got merged already? Updating then!

@GuillaumeGomez GuillaumeGomez force-pushed the enforce-codeblocks-attribute-check branch from 1fab9c0 to 72199f0 Compare July 13, 2020 15:12
@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum Any idea what's going in:

error[E0602]: unknown lint: `invalid_codeblock_attributes`
  |
  = help: did you mean: `invalid_codeblock_attribute`
  = note: requested on the command line with `-D invalid_codeblock_attributes`

? I tested locally and the option works just as expected. Is it using an older rustc/rustdoc version?

@Mark-Simulacrum
Copy link
Member

Oh, yeah, right -- we're checking that --stage 0 doc works on CI. I think probably the easiest thing is just to wait ... 3 days or so until we bump the beta compiler anyway?

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 15, 2020
@GuillaumeGomez GuillaumeGomez force-pushed the enforce-codeblocks-attribute-check branch from 72199f0 to 3dc8544 Compare July 16, 2020 14:40
@@ -725,7 +725,11 @@ impl<'a> Builder<'a> {
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
.env("RUSTDOC_REAL", self.rustdoc(compiler))
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
.env("RUSTC_BOOTSTRAP", "1");
.env("RUSTC_BOOTSTRAP", "1")
.arg("-Dinvalid_codeblock_attributes");
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be -D... but rather -W, with -Dwarnings upgrading that only when --deny=warnings or equivalent is passed to x.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same answer as I provided here.

src/bootstrap/builder.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

Still not working with the new lint. :'(

@Mark-Simulacrum
Copy link
Member

Yeah, #74395 will need to land first.

@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum I'll trust you on this one: I set the lint to warning level by default. I really hope it is set to deny when running in CI. :)

}
rustdocflags.arg("-Winvalid_codeblock_attributes");
Copy link
Member

Choose a reason for hiding this comment

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

Why was this moved outside of the InTree block? We should still only specify this for in-tree crates.

Copy link
Member Author

Choose a reason for hiding this comment

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

Woups, my bad.

@GuillaumeGomez
Copy link
Member Author

I think it's now ready @Mark-Simulacrum. :)

@Mark-Simulacrum
Copy link
Member

@bors r+ rollup=iffy since this denies a new lint (and could have conflicts with things introducing errors for that lint)

@bors
Copy link
Contributor

bors commented Jul 17, 2020

📌 Commit 5f6c079 has been approved by Mark-Simulacrum

@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 Jul 17, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 17, 2020
…ttribute-check, r=Mark-Simulacrum

Enforce even more the code blocks attributes check through rustdoc

`rustdoc` now has a lint which allows it to warn if a code block attribute is malformated (which can end up in bad situations, even more in case of testing examples!). Now it'll fail if such a situation is encountered when testing markdown code blocks examples.

r? @Mark-Simulacrum
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 17, 2020
…arth

Rollup of 18 pull requests

Successful merges:

 - rust-lang#71670 (Enforce even more the code blocks attributes check through rustdoc)
 - rust-lang#73930 (Make some Option methods const)
 - rust-lang#74009 (Fix MinGW `run-make-fulldeps` tests)
 - rust-lang#74056 (Add Arguments::as_str().)
 - rust-lang#74169 (Stop processing unreachable blocks when solving dataflow)
 - rust-lang#74251 (Teach bootstrap about target files vs target triples)
 - rust-lang#74288 (Fix src/test/run-make/static-pie/test-aslr.rs)
 - rust-lang#74300 (Use intra-doc links in core::iter module)
 - rust-lang#74364 (add lazy normalization regression tests)
 - rust-lang#74368 (Add CSS tidy check)
 - rust-lang#74394 (Remove leftover from emscripten fastcomp support)
 - rust-lang#74411 (Don't assign `()` to `!` MIR locals)
 - rust-lang#74416 (Use an UTF-8 locale for the linker.)
 - rust-lang#74424 (Move hir::Place to librustc_middle/hir)
 - rust-lang#74428 (docs: better demonstrate that None values are skipped as many times a…)
 - rust-lang#74438 (warn about uninitialized multi-variant enums)
 - rust-lang#74440 (Fix Arc::as_ptr docs)
 - rust-lang#74452 (intra-doc links: resolve modules in the type namespace)

Failed merges:

r? @ghost
@bors bors merged commit 3006ea3 into rust-lang:master Jul 18, 2020
@GuillaumeGomez GuillaumeGomez deleted the enforce-codeblocks-attribute-check branch July 20, 2020 08:47
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.

None yet

7 participants