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

Remove most "```ignore" doc tests. #42777

Merged
merged 3 commits into from
Jun 23, 2017
Merged

Conversation

kennytm
Copy link
Member

@kennytm kennytm commented Jun 20, 2017

Unconditional ```ignore doc tests lead to outdated examples (e.g. #42729 (comment)). This PR tries to change all existing ```ignore tests into one of the following:

  • Add import and declarations to ensure the code is run-pass
  • If the code is not Rust, change to ```text/```sh/```json/```dot
  • If the code is expected compile-fail, change to ```compile_fail
  • If the code is expected run-fail, change to ```should_panic
  • If the code can type-check but cannot link/run, change to ```no_run
  • Otherwise, add an explanation after the ```ignore

The --explain handling is changed to cope with hidden lines from the error index.

Tidy is changed to reject any unexplained ```ignore and ```rust,ignore.

@rust-highfive
Copy link
Collaborator

r? @arielb1

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

@kennytm
Copy link
Member Author

kennytm commented Jun 20, 2017

Additional info:

  1. There are 27 remaining ```ignore tests, divided into 6 categories:

    • code demo which looks better with syntax highlighting only (10 instances)
    • private modules (6 instances)
    • doc test with include!(...) (3 instances)
    • doc test with macro exporting across multiple crates (6 instances)
    • compile_fail cannot check SIMD failure (1 instance)
    • doc test cannot "fail on Linux/Windows/etc but pass on macOS" (1 instance)
  2. There are 8 error codes which are no longer emitted. I just added
    #### Note: this error code is no longer emitted by the compiler., but I'm
    not sure if they should be removed instead.

    • E0073 (indirectly recursive struct)
    • E0074 (#[simd] on generic tuple struct)
    • E0082 (C-like enum overflows — apparantly merged into E0080)
    • E0139 (transmute to wrapper type)
    • E0193 (where clause without generic type parameters)
    • E0398 (&Box<Trait> means &Box<Trait+'static> after Rust 1.3)
    • E0447 (pub inside function)

    E0329 (associated const of generic parameter) is just commented out since the description explicitly said "This is not supported yet".

@steveklabnik
Copy link
Member

Amazing! I have always wanted to do this. Thank you so much!

I can't review right this moment, but was too excited not to leave a message 💯

@Mark-Simulacrum
Copy link
Member

Looks like Travis failed.

[00:50:41] failures:
[00:50:41] 
[00:50:41] ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index (line 7427) stdout ----
[00:50:41] 	error[E0455]: native frameworks are only available on macOS targets
[00:50:41]  --> <anon>:2:1
[00:50:41]   |
[00:50:41] 2 | #[link(name = "FooCoreServices", kind = "framework")] extern {}
[00:50:41]   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:50:41] 
[00:50:41] error: aborting due to previous error(s)
[00:50:41] 
[00:50:41] thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc/session/mod.rs:218
[00:50:41] 
[00:50:41] ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index (line 7887) stdout ----
[00:50:41] 	error[E0455]: native frameworks are only available on macOS targets
[00:50:41]  --> <anon>:2:1
[00:50:41]   |
[00:50:41] 2 | #[link(name = "FooCoreServices", kind = "framework")] extern {}
[00:50:41]   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:50:41] 
[00:50:41] error: aborting due to previous error(s)
[00:50:41] 
[00:50:41] thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc/session/mod.rs:218
[00:50:41] 
[00:50:41] 
[00:50:41] failures:
[00:50:41]     /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index (line 7427)
[00:50:41]     /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index (line 7887)
[00:50:41] 
[00:50:41] test result: FAILED. 1138 passed; 2 failed; 18 ignored; 0 measured; 0 filtered out

@kennytm
Copy link
Member Author

kennytm commented Jun 20, 2017

@Mark-Simulacrum Thanks. Turned this back into ```ignore 🙁 unless there is a way to ignore the test just for macOS.

@arielb1 arielb1 added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 20, 2017
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

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

Great work!

Nitpicks inline.

/// let val: *const u8 = &10u8 as *const u8;
/// ```
/// let val = 10u8;
/// let ptr: *const u8 = &val as *const u8;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank Reverted. Thought this was ```ignored because &10u8 would be dropped too early (it was ```ignored to avoid introducing a #[feature] to the example when .as_ref() was unstable).

/// let val: *mut u8 = &mut 10u8 as *mut u8;
/// ```
/// let mut val = 10u8;
/// let ptr: *mut u8 = &mut val as *mut u8;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank Reverted.

# use std::ptr;
# let v = Some("value");
# type SomeType = &'static [u8];
# unsafe {
ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the unsafe block visible to the documentation?

Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank Made visible.

/// p.x = 22; // ok, even though `p` is uninitialized
///
/// let p: Box<Point>;
/// let mut p: Box<Point>;
/// (*p).x = 22; // not ok, p is uninitialized, can't deref
Copy link
Contributor

Choose a reason for hiding this comment

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

May be these two examples should be separated into a code block that succeeds (above) and one that fails with E0381 (bellow).

Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank Separated into 3 code blocks.

@@ -966,7 +972,7 @@ fn main() {
};
let borrowed = &mut cave;

borrowed.knight.nothing_is_true(); // E0507
// borrowed.knight.nothing_is_true(); // E0507
mem::replace(&mut borrowed.knight, TheDarkKnight).nothing_is_true(); // ok!
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Separate the success and failure cases to catch any regressions. For the second block it'll need a bunch of duplicated hidden code :-/

Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank Reworded and separated into 2 examples.

@@ -2935,12 +2966,13 @@ impl<T, U> CoerceUnsized<MyType<U>> for MyType<T>
[`CoerceUnsized`]: https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html
"##,

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this description commented out? Add a reason to the comment to avoid confusion.

Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank Added a comment to explain why this is hidden at the moment.

@kennytm
Copy link
Member Author

kennytm commented Jun 21, 2017

@estebank Thanks! All addressed.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 21, 2017

📌 Commit 7edba12 has been approved by estebank

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Jun 22, 2017
…bank

Remove most "```ignore" doc tests.

Unconditional ` ```ignore ` doc tests lead to outdated examples (e.g. rust-lang#42729 (comment)). This PR tries to change all existing ` ```ignore ` tests into one of the following:

* Add import and declarations to ensure the code is run-pass
* If the code is not Rust, change to ` ```text `/` ```sh `/` ```json `/` ```dot `
* If the code is expected compile-fail, change to ` ```compile_fail `
* If the code is expected run-fail, change to ` ```should_panic `
* If the code can type-check but cannot link/run, change to ` ```no_run `
* Otherwise, add an explanation after the ` ```ignore `

The `--explain` handling is changed to cope with hidden lines from the error index.

Tidy is changed to reject any unexplained ` ```ignore ` and ` ```rust,ignore `.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Jun 22, 2017
…bank

Remove most "```ignore" doc tests.

Unconditional ` ```ignore ` doc tests lead to outdated examples (e.g. rust-lang#42729 (comment)). This PR tries to change all existing ` ```ignore ` tests into one of the following:

* Add import and declarations to ensure the code is run-pass
* If the code is not Rust, change to ` ```text `/` ```sh `/` ```json `/` ```dot `
* If the code is expected compile-fail, change to ` ```compile_fail `
* If the code is expected run-fail, change to ` ```should_panic `
* If the code can type-check but cannot link/run, change to ` ```no_run `
* Otherwise, add an explanation after the ` ```ignore `

The `--explain` handling is changed to cope with hidden lines from the error index.

Tidy is changed to reject any unexplained ` ```ignore ` and ` ```rust,ignore `.
@kennytm
Copy link
Member Author

kennytm commented Jun 22, 2017

@estebank #[cfg]'ed out Windows on the E0060 in 5dd6538 due to AppVeyor failure on rollup #42817. (I can't repro it locally, but I don't think the other 6 PRs cause the linker issue.)

@estebank
Copy link
Contributor

@bors r-

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 22, 2017

📌 Commit 5dd6538 has been approved by estebank

@estebank
Copy link
Contributor

estebank commented Jun 22, 2017

@kennytm can you file a ticket for that? We need to figure out what the actual problem is, specially because we don't want to have documentation that is incorrect or misleading. It should contain code to reproduce the problem under Windows, and a link to the workaround commit in this PR. Probably the output of AppVeyor too:

failures:
---- C:\projects\rust\build\x86_64-pc-windows-msvc\test\error-index.md - Rust_Compiler_Error_Index (line 1285) stdout ----
	error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\rustdoctest.RWH8fWEAi4XJ\\rust_out.0.o" "/OUT:C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\rustdoctest.RWH8fWEAi4XJ\\rust_out.exe" "/OPT:REF,NOICF" "/DEBUG" "/LIBPATH:C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/LIBPATH:C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "std-c5f066fd9d9c9409.dll.lib" "C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-096fad10dd181792.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: rust_out.0.o : error LNK2019: unresolved external symbol printf referenced in function _ZN8rust_out4main17ha22022d8940e3e88E
          C:\Users\appveyor\AppData\Local\Temp\1\rustdoctest.RWH8fWEAi4XJ\rust_out.exe : fatal error LNK1120: 1 unresolved externals
          
error: aborting due to previous error(s)
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:512
thread 'rustc' panicked at 'couldn't compile the test', src\librustdoc\test.rs:278
---- C:\projects\rust\build\x86_64-pc-windows-msvc\test\error-index.md - Rust_Compiler_Error_Index (line 1355) stdout ----
	error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\rustdoctest.pJgryzUQ8mFi\\rust_out.0.o" "/OUT:C:\\Users\\appveyor\\AppData\\Local\\Temp\\1\\rustdoctest.pJgryzUQ8mFi\\rust_out.exe" "/OPT:REF,NOICF" "/DEBUG" "/LIBPATH:C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/LIBPATH:C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "std-c5f066fd9d9c9409.dll.lib" "C:\\projects\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-096fad10dd181792.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: rust_out.0.o : error LNK2019: unresolved external symbol printf referenced in function _ZN8rust_out4main17ha22022d8940e3e88E
          C:\Users\appveyor\AppData\Local\Temp\1\rustdoctest.pJgryzUQ8mFi\rust_out.exe : fatal error LNK1120: 1 unresolved externals
          
error: aborting due to previous error(s)
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:512
thread 'rustc' panicked at 'couldn't compile the test', src\librustdoc\test.rs:278
failures:
    C:\projects\rust\build\x86_64-pc-windows-msvc\test\error-index.md - Rust_Compiler_Error_Index (line 1285)
    C:\projects\rust\build\x86_64-pc-windows-msvc\test\error-index.md - Rust_Compiler_Error_Index (line 1355)
test result: FAILED. 1138 passed; 2 failed; 20 ignored; 0 measured; 0 filtered out

@kennytm
Copy link
Member Author

kennytm commented Jun 22, 2017

@estebank Found the solution from #42830. Rebased. (My local compiler was VC 2010 which is why I couldn't reproduce it)

@estebank
Copy link
Contributor

@bors r-

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 22, 2017

📌 Commit 513b962 has been approved by estebank

@Mark-Simulacrum
Copy link
Member

Canceled try build.

@brson
Copy link
Contributor

brson commented Jun 22, 2017

Wowee. Super cleanup patch @kennytm.

@Mark-Simulacrum Mark-Simulacrum 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 Jun 22, 2017
@Mark-Simulacrum
Copy link
Member

@bors r+ retry

@bors
Copy link
Contributor

bors commented Jun 22, 2017

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jun 22, 2017

📌 Commit 513b962 has been approved by Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Jun 22, 2017

⌛ Testing commit 513b962 with merge 5752d8b...

bors added a commit that referenced this pull request Jun 22, 2017
Remove most "```ignore" doc tests.

Unconditional ` ```ignore ` doc tests lead to outdated examples (e.g. #42729 (comment)). This PR tries to change all existing ` ```ignore ` tests into one of the following:

* Add import and declarations to ensure the code is run-pass
* If the code is not Rust, change to ` ```text `/` ```sh `/` ```json `/` ```dot `
* If the code is expected compile-fail, change to ` ```compile_fail `
* If the code is expected run-fail, change to ` ```should_panic `
* If the code can type-check but cannot link/run, change to ` ```no_run `
* Otherwise, add an explanation after the ` ```ignore `

The `--explain` handling is changed to cope with hidden lines from the error index.

Tidy is changed to reject any unexplained ` ```ignore ` and ` ```rust,ignore `.
@Mark-Simulacrum
Copy link
Member

ah, whatever, I guess try actually has to pass for bors to be happy..

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jun 22, 2017

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@bors
Copy link
Contributor

bors commented Jun 22, 2017

📌 Commit 513b962 has been approved by estebank

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 22, 2017
…bank

Remove most "```ignore" doc tests.

Unconditional ` ```ignore ` doc tests lead to outdated examples (e.g. rust-lang#42729 (comment)). This PR tries to change all existing ` ```ignore ` tests into one of the following:

* Add import and declarations to ensure the code is run-pass
* If the code is not Rust, change to ` ```text `/` ```sh `/` ```json `/` ```dot `
* If the code is expected compile-fail, change to ` ```compile_fail `
* If the code is expected run-fail, change to ` ```should_panic `
* If the code can type-check but cannot link/run, change to ` ```no_run `
* Otherwise, add an explanation after the ` ```ignore `

The `--explain` handling is changed to cope with hidden lines from the error index.

Tidy is changed to reject any unexplained ` ```ignore ` and ` ```rust,ignore `.
@Mark-Simulacrum
Copy link
Member

@bors r-

tidy check (x86_64-pc-windows-msvc)
tidy error: C:\projects\rust\src\librustc_typeck\diagnostics.rs:4443: unexplained "```ignore" doctest; try one:
* make the test actually pass, by adding necessary imports and declarations, or
* use "```text", if the code is not Rust code, or
* use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
* use "```should_panic", if the code is expected to fail at run time, or
* use "```no_run", if the code should type-check but not necessary linkable/runnable, or
* explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
tidy error: C:\projects\rust\src\librustc_typeck\diagnostics.rs:4450: unexplained "```ignore" doctest; try one:
* make the test actually pass, by adding necessary imports and declarations, or
* use "```text", if the code is not Rust code, or
* use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
* use "```should_panic", if the code is expected to fail at run time, or
* use "```no_run", if the code should type-check but not necessary linkable/runnable, or
* explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
some tidy checks failed

@bors
Copy link
Contributor

bors commented Jun 23, 2017

☀️ Test successful - status-travis
State: approved= try=False

Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.

Remaining "```ignore"s received an explanation why they are being ignored.
@kennytm
Copy link
Member Author

kennytm commented Jun 23, 2017

@Mark-Simulacrum Rebased to remove the two ```ignore from E0615.

@Mark-Simulacrum
Copy link
Member

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jun 23, 2017

📌 Commit 9addd3b has been approved by estebank

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 23, 2017
…bank

Remove most "```ignore" doc tests.

Unconditional ` ```ignore ` doc tests lead to outdated examples (e.g. rust-lang#42729 (comment)). This PR tries to change all existing ` ```ignore ` tests into one of the following:

* Add import and declarations to ensure the code is run-pass
* If the code is not Rust, change to ` ```text `/` ```sh `/` ```json `/` ```dot `
* If the code is expected compile-fail, change to ` ```compile_fail `
* If the code is expected run-fail, change to ` ```should_panic `
* If the code can type-check but cannot link/run, change to ` ```no_run `
* Otherwise, add an explanation after the ` ```ignore `

The `--explain` handling is changed to cope with hidden lines from the error index.

Tidy is changed to reject any unexplained ` ```ignore ` and ` ```rust,ignore `.
bors added a commit that referenced this pull request Jun 23, 2017
Rollup of 8 pull requests

- Successful merges: #42777, #42783, #42787, #42821, #42822, #42825, #42829, #42833
- Failed merges:
@bors bors merged commit 9addd3b into rust-lang:master Jun 23, 2017
@kennytm kennytm deleted the kill-ignore-doctest branch June 26, 2017 15:24
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.

8 participants