-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
Additional info:
|
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 💯 |
Looks like Travis failed.
|
0712a27
to
524a892
Compare
@Mark-Simulacrum Thanks. Turned this back into |
There was a problem hiding this 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.
src/libcore/ptr.rs
Outdated
/// let val: *const u8 = &10u8 as *const u8; | ||
/// ``` | ||
/// let val = 10u8; | ||
/// let ptr: *const u8 = &val as *const u8; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ```ignore
d because &10u8
would be dropped too early (it was ```ignore
d to avoid introducing a #[feature]
to the example when .as_ref()
was unstable).
src/libcore/ptr.rs
Outdated
/// let val: *mut u8 = &mut 10u8 as *mut u8; | ||
/// ``` | ||
/// let mut val = 10u8; | ||
/// let ptr: *mut u8 = &mut val as *mut u8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estebank Reverted.
src/librustc/diagnostics.rs
Outdated
# use std::ptr; | ||
# let v = Some("value"); | ||
# type SomeType = &'static [u8]; | ||
# unsafe { | ||
ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
src/librustc_borrowck/diagnostics.rs
Outdated
@@ -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! | |||
} |
There was a problem hiding this comment.
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 :-/
There was a problem hiding this comment.
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 | |||
"##, | |||
|
|||
/* |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
524a892
to
7edba12
Compare
@estebank Thanks! All addressed. |
@bors r+ rollup |
📌 Commit 7edba12 has been approved by |
…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 `.
…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 `.
@estebank |
@bors r- |
@bors r+ rollup |
📌 Commit 5dd6538 has been approved by |
@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:
|
5612473
to
513b962
Compare
@bors r- |
@bors r+ |
📌 Commit 513b962 has been approved by |
Canceled try build. |
Wowee. Super cleanup patch @kennytm. |
@bors r+ retry |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 513b962 has been approved by |
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 `.
ah, whatever, I guess try actually has to pass for bors to be happy.. @bors r=estebank |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 513b962 has been approved by |
…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 r-
|
☀️ Test successful - status-travis |
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.
513b962
to
9addd3b
Compare
@Mark-Simulacrum Rebased to remove the two |
@bors r=estebank |
📌 Commit 9addd3b has been approved by |
…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 `.
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:```text
/```sh
/```json
/```dot
```compile_fail
```should_panic
```no_run
```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
.