-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Don't allow #[should_panic] with non-() tests #49911
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Your PR failed on Travis (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.
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 |
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.
Looks pretty good at first glance!
@@ -26,6 +26,7 @@ fn is_a_num() -> Result<(), ParseIntError> { | |||
#[test] | |||
#[should_panic] | |||
fn not_a_num() -> Result<(), ParseIntError> { | |||
//~^ ERROR test functions returning Result<_, _> must not use #[should_panic] |
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.
This test livs in the run-pass
directory -- that means it must compile. Can you copy the test into ui/rfc-1937-termination-trait/
, and break it into two files? One of them can include the is_a_num
test (and the comment // run-pass
). The other includes the not_a_num
test (with the //~ ERROR
). That way, we test that the first test compiles and runs, and that the second fails to compile. There is discussion about ui tests in the rustc-guide: https://rust-lang-nursery.github.io/rustc-guide/tests/adding.html#ui
Oh, I see that travis is also upset about some overly long lines. |
Your PR failed on Travis (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.
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 |
Cool. On the plus side the build failed because my change actually worked :-) Once my local rust install finally compiles enough to run the tests I'll finish it up. What's the plan re: |
@nikomatsakis updated with feedback and build passing |
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.
Looks great, one nit
src/libsyntax/test.rs
Outdated
diag.span_err(i.span, "functions used as tests can not have any arguments"), | ||
BadTestSignature::ShouldPanicOnlyWithNoArgs => | ||
diag.span_err(i.span, | ||
"functions used as tests returning Result<_, _> must \ |
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.
Let's phrase this differently; the test may not actually be returning Result
, but rather any Termination
type. How about:
functions using `#[should_panic]` must return `()`
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.
I like that better, changing.
Updated @nikomatsakis (btw, please let me know if this is the desired way of indicating that it's ready for review again. I'm not sure if there is an incantation to swap the label back to |
Ping from triage! Can @nikomatsakis (or someone else from @rust-lang/compiler) review this? |
@rcoh can you squash all the commits into one (and give that commit a meaningful message like the PR topic?) |
@oli-obk squashed |
@bors r=nikomatsakis |
📌 Commit 14e5e0e has been approved by |
Don't allow #[should_panic] with non-() tests Adds (removes) support for `#[should_panic]` when the test is non-`()`
☀️ Test successful - status-appveyor, status-travis |
Adds (removes) support for
#[should_panic]
when the test is non-()