-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Adjust design of unit tests with non-() type #49909
Copy link
Copy link
Closed
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Per this comment, we want to alter the design of unit tests with non-
()type. The new design is:#[should_panic]can only be applied to tests with()return type and continues to have the same meaning.Tdefines the error result using theTerminationtrait.Achieving these changes should be relatively straight-forward. Basically the only thing we have to do is to make it an error to apply
#[should_panic]unless the test has(). Currently we check that the test has the correct signature here:rust/src/libsyntax/test.rs
Lines 330 to 355 in 9afed64
In any case, we just have to extend that function to also check whether there is a
should_panicattribute -- if so, we can report an error, sort of like this:rust/src/libsyntax/test.rs
Line 365 in 9afed64