-
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
audit: ensure every gated feature has a compile-fail test #22820
Comments
(but hey, if other people want to add such missing tests in the meantime, while I am asleep, I will not mind. :) |
…atures. Namely: * `quote` * `link_args` * `link_llvm_intrinsics` * `thread_local` * `unsafe_destructor` Also updates test for `plugin_registrar` to make it clear that it is only testing the `plugin_registrar` feature gate. Cc rust-lang#22820.
In case its not clear: If you want to help, just find a case above that does not have a check-mark and also does not have a pull request number attached beneath it. (And I guess write your name so that other people do not waste time adding a test for the same feature gate). |
…-gates, r=alexcrichton Add tests checking that a number of feature gates are gating their features Namely: * `quote` * `link_args` * `link_llvm_intrinsics` * `thread_local` * `unsafe_destructor` Also updates test for `plugin_registrar` to make it clear that it is only testing the `plugin_registrar` feature gate. Cc rust-lang#22820. (Latter is not fixed, since there are still a bunch more feature-gates that need tests. But I wanted to stop here and move on to something else.)
…eatures. Namely: * `box_syntax` * `box_patterns` * `simd_ffi` * `macro_reexport` cc rust-lang#22820
…s1, r=alexcrichton ...ures. Namely: * `box_syntax` * `box_patterns` * `simd_ffi` * `macro_reexport` cc rust-lang#22820
…s1, r=alexcrichton ...ures. Namely: * `box_syntax` * `box_patterns` * `simd_ffi` * `macro_reexport` cc rust-lang#22820
The test for |
I am not surprised that I "overlooked" that ... the expected error message prefix does not say anything about a feature gate. Let me just confirm that the whole message does ... Update: Okay, the help output for that test (custom_attribute.rs) does mention the feature gate:
So I have now checked off that box, though I wonder if I should add this help message to the expected test output there. |
I was wondering the same thing about the help message. It is not very clear what that From reading #23974 some help messages were removed, would there be any concern for adding help messages to the expected test output in this case? It could be worth adding a comment in there similar to the other gated tests:
In addition, would it be worth going as far as to rename |
In relation to the feature gate list above I'm going to start off by looking into the following: update: removed items that had tests, and added
|
I've done a pass through of the unchecked feature gates and have found tests for the following:
@pnkfelix Could these be marked as complete? |
@Lstat thanks! |
Ok, so I've had a look through everything, here's my findings: @pnkfelix I have some questions below for the three outstanding feature gates (at the very bottom of this comment) and was wondering if you could help confirm the status of those feature gate tests? My previous comment listed feature gates that had existing tests. I've since found a few more to add to that list. Here is the full list of feature gates with existing tests. New findings are in bold:
The following feature gates were removed after this issue was initially created. Since they are no longer around they can be considered complete or crossed out of the task list above:
The following feature gates appear to have duplicate tests introduced in #23578, the initial tests were added in #20723 and #21233:
The following are not in the above task list as they have been added since the issue was initially created:
The following are remaining feature gates needing tests (excluding the feature gates I had questions for, see below). I'm cooking up a PR for these:
The following items are ones that I had trouble completing because I have questions and need some feedback:
The In addition, it seems that there is no way to trigger this code path unless there is a bug in a library or the compiler itself. Are the tests in missing-stability.rs enough to consider
These appear to be the tests we're looking for relating to
This appears to be the Should we reinstate the test in this issue or let it be handled by #19624 which is in the works? |
As part of the audit for rust-lang#22820 the following duplicate feature gate tests were removed: * `box_patterns` * `simd_ffi` These tests for `box_patterns` and `simd_ffi` were added in rust-lang#23578, however there were existing tests in rust-lang#20723 and rust-lang#21233 respectively. r? @nrc
As part of the audit for rust-lang#22820 the following duplicate feature gate tests were removed: * `box_patterns` * `simd_ffi` These tests for `box_patterns` and `simd_ffi` were added in rust-lang#23578, however there were existing tests in rust-lang#20723 and rust-lang#21233 respectively. r? @nrc
As part of the audit for rust-lang#22820 the following feature gate tests have been added: * `negate_unsigned` * `on_unimplemented` * `optin_builtin_traits` * `plugin` * `rustc_attrs` * `rustc_diagnostic_macros` * `slice_patterns` In addition some feature gate error message typos fixed.
As part of the audit for rust-lang#22820 the following duplicate feature gate tests were removed: * `box_patterns` * `simd_ffi` These tests for `box_patterns` and `simd_ffi` were added in rust-lang#23578, however there were existing tests in rust-lang#20723 and rust-lang#21233 respectively. r? @nrc
For visible_private_types, i found src/test/run-pass/visible-private-types-feature-gate.rs |
There appear to be a lot of new unstable features since this was touched. It seems hopeless to ever catch up on this issue without an automatic tidy script verifying the tests exist. @pnkfelix do you want this issue to continue? Should we try to augment tidy to check the existence of compile-fail tests mentioning unstable features? |
@brson I agree that it seems like we'll never be able to close this without having some sort of automation (e.g. a tidy script, as you say) to verify that the tests exist. I don't have any immediate idea about the best way to write such a script. I guess it could just be based on some naming convention for the test itself; i.e. it would be just a heuristic check, not a true verification of it. |
I think it could be written like so: after featureck, search everything in |
@brson but requiring the test to explicitly deny the feature defeats the point, doesn't it? That is, the goal here is to catch code that makes use of a feature without explicitly opting into that feature. .. Though I suppose you might be thinking that if there is enough infrastructure present to support some kind of deny(feature) attribute, then that is a sign that the necessary gating is in place, regardless of what the default lint settings actually are? |
@pnkfelix Good point. I think yes, I was considering that just confirming that the compiler has code that correctly can deny the feature is good enough, but there is some room for error by making the deny explicit. The As an extension to my previous suggestion, the test runner could take the test case that is annotated to be a 'deny feature' test, run it once with |
Similarly to the above, but to avoid creating another custom test runner. The featureck lint could require that |
Make tidy check for lang gate tests Add gate tests to the checks that tidy performs. Excerpt from the commit message of the main commit: Require compile-fail tests for new lang features Its non trivial to test lang feature gates, and people forget to add such tests. So we extend the features lint of the tidy tool to ensure that all new lang features contain a new compile-fail test. Of course, one could drop this requirement and just grep all tests in run-pass for #![feature(abc)] and then run this test again, removing the mention, requiring that it fails. But this only tests for the existence of a compilation failure. Manual tests ensure that also the correct lines spawn the error, and also test the actual error message. For library features, it makes no sense to require such a test, as here code is used that is generic for all library features. The tidy lint extension now checks the compile-fail test suite for occurences of "gate-test-X" where X is a feature. Alternatively, it also accepts file names with the form "feature-gate-X.rs". If a lang feature is found that has no such check, we emit a tidy error. I've applied the markings to all tests I could find in the test suite. I left a small (20 elements) whitelist of features that right now have no gate test, or where I couldn't find one. Once this PR gets merged, I'd like to close issue #22820 and open a new one on suggestion of @nikomatsakis to track the removal of all elements from that whitelist (already have a draft). Writing such a small test can be a good opportunity for a first contribution, so I won't touch it (let others have the fun xD). cc @brson , @pnkfelix (they both discussed about this in the issue linked above).
With #39059 fixed, maybe this issue can be closed as resolved? |
Thanks @est31 |
I was sloppy when I implemented #22173 and did not include a test. So, surprise, a follow-on commit a few days later broke it.
As self-punishment for neglecting to include a regression test, I am assigning myself the task of reviewing our test suite to make sure that every feature-gate has a test.
Here is a transcribed list of feature gates, based on feature_gate.rs, that I have annotated according to whether the feature is Accepted/Removed (and thus needs no tests), Active/Deprecated but has tests already (marked with an
x
, or Active/Deprecated but has no tests that I saw via a cursory grep/skim.("globs", "1.0.0", Accepted),("macro_rules", "1.0.0", Accepted),("struct_variant", "1.0.0", Accepted),("managed_boxes", "1.0.0", Removed),("phase", "1.0.0", Removed),plugin
gate or theplugin_registrar
gate. From the error message it seems like theplugin_registrar
gate is firing.("default_type_params", "1.0.0", Accepted),("struct_inherit", "1.0.0", Removed),("quad_precision_float", "1.0.0", Removed),("import_shadowing", "1.0.0", Removed),("tuple_indexing", "1.0.0", Accepted),("associated_types", "1.0.0", Accepted),("slicing_syntax", "1.0.0", Accepted),("if_let", "1.0.0", Accepted),("while_let", "1.0.0", Accepted),plugin
gate or theplugin_registrar
gate("issue_5723_bootstrap", "1.0.0", Accepted),("opt_out_copy", "1.0.0", Removed),("test_accepted_feature", "1.0.0", Accepted),("test_removed_feature", "1.0.0", Removed),The text was updated successfully, but these errors were encountered: