-
Notifications
You must be signed in to change notification settings - Fork 13k
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
fix const index feature-gate regression #30202
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Aatch (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. |
@@ -11,7 +11,7 @@ | |||
#![deny(exceeding_bitshifts)] | |||
#![allow(unused_variables)] | |||
#![allow(dead_code)] | |||
#![feature(num_bits_bytes)] | |||
#![feature(num_bits_bytes, const_indexing)] |
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.
Oh, interesting ... am I right in inferring that this program will compile successfully (and the error occurs at runtime, assuming the checks are turned on), if the feature gate is not included here?
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.
(because I thought we had decided that such errors in such contexts should not cause compilation errors, at least not ones that cannot be controlled via lint-style allow/warn/deny switches, but instead should just generate code to panic at runtime?)
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.
The bitshift checks have been errors since before 1.0. I'll investigate if anything assumes they errored in check_const.
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 is not a problem. The "error" is actually the exceeding_bitshifts
lint which is set to deny
here. So it's already behind a lint.
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.
it compiles if the lint is set to allow: https://play.rust-lang.org/?gist=a4a9ec25dbc49a18f272&version=nightly
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.
Hmm. Sorry, I was not clear about what I was saying.
I was worried about the fact that you added the feature gate opt-in, since this very bug (that this PR is addressing) is about the fact that people shouldn't have to add this feature gate to get this code to work.
But it seems like you are saying that you need the feature gate there in order to see the compile-time error on just the line that you added, and without the feature gate, there would be no compile-time error -- i.e. the lint wouldn't detect the excessive bitshift at compile-time.
I would have preferred such a subtle issue be broken out into a separate test. But its not worth blocking the PR at this point.
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.
so a run-fail test that does the same as this file just without the feature gate? I think there's a bitshift overflow run-fail test. I'll add it there.
If this is in Rust 1.6-beta, the fix should be backported |
(No tag, found a bug report for this PR) |
not in the beta according to playground: http://is.gd/xCYioD |
81358f1
to
baa8ce7
Compare
Looks good to me |
see #29947 (comment) I also added some missing tests
see #29947 (comment)
I also added some missing tests