-
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
Miri: unleash all feature gates #71631
Conversation
This comment has been minimized.
This comment has been minimized.
55c6530
to
0ab08a9
Compare
The goal of the current behavior is to prevent unnecessary use of Without a diagnostics bug--we were not suggesting that nightly users enable |
Yes, it would have been clearer. But I still think we should not ask for feature gates with unleash-miri. Even if the compiler tells me which feature gate is missing, that's just needless hoops for me to jump through. All it achieves is annoy me as I am crafting the testcase.
I'm not a fan of that kind of nudging -- not when it has harmful effects elsewhere. The way to prevent people from unnecessarily adding the flag is to tell them during review. The flag name is already scary enough to nudge people away from it.
Most (all?) unleash tests that we have should remain unleash even when we get const-checking for those features -- the point of these tests is to check the underlying engine and the dynamic checks, not to check const-qualification. So I don't buy this motivation at well, we typically do not want to remove that flag ever. |
This seems like a difference in values rather than a dispute over the facts. I'd rather have as many tests exercise the const-checker as possible. You would rather not have to think about it while writing The stakes here are pretty low, so I'm fine with any outcome, but I would appreciate it if you avoided |
For those tests, why would you use the flag at all? So when your goal is exercising the const-checker, shouldn't you just not use this flag? |
It's possible for the same test to exercise rare code paths in both the static checks and the dynamic ones. After this PR is merged, it will be possible for you to turn off the const-checker in tests you write (edit: both new and old) even if const-checking could handle them fine. I ask that you don't. |
@ecstatic-morse I don't think I entirely understand which tests you do not want me to modify how -- so I will just make sure to Cc you on every change I make to miri-unleash tests. That way you can make sure I do not accidentally regress test coverage for the static checks. I think maybe you are saying I should not add the miri-unleash flag to existing tests ("turn off the const-checker"). I will make sure to never do that, and instead run the test both with and without miri-unleash, like what we ended up doing in #71604. This was anyway the first time I did that, usually I just wrote new miri-unleash tests from scratch. Does that work for you? |
6c1c529
to
b8efed7
Compare
r? @oli-obk If it were up to me, we wouldn't merge this. Someone else should approve. |
Side note: we can make sure that when a test specifies unleash, it needs to actually unleash anything in order to pass, otherwise we report an additional error about that or just ICE. |
☔ The latest upstream changes (presumably #71707) made this pull request unmergeable. Please resolve the merge conflicts. |
@ecstatic-morse: @oli-obk would like us to form consensus here, and I tend to agree. So let me make another attempt at trying to understand your concern. If I understand you correctly, you are worried that this change will reduce test coverage for the static const-eval checks. I agree that would be bad. However, I am confused about this concern: in my mind, the entire point of the miri-unleash flag is to not run the static const-eval checks. A test that sets this flag is, by definition, not meant to test anything related to the static checks. Thus I fail to understand how any change in the behavior of this flag can have bad effects on test coverage for the static checks. Maybe you have been using this flag differently?
Maybe you could give a concrete example for how one of our existing tests becomes less useful with this change, or how this change might lead to someone accidentally not testing the thing they wanted to test -- or really any example. So far, whlle I understand your concern in the abstract, I fail to understand how it relates to this PR. |
This is particularly confusing to me, as the unleash tests I write are usually tests that will never get accepted by rustc, even when the features all become stable. The point is to write const-unsound code and make sure it gets rejected by the dynamic checks. None of the tests in "miri-unleashed" is meant to exercise the static const-checker; that should all happen in dedicated tests (and I think it does so far, and I don't think this PR is likely to change that). Do we have a single "pass" test with "miri-unleash"? I don't think so, they are all about exercising error paths in the CTFE engine that are otherwise unreachable because the static checks prevent even getting to those failures. |
Or to put my confusion in one sentence: I don't understand how it make sense that miri-unleash disables the static checks that prevent non- I am curious to understand why you think this makes sense. |
b8efed7
to
c7eb916
Compare
This is the thing I want to enforce. The goal is to prevent you or (more importantly) others from using
I'm a fan of nudging. I'm sorry that you ran into a bad diagnostic, but I don't think the current behavior is "harmful". If you had encountered a scenario that couldn't be resolved just by adding a feature gate, it would be much easier to understand your desire to remove this. The automated check is currently accomplishing the goal I stated above, and I believe that things that can be automated should be: There's no need to rely on the review process. |
So, what about making |
9c218a6
to
b430a73
Compare
Okay I pushed my latest proposal: this is effectively a This lets me write tests that fail in CTFE without worrying about static checks (they fail anyway, so the |
|
||
if is_unleashable && self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { | ||
self.tcx.sess.span_warn(span, "skipping const checks"); | ||
self.tcx.sess.span_warn(self.tcx.def_span(self.def_id), "skipping const checks"); |
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.
side note: what do you think about emitting the feature name that is being skipped if there is one?
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.
Sure... or maybe not even emit the warning in that case? Either there will be other errors or a panic at the end listing the missing gates.
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 think emitting them is good, as it shows where things are being skipped. I mean, I added them on purpose so we'd be able so see exactly where a test is skipping checks, in order to notice when the checks change in any way
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.
Otherwise I'm worried this will kill deduplication, so we'll have 5 annotations per const again.
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.
in order to notice when the checks change in any way
The point of the flag is to not worry about the static checks, and focus on testing the underlying engine. Why would I care if the checks change? I explicitly do not want to care about that, that's why I use the flag.^^
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 thought we agreed in your PR that this is not the right kind of error, and instead we should error when unleashing any feature gate (like my PR does now)?
Sorry, we've went back and forth too many times. You're right.
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 guess I don't know what "labels" vs "spans" are...
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.DiagnosticBuilder.html#method.span_label allows you to add an arbitrary annotation to an arbitrary span. This is what gives us the ^^^^^ something here
annotations.
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.
Hm... I did that, but it doesn't print the labels.
let mut diag = self.struct_warn("skipping const checks");
for &(span, feature_gate) in unleashed_features.iter() {
if let Some(feature_gate) = feature_gate {
diag.span_label(span, format!("skipping check for `{}` feature", feature_gate));
} else {
diag.span_label(span, "skipping check that does not even have a feature gate");
}
}
diag.emit();
becomes just
warning: skipping const checks
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 tried passing a proper span to struct_warn
, no luck.
Our diagnostics APIs are quite hard to use correctly, it seems. :/
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 went for span_help
now, that seems to work. It's quite the hack though...
b430a73
to
08ba014
Compare
This comment has been minimized.
This comment has been minimized.
@@ -1,5 +1,5 @@ | |||
// compile-flags: -Zunleash-the-miri-inside-of-you | |||
#![feature(const_mut_refs, box_syntax)] | |||
// compile-flags: -Zunleash-the-miri-inside-of-you -Zdeduplicate-diagnostics |
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 deduplication isn't necessary anymore, right? (same for the others)
1967dd4
to
1c119f6
Compare
1c119f6
to
a909c03
Compare
@bors r+ |
📌 Commit 182133f has been approved by |
☀️ Test successful - checks-azure |
//~^ skipping const checks | ||
//~| it is undefined behavior to use this value | ||
//~^ ERROR it is undefined behavior to use this value | ||
//~| NOTE encountered a reference pointing to a static variable |
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.
Another curious thing about diagnostic UI tests: looks like NOTE
annotations match what the rustc API calls "labels". Do they also match what the rustc API calls "note"?
IMO it is silly to unleash features that do not even have a feature gate yet, but not unleash features that do. The only thing this achieves is making unleashed mode annoying to use as we have to figure out the feature flags to enable (and not always do the error messages say what that flag is).
Given that the point of
-Z unleash-the-miri-inside-of-you
is to debug the Miri internals, I see no good reason for this extra hurdle. I cannot imagine a situation where we'd use that flag, realize the program also requires some feature gate, and then be like "oh I guess if this feature is unstable I will do something else". Instead, we'll always just add that flag to the code as well, so requiring the flag achieves nothing.r? @oli-obk @ecstatic-morse
Fixes #71630