-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 target_feature 1.1 should print the list of missing target features #109710
Fix target_feature 1.1 should print the list of missing target features #109710
Conversation
r? @oli-obk (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
@est31 Already created the PR. |
This comment has been minimized.
This comment has been minimized.
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 looks really great already, you will also need to bless the tests whose output has been changed by this PR. I offer you to help with this as you said you have M1 hardware which makes it hard to work on x86 specific tests: i can file a PR to your PR once it is ready in the other components.
☔ The latest upstream changes (presumably #109734) made this pull request unmergeable. Please resolve the merge conflicts. |
d4ad06c
to
3260f5c
Compare
This comment has been minimized.
This comment has been minimized.
3260f5c
to
4270524
Compare
This comment has been minimized.
This comment has been minimized.
4270524
to
d7a8af4
Compare
This comment has been minimized.
This comment has been minimized.
@estebank What should we do for the test outputs in another architectures? |
LGTM except for the test issue 👍 |
This comment has been minimized.
This comment has been minimized.
50d411d
to
63dc009
Compare
This comment has been minimized.
This comment has been minimized.
63dc009
to
fbc38d2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
802c173
to
004b5e0
Compare
This comment has been minimized.
This comment has been minimized.
004b5e0
to
ae93226
Compare
ae93226
to
73fd02f
Compare
@rustbot label -S-waiting-on-author +S-waiting-on-review |
@@ -91,15 +162,15 @@ impl UnsafetyViolationDetails { | |||
"references to fields of layout constrained fields lose the constraints. Coupled \ | |||
with interior mutability, the field can be changed to invalid values", | |||
), | |||
CallToFunctionWith => ( | |||
CallToFunctionWith { missing_features: _, target_features: _ } => ( |
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.
You can use { .. }
here, this holds true for the other occurrences of this pattern in the last commit as well.
} | ||
} | ||
|
||
fn target_features(&self) -> Vec<Symbol> { |
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 should return Option<Vec<Symbol>>
here instead of an empty vector. Then in the note_missing_features
function, you don't need to check is_empty
any more but can directly use self.target_features()?
.
} | ||
|
||
impl UnsafetyViolationDetails { | ||
fn missing_features(&self) -> Vec<Symbol> { |
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.
Same here, missing_features
should return an Option<Vec<Symbol>>
instead.
diag.help(help); | ||
} | ||
|
||
match self.details.violation { |
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 outer match is not needed here, you can just collapse it to a single if let
. If it's None, you just do what you do in the _
arm.
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 was the old code
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's still part of the diff though? Maybe you haven't added these changes to git yet?
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.
Ohh you meant what I am asking you to do reflects the older state of a PR, and you were asked to change it? I don't think so, but please correct me if I'm wrong. The older state also had a match, just no if let inside. Now you are doing both. Ideally you'd just have an if let, like:
if let Some(note_missing_features) = self.details.violation.note_missing_features() {
diag.note(note_missing_features);
} else {
diag.note(self.details.clone().note());
}
The note_missing_features
function will already return None
if it's not a CallToFunctionWith
, we just use this fact here.
My demand is more or less the same thing I asked about in march: #109710 (comment)
If you need more clarifications, please ask!
op_in_unsafe_fn_allowed, | ||
help: details.help_missing_features(), | ||
note_missing_features: details.note_missing_features(), |
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.
You don't need to store this any more, you can just call note_missing_features()
where you'd be using the note_missing_features
field. Same goes for the help
field.
if let Some(help) = self.help { | ||
diag.help(help); | ||
} | ||
match self.details.violation { |
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.
Same holds here, this can be collapsed into a single if let Some(note_missing_features) = self.self.details.note_missing_features()
.
diag.set_arg("details", desc); | ||
diag.span_label(self.details.span, self.details.label()); | ||
diag.note(self.details.note()); | ||
diag.span_label(self.details.clone().span, self.details.clone().label()); |
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 you don't need to clone details to obtain the span, just to obtain the label.
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's necessary, if I don't clone it then will be an error here
☔ The latest upstream changes (presumably #112017) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @est31 (feel free to bounce back to me if you prefer) |
This has some still outstanding points and also needs a rebase, @rohaquinlop if you need advice for any of these please write! |
@est31 I'll go back to work on this issue, thanks in advance |
ping from triage - can you post your status on this PR? There hasn't been an update in a few months. Thanks! FYI: when a PR is ready for review, send a message containing |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
…tures, r=est31 Print list of missing target features when calling a function with target features outside an unsafe block Fixes rust-lang#108680 Supersedes rust-lang#109710. I used the same wording for the messages, but the implementation is different. r? `@est31`
…tures, r=est31 Print list of missing target features when calling a function with target features outside an unsafe block Fixes rust-lang#108680 Supersedes rust-lang#109710. I used the same wording for the messages, but the implementation is different. r? ``@est31``
…tures, r=est31 Print list of missing target features when calling a function with target features outside an unsafe block Fixes rust-lang#108680 Supersedes rust-lang#109710. I used the same wording for the messages, but the implementation is different. r? `@est31`
Rollup merge of rust-lang#118333 - eduardosm:print-missing-target-features, r=est31 Print list of missing target features when calling a function with target features outside an unsafe block Fixes rust-lang#108680 Supersedes rust-lang#109710. I used the same wording for the messages, but the implementation is different. r? `@est31`
Fixed #108680
According to the issue description implemented the note and help description. Removed the note in the general case.