Skip to content
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

Closed

Conversation

rohaquinlop
Copy link
Contributor

Fixed #108680

According to the issue description implemented the note and help description. Removed the note in the general case.

@rustbot
Copy link
Collaborator

rustbot commented Mar 28, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 28, 2023
@rustbot
Copy link
Collaborator

rustbot commented Mar 28, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rohaquinlop
Copy link
Contributor Author

@est31 Already created the PR.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@est31 est31 left a 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.

compiler/rustc_middle/src/mir/query.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/mir/query.rs Outdated Show resolved Hide resolved
tests/ui/target-feature/issue-108680-1.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Mar 30, 2023

☔ The latest upstream changes (presumably #109734) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_middle/src/mir/query.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/mir/query.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/mir/query.rs Outdated Show resolved Hide resolved
compiler/rustc_mir_transform/src/check_unsafety.rs Outdated Show resolved Hide resolved
compiler/rustc_mir_transform/src/check_unsafety.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

compiler/rustc_mir_transform/src/check_unsafety.rs Outdated Show resolved Hide resolved
compiler/rustc_mir_transform/src/check_unsafety.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@rohaquinlop
Copy link
Contributor Author

@estebank What should we do for the test outputs in another architectures?

@est31
Copy link
Member

est31 commented Apr 16, 2023

LGTM except for the test issue 👍

@rust-log-analyzer

This comment has been minimized.

@rohaquinlop rohaquinlop force-pushed the 108680-target_feature-1.1 branch 2 times, most recently from 50d411d to 63dc009 Compare April 18, 2023 15:18
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rohaquinlop
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 7, 2023
@rohaquinlop rohaquinlop requested a review from oli-obk June 7, 2023 19:44
@@ -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: _ } => (
Copy link
Member

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> {
Copy link
Member

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> {
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Member

@est31 est31 Jun 8, 2023

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(),
Copy link
Member

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 {
Copy link
Member

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());
Copy link
Member

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.

Copy link
Contributor Author

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

@bors
Copy link
Contributor

bors commented Jun 13, 2023

☔ The latest upstream changes (presumably #112017) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 14, 2023

r? @est31 (feel free to bounce back to me if you prefer)

@rustbot rustbot assigned est31 and unassigned oli-obk Jun 14, 2023
@est31 est31 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2023
@est31
Copy link
Member

est31 commented Jul 20, 2023

This has some still outstanding points and also needs a rebase, @rohaquinlop if you need advice for any of these please write!

@rohaquinlop
Copy link
Contributor Author

@est31 I'll go back to work on this issue, thanks in advance

@JohnCSimon
Copy link
Member

@rohaquinlop

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
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

@Dylan-DPC
Copy link
Member

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

@Dylan-DPC Dylan-DPC closed this Oct 21, 2023
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 21, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 29, 2023
…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`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 29, 2023
…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``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 29, 2023
…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`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 29, 2023
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

target_feature 1.1 error should print the list of missing target features
10 participants