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

Target modifiers fix for bool flags without value #138483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

azhogin
Copy link
Contributor

@azhogin azhogin commented Mar 14, 2025

Fixed support of boolean flags without values: -Zbool-flag is now consistent with -Zbool-flag=true in another crate.

When flag is explicitly set to default value, target modifier will not be set in crate metainfo (-Zflag=false when false is a default value for the flag).

Improved error notification when target modifier flag is absent in a crate ("-Zflag unset").
Example:

note: `-Zreg-struct-return=true` in this crate is incompatible with unset `-Zreg-struct-return` in dependency `default_reg_struct_return`

@rustbot
Copy link
Collaborator

rustbot commented Mar 14, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 14, 2025
@rust-log-analyzer

This comment has been minimized.

@azhogin azhogin force-pushed the azhogin/target-modifiers-bool-fix branch from 908d92f to 080cbc2 Compare March 14, 2025 08:17
| ^
|
= help: the `-Zreg-struct-return` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
= note: `-Zreg-struct-return unset` in this crate is incompatible with `-Zreg-struct-return=true` in dependency `enabled_reg_struct_return`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem correct (unset in the backticks?), plus the string is untranslatable. I'd suggest adding a variant to the strings that explicitly says "unset" and use that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added messages for cases when current crate has unset flag and when external crate has unset flag.

{
target_modifiers.insert(tmod, value.to_string());
if let Some(tmod) = *tmod {
let v = if let Some(v) = value { v.to_string() } else { String::new() };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would value.map_or_default(ToOwned::to_owned) work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to map_or(...), looks like map_or_default is not yet merged for Option.

= note: `-Zreg-struct-return=true` in this crate is incompatible with `-Zreg-struct-return=` in dependency `default_reg_struct_return`
= help: set `-Zreg-struct-return=` in this crate or `-Zreg-struct-return=true` in `default_reg_struct_return`
= note: `-Zreg-struct-return=true` in this crate is incompatible with `-Zreg-struct-return unset` in dependency `default_reg_struct_return`
= help: set `-Zreg-struct-return unset` in this crate or `-Zreg-struct-return=true` in `default_reg_struct_return`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this diagnostic is poor. it should be something like

Suggested change
= help: set `-Zreg-struct-return unset` in this crate or `-Zreg-struct-return=true` in `default_reg_struct_return`
= help: unset `-Zreg-struct-return` in this crate or set `-Zreg-struct-return=true` in `default_reg_struct_return`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@rustbot rustbot 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 Mar 15, 2025
@azhogin azhogin force-pushed the azhogin/target-modifiers-bool-fix branch from 080cbc2 to 6ccaea1 Compare March 17, 2025 05:49
@azhogin
Copy link
Contributor Author

azhogin commented Mar 18, 2025

@rustbot 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 Mar 18, 2025
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fee1-dead
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 24, 2025

📌 Commit 6ccaea1 has been approved by fee1-dead

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Mar 24, 2025

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants