-
Notifications
You must be signed in to change notification settings - Fork 13.8k
simplify check_cfg_arg impl #147570
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
base: master
Are you sure you want to change the base?
simplify check_cfg_arg impl #147570
Conversation
Some changes occurred in cfg and check-cfg configuration cc @Urgau |
rustbot has assigned @Mark-Simulacrum. Use |
This comment has been minimized.
This comment has been minimized.
r? Urgau |
90bd404
to
33fa88d
Compare
This comment has been minimized.
This comment has been minimized.
33fa88d
to
78cacb9
Compare
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.
Going from a
pub fn check_cfg_arg(name: &str, values: &[&str]) -> String { | ||
if values.is_empty() { | ||
format!("--check-cfg=cfg({name})") | ||
} else { | ||
format!("--check-cfg=cfg({name},values(\"{}\"))", values.join("\",\"")) | ||
} | ||
} |
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 technically correct, having an empty values()
is valid and has the semantic of defining a cfg that has no expected values (and thus will always warn).
But it doesn't really make sense for bootstrap to be defining such cfgs.
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 read about this, but it seems really weird that values()
makes the cfg name unusable(?) and what accepts an empty value is values(none())
.
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, &[&str])] = &[ | ||
(Some(Mode::Rustc), "bootstrap", &[]), | ||
(Some(Mode::Codegen), "bootstrap", &[]), | ||
(Some(Mode::ToolRustcPrivate), "bootstrap", &[]), | ||
(Some(Mode::ToolStd), "bootstrap", &[]), | ||
(Some(Mode::ToolRustcPrivate), "rust_analyzer", &[]), | ||
(Some(Mode::ToolStd), "rust_analyzer", &[]), |
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.
What do you think about having &[Option<&str>]
for representing the expected values? which would make the none()
part explicit.
The generation part would then always be like that cfg(name, values(...))
.
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.
That would allow &[None, None, None]
which seems silly...
No description provided.