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

Remove unstable cfg target(...) compact feature #130780

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

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Sep 24, 2024

This PR removes the unstable cfg_target_compact feature from #96901, which permits compact target(...) cfgs (e.g. cfg(target(os = "linux")) -> cfg(target_os = "linux")).

The feature:

  • is only used in one crate: GitHub Search (not even in the compiler)
  • has received no activity on the tracking issue
  • has not received any stabilization request since it's nightly introduction (~2yrs ago)
  • was part of a bigger feature that was already withdrawn
  • is limited to target_* cfgs
  • is not implemented by Cargo (and rustdoc doc_cfg feature)
  • it's only useful when one has multiple target_* cfgs consecutively
    as it will only save you the "target_" part on the second cfg
  • one still need to do the mapping it's in head, not saving much
    target(os = "linux", env = "") means target_os = "linux", target_env = "" in every other place

All this to say that I don't think the feature pulls its weight.

@rustbot label +I-lang-nominated
Closes #96901

@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2024

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
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. I-lang-nominated Nominated for discussion during a lang team meeting. labels Sep 24, 2024
@lqd
Copy link
Member

lqd commented Sep 24, 2024

Wasn’t this helping to remove some use cases for build scripts?

@Urgau
Copy link
Member Author

Urgau commented Sep 24, 2024

The part that was supposed to help with build script was the cfg(target = "...") part of the RFC, but that part was already withdrawn.

@lqd
Copy link
Member

lqd commented Sep 24, 2024

IIRC the target abi was only matchable in build scripts, is that still the case today (with and without this PR)? To be able to lower the need for build scripts in the ecosystem we need cfgs to be at least isomorphic…

@Urgau
Copy link
Member Author

Urgau commented Sep 24, 2024

This PR doesn't change anything for matching on specific target cfgs components. This PR only removes the shorthand cfg(target(os = "linux")) -> cfg(target_os = "linux").

As for the target abi, the target_abi cfg was stabilized in 1.78.

@lqd
Copy link
Member

lqd commented Sep 24, 2024

Good. Thank you for the clarifications.

@bors

This comment was marked as resolved.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch 2 times, most recently from 79578af to 9832308 Compare October 5, 2024 07:56
@bors

This comment was marked as resolved.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from 9832308 to 1de1d84 Compare October 7, 2024 12:50
@bors

This comment was marked as resolved.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from 1de1d84 to 1f2c377 Compare October 16, 2024 15:38
@bors

This comment was marked as resolved.

@BoxyUwU BoxyUwU added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2024
@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from 1f2c377 to 7c50b97 Compare October 27, 2024 16:30
@bors

This comment was marked as resolved.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from 7c50b97 to 2cdde6a Compare December 17, 2024 22:39
@bors

This comment was marked as resolved.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from 2cdde6a to c6b25b3 Compare January 3, 2025 15:37
@bors

This comment was marked as resolved.

@BoxyUwU BoxyUwU added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 26, 2025
@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from c6b25b3 to f047624 Compare January 26, 2025 11:51
@rust-log-analyzer

This comment has been minimized.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from f047624 to 4475a8e Compare January 26, 2025 12:44
@bors

This comment was marked as resolved.

@Urgau Urgau force-pushed the withdrawn-cfg-target-compact branch from 4475a8e to dd3f8ff Compare March 3, 2025 19:16
@rustbot rustbot added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Mar 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 3, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@traviscross
Copy link
Contributor

So, strictly speaking, removing something unstable from the compiler doesn't need our lang OK. If compiler wants to say, "we're not happy with the implementation, we're going to pull it out until someone tries again", or "this is in the way, and it's not on track to be stabilized soon, so we're going to pull it out", then that can just be done, though we appreciate a heads-up and CC on it, especially if it's in the critical path of something on our radar.

On this one though, I do read it as a lang request. (This is what I think you had in mind also; I'm saying this all for the benefit of others.) The implementation seems fine, and it's not a lot of code, and it doesn't seem in the way of anything. So it's basically just a prompt to ask the lang question of whether this is something we still want or not.

In that light, this is nominated, and we'll try to get to it (no promises on timing), but also, let's ping everyone and maybe we'll collect some thoughts.

@rust-lang/lang: What do we think? Do we still want #[cfg(target(..))]?

@joshtriplett
Copy link
Member

I mildly appreciated the idea of the target shorthand syntax. I think it's not useful to count occurrences in code search, because (like most convenience features) nobody is going to use nightly just for a convenience feature; people will wait for it to be in stable before using it. That said, it's a small feature that provides a small amount of value; it's not going to be earth-shattering, whether it stays or goes. If anyone feels like it doesn't carry enough weight, or if it adds any non-trivial complexity to cfg, by all means let's drop it.

@traviscross
Copy link
Contributor

traviscross commented Mar 7, 2025

Pulling it out drops only 28 lines of entirely plain and boring code. It all seems to come down, I think, to whether or not this is something we want to let people write.

Agreed that use in nightly is a poor metric, especially here. I'd never use this until we had stabilized it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking Issue for RFC 3239: Add target configuration
8 participants