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

terminology: #[feature] *enables* a feature (instead of "declaring" or "activating" it) #131321

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Oct 6, 2024

Mostly, we currently call a feature that has a corresponding #[feature(name)] attribute in the current crate a "declared" feature. I think that is confusing as it does not align with what "declaring" usually means. Furthermore, we also refer to #[stable]/#[unstable] as declaring a feature (e.g. in these diagnostics), which aligns better with what "declaring" usually means. To make things worse, the functions tcx.features().active(...) and tcx.features().declared(...) both exist and they are doing almost the same thing (testing whether a corresponding #[feature(name)] exists) except that active would ICE if the feature is not an unstable lang feature. On top of this, the callback when a feature is activated/declared is called set_enabled, and many comments also talk about "enabling" a feature.

So really, our terminology is just a mess.

I would suggest we use "declaring a feature" for saying that something is/was guarded by a feature (e.g. #[stable]/#[unstable]), and "enabling a feature" for #[feature(name)]. This PR implements that.

@rustbot
Copy link
Collaborator

rustbot commented Oct 6, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
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 A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Oct 6, 2024
@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the feature-activation branch from 8c5bf45 to 2c37795 Compare October 6, 2024 09:55
@rustbot
Copy link
Collaborator

rustbot commented Oct 6, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the feature-activation branch from 2c37795 to 1df170c Compare October 6, 2024 11:31
@est31
Copy link
Member

est31 commented Oct 8, 2024

r? @est31

@bors r+

@bors
Copy link
Contributor

bors commented Oct 8, 2024

📌 Commit 1df170c has been approved by est31

It is now in the queue for this repository.

@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 Oct 8, 2024
@nnethercote
Copy link
Contributor

This is an improvement over "declared", but I was going to suggest enable/enabled over activate/active. Several of the existing comments already used enable/enabled.

@RalfJung
Copy link
Member Author

RalfJung commented Oct 8, 2024

Hm... both "active" and "enabled" are used then, it seems.

@rust-lang/compiler any preference?

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 8, 2024
@dianne
Copy link
Contributor

dianne commented Oct 8, 2024

If you're looking to make comments use consistent terminology too, the doc comments in rustc_middle/src/middle/stability.rs use yet another term: features being "provided".

@nnethercote
Copy link
Contributor

It's not a perfect analogy, but cargo features are "enabled".

@RalfJung
Copy link
Member Author

RalfJung commented Oct 8, 2024 via email

@RalfJung RalfJung force-pushed the feature-activation branch from 1df170c to 3b7ed10 Compare October 8, 2024 12:07
@rustbot
Copy link
Collaborator

rustbot commented Oct 8, 2024

These commits modify compiler targets.
(See the Target Tier Policy.)

@RalfJung RalfJung changed the title terminology: #[feature] *activates* a feature (instead of "declaring" it) terminology: #[feature] *enables* a feature (instead of "declaring" or "activating" it) Oct 8, 2024
@RalfJung
Copy link
Member Author

RalfJung commented Oct 8, 2024

I now updated this to "enabling" a feature.

@rustbot ready

@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 Oct 8, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ded5475): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -0.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 775.847s -> 775.025s (-0.11%)
Artifact size: 329.70 MiB -> 329.61 MiB (-0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 9, 2024
@RalfJung
Copy link
Member Author

RalfJung commented Oct 9, 2024

Oh wow, it basically makes no difference. That's surprising. I guess the hash set is usually empty and so checking it is pretty fast, or so?

I can still bring back the bools as private fields if you prefer, to avoid all these hash set tests.

@RalfJung
Copy link
Member Author

RalfJung commented Oct 16, 2024

@nnethercote ehuss is not on the compiler team, so it seems odd to ask them for review here? This is basically entirely an internal compiler change. The term shows up in one error message, but it's not like we super carefully review those.

@ehuss
Copy link
Contributor

ehuss commented Oct 21, 2024

Yea, I have nothing to say here (other than the perf experiment commit will likely cause a lot of conflicts for other PRs). I'll reassign to the original reviewer.

r? @est31

@rustbot rustbot assigned est31 and unassigned ehuss Oct 21, 2024

self.all_features()[..].hash_stable(hcx, hasher);
self.all_lang_features()[..].hash_stable(hcx, hasher);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change from all_features to all_lang_features?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, you renamed the function above.

@nnethercote
Copy link
Contributor

Ok, r=me for the first two commits. I like the idea of the third one -- good to avoid duplicating the data -- but I think it's worth putting that in a separate PR because it touches so many lines.

@nnethercote nnethercote assigned nnethercote and unassigned est31 Oct 22, 2024
@RalfJung
Copy link
Member Author

Okay I will move 6c38ef0 to a separate PR.

@RalfJung
Copy link
Member Author

@bors r=nnethercote

@bors
Copy link
Contributor

bors commented Oct 22, 2024

📌 Commit 1381773 has been approved by nnethercote

It is now in the queue for this repository.

@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 Oct 22, 2024
@bors
Copy link
Contributor

bors commented Oct 22, 2024

⌛ Testing commit 1381773 with merge bca5fde...

@bors
Copy link
Contributor

bors commented Oct 22, 2024

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing bca5fde to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 22, 2024
@bors bors merged commit bca5fde into rust-lang:master Oct 22, 2024
7 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 22, 2024
@RalfJung RalfJung deleted the feature-activation branch October 22, 2024 14:45
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bca5fde): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.1% [-3.1%, -3.1%] 1

Max RSS (memory usage)

Results (secondary -3.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 780.605s -> 781.36s (0.10%)
Artifact size: 333.69 MiB -> 333.62 MiB (-0.02%)

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2024
…=<try>

nightly feature tracking: get rid of the per-feature bool fields

The `struct Features` that tracks which features are enabled has a ton of public `bool`-typed fields that are basically caching the result of looking up the corresponding feature in `enabled_lang_features`. Having public fields with an invariant is not great, so at least they should be made private. However, it turns out caching these lookups is actually [not worth it](rust-lang#131321 (comment)), so this PR just entirely gets rid of these fields. (The alternative would be to make them private and have a method for each of them to expose them in a read-only way. Most of the diff of this PR would be the same in that case.)

r? `@nnethercote`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 23, 2024
…=nnethercote

nightly feature tracking: get rid of the per-feature bool fields

The `struct Features` that tracks which features are enabled has a ton of public `bool`-typed fields that are basically caching the result of looking up the corresponding feature in `enabled_lang_features`. Having public fields with an invariant is not great, so at least they should be made private. However, it turns out caching these lookups is actually [not worth it](rust-lang#131321 (comment)), so this PR just entirely gets rid of these fields. (The alternative would be to make them private and have a method for each of them to expose them in a read-only way. Most of the diff of this PR would be the same in that case.)

r? `@nnethercote`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 7, 2024
…ercote

terminology: #[feature] *enables* a feature (instead of "declaring" or "activating" it)

Mostly, we currently call a feature that has a corresponding `#[feature(name)]` attribute in the current crate a "declared" feature. I think that is confusing as it does not align with what "declaring" usually means. Furthermore, we *also* refer to `#[stable]`/`#[unstable]` as *declaring* a feature (e.g. in [these diagnostics](https://github.com/rust-lang/rust/blob/f25e5abea229a6b6aa77b45e21cb784e785c6040/compiler/rustc_passes/messages.ftl#L297-L301)), which aligns better with what "declaring" usually means. To make things worse, the functions  `tcx.features().active(...)` and  `tcx.features().declared(...)` both exist and they are doing almost the same thing (testing whether a corresponding `#[feature(name)]`  exists) except that `active` would ICE if the feature is not an unstable lang feature. On top of this, the callback when a feature is activated/declared is called `set_enabled`, and many comments also talk about "enabling" a feature.

So really, our terminology is just a mess.

I would suggest we use "declaring a feature" for saying that something is/was guarded by a feature (e.g. `#[stable]`/`#[unstable]`), and "enabling a feature" for  `#[feature(name)]`. This PR implements that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. 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.

9 participants