Skip to content

Rework target checking for built-in attributes #145085

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

Merged
merged 6 commits into from
Aug 14, 2025

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Aug 8, 2025

This is a refactoring of target checking for built-in attributes.
This PR has the following goals:

  • Only refactor the 80% of the attributes that are simple to target check. More complicated ones like #[repr] will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future.
  • No breaking changes.
    • This part of the codebase is not very well tested though, we can do a crater run if we want to be sure.
    • I've spotted quite a few weird situations (like I don't think an impl block should be deprecated?). We can propose fixing these to in a future PR

Fixes #143780
Fixes #138510

I've split it in commits and left a description on some of the commits to help review.
r? @jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 8, 2025
@JonathanBrouwer JonathanBrouwer force-pushed the target_checking branch 2 times, most recently from 66feb37 to a1c6f2a Compare August 9, 2025 18:02
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review August 9, 2025 19:06
@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 Aug 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Aug 14, 2025

Rebased & fixed the PR. I also specified the targets for the linkage attribute, which is now in master after rebasing. Other than that, no significant changes.
@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 Aug 14, 2025
@jdonszelmann
Copy link
Contributor

@bors r+ p=5

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

📌 Commit 4bb7bf6 has been approved by jdonszelmann

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 Aug 14, 2025
@jdonszelmann
Copy link
Contributor

(prio because a lot of PRs keep making this outdated so I want it to go before the next rollup which inevitably is created. don't put attribute related PRs in the next rollup, it will have conflicts!)

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

⌛ Testing commit 4bb7bf6 with merge 898aff7...

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

☀️ Test successful - checks-actions
Approved by: jdonszelmann
Pushing 898aff7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 14, 2025
@bors bors merged commit 898aff7 into rust-lang:master Aug 14, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 14, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing be00ea1 (parent) -> 898aff7 (this PR)

Test differences

Show 352 test diffs

Stage 1

  • errors::verify_builtin_macros_cfg_select_no_matches_83: [missing] -> pass (J0)
  • errors::verify_builtin_macros_expected_other_82: [missing] -> pass (J0)
  • errors::verify_passes_abi_invalid_attribute_126: pass -> [missing] (J0)
  • errors::verify_passes_abi_invalid_attribute_94: [missing] -> pass (J0)
  • errors::verify_passes_abi_ne_125: pass -> [missing] (J0)
  • errors::verify_passes_abi_of_124: pass -> [missing] (J0)
  • errors::verify_passes_align_attr_application_178: pass -> [missing] (J0)
  • errors::verify_passes_align_on_fields_75: pass -> [missing] (J0)
  • errors::verify_passes_attr_application_enum_106: [missing] -> pass (J0)
  • errors::verify_passes_attr_application_enum_139: pass -> [missing] (J0)
  • errors::verify_passes_attr_only_in_functions_98: [missing] -> pass (J0)
  • errors::verify_passes_cold_61: pass -> [missing] (J0)
  • errors::verify_passes_collapse_debuginfo_107: pass -> [missing] (J0)
  • errors::verify_passes_debug_visualizer_invalid_60: [missing] -> pass (J0)
  • errors::verify_passes_deprecated_annotation_has_no_effect_76: [missing] -> pass (J0)
  • errors::verify_passes_deprecated_attribute_144: pass -> [missing] (J0)
  • errors::verify_passes_doc_alias_bad_char_16: [missing] -> pass (J0)
  • errors::verify_passes_doc_alias_duplicated_29: pass -> [missing] (J0)
  • errors::verify_passes_doc_alias_malformed_31: pass -> [missing] (J0)
  • errors::verify_passes_doc_alias_start_end_26: pass -> [missing] (J0)
  • errors::verify_passes_doc_attr_not_crate_level_42: pass -> [missing] (J0)
  • errors::verify_passes_doc_cfg_hide_takes_list_46: pass -> [missing] (J0)
  • errors::verify_passes_doc_inline_conflict_29: [missing] -> pass (J0)
  • errors::verify_passes_doc_invalid_52: pass -> [missing] (J0)
  • errors::verify_passes_doc_keyword_not_mod_25: [missing] -> pass (J0)
  • errors::verify_passes_doc_keyword_not_mod_34: pass -> [missing] (J0)
  • errors::verify_passes_doc_keyword_only_impl_27: [missing] -> pass (J0)
  • errors::verify_passes_doc_masked_not_extern_crate_self_32: [missing] -> pass (J0)
  • errors::verify_passes_doc_test_literal_44: pass -> [missing] (J0)
  • errors::verify_passes_doc_test_unknown_43: pass -> [missing] (J0)
  • errors::verify_passes_doc_test_unknown_any_47: pass -> [missing] (J0)
  • errors::verify_passes_doc_test_unknown_passes_49: pass -> [missing] (J0)
  • errors::verify_passes_doc_test_unknown_plugins_41: [missing] -> pass (J0)
  • errors::verify_passes_duplicate_feature_err_121: [missing] -> pass (J0)
  • errors::verify_passes_duplicate_feature_err_154: pass -> [missing] (J0)
  • errors::verify_passes_export_name_65: pass -> [missing] (J0)
  • errors::verify_passes_feature_previously_declared_97: [missing] -> pass (J0)
  • errors::verify_passes_feature_stable_twice_96: [missing] -> pass (J0)
  • errors::verify_passes_has_incoherent_inherent_impl_44: [missing] -> pass (J0)
  • errors::verify_passes_implied_feature_not_exist_120: [missing] -> pass (J0)
  • errors::verify_passes_implied_feature_not_exist_153: pass -> [missing] (J0)
  • errors::verify_passes_incorrect_target_101: [missing] -> pass (J0)
  • errors::verify_passes_ineffective_unstable_impl_164: pass -> [missing] (J0)
  • errors::verify_passes_inline_ignored_for_exported_137: pass -> [missing] (J0)
  • errors::verify_passes_invalid_macro_export_arguments_67: [missing] -> pass (J0)
  • errors::verify_passes_lang_item_fn_with_track_caller_113: pass -> [missing] (J0)
  • errors::verify_passes_lang_item_on_incorrect_target_83: [missing] -> pass (J0)
  • errors::verify_passes_layout_abi_86: [missing] -> pass (J0)
  • errors::verify_passes_layout_homogeneous_aggregate_121: pass -> [missing] (J0)
  • errors::verify_passes_layout_invalid_attribute_123: pass -> [missing] (J0)
  • errors::verify_passes_layout_of_90: [missing] -> pass (J0)
  • errors::verify_passes_layout_size_120: pass -> [missing] (J0)
  • errors::verify_passes_link_48: [missing] -> pass (J0)
  • errors::verify_passes_link_section_72: pass -> [missing] (J0)
  • errors::verify_passes_linkage_93: pass -> [missing] (J0)
  • errors::verify_passes_may_dangle_102: pass -> [missing] (J0)
  • errors::verify_passes_missing_const_err_122: [missing] -> pass (J0)
  • errors::verify_passes_missing_lang_item_80: [missing] -> pass (J0)
  • errors::verify_passes_missing_stability_attr_115: [missing] -> pass (J0)
  • errors::verify_passes_must_not_suspend_47: [missing] -> pass (J0)
  • errors::verify_passes_must_not_suspend_60: pass -> [missing] (J0)
  • errors::verify_passes_non_exhaustive_with_default_field_values_19: pass -> [missing] (J0)
  • errors::verify_passes_non_exported_macro_invalid_attrs_69: [missing] -> pass (J0)
  • errors::verify_passes_object_lifetime_err_138: pass -> [missing] (J0)
  • errors::verify_passes_optimize_invalid_target_15: pass -> [missing] (J0)
  • errors::verify_passes_repr_align_greater_than_target_max_77: pass -> [missing] (J0)
  • errors::verify_passes_repr_conflicting_78: pass -> [missing] (J0)
  • errors::verify_passes_rustc_dirty_clean_71: pass -> [missing] (J0)
  • errors::verify_passes_rustc_force_inline_88: pass -> [missing] (J0)
  • errors::verify_passes_rustc_legacy_const_generics_index_exceed_52: [missing] -> pass (J0)
  • errors::verify_passes_rustc_legacy_const_generics_index_exceed_69: pass -> [missing] (J0)
  • errors::verify_passes_rustc_legacy_const_generics_index_negative_53: [missing] -> pass (J0)
  • errors::verify_passes_rustc_legacy_const_generics_index_negative_70: pass -> [missing] (J0)
  • errors::verify_passes_rustc_legacy_const_generics_only_50: [missing] -> pass (J0)
  • errors::verify_passes_rustc_lint_opt_deny_field_access_74: [missing] -> pass (J0)
  • errors::verify_passes_rustc_unstable_feature_bound_85: pass -> [missing] (J0)
  • errors::verify_passes_should_be_applied_to_fn_16: pass -> [missing] (J0)
  • errors::verify_passes_should_be_applied_to_fn_17: pass -> [missing] (J0)
  • errors::verify_passes_should_be_applied_to_static_22: pass -> [missing] (J0)
  • errors::verify_passes_target_feature_on_statement_21: pass -> [missing] (J0)
  • errors::verify_passes_transparent_incompatible_143: pass -> [missing] (J0)
  • errors::verify_passes_unexportable_adt_with_private_fields_142: [missing] -> pass (J0)
  • errors::verify_passes_unexportable_type_repr_139: [missing] -> pass (J0)
  • errors::verify_passes_unknown_external_lang_item_109: pass -> [missing] (J0)
  • errors::verify_passes_unknown_feature_118: [missing] -> pass (J0)
  • errors::verify_passes_unknown_feature_151: pass -> [missing] (J0)
  • errors::verify_passes_unknown_lang_item_84: [missing] -> pass (J0)
  • errors::verify_passes_unnecessary_stable_feature_129: [missing] -> pass (J0)
  • errors::verify_passes_unreachable_due_to_uninhabited_158: pass -> [missing] (J0)
  • errors::verify_passes_unused_assign_passed_165: pass -> [missing] (J0)
  • errors::verify_passes_unused_capture_maybe_capture_ref_127: [missing] -> pass (J0)
  • errors::verify_passes_unused_var_maybe_capture_ref_126: [missing] -> pass (J0)
  • errors::verify_passes_unused_var_maybe_capture_ref_159: pass -> [missing] (J0)
  • errors::verify_passes_useless_stability_112: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_invalid_alignment_value_38: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_link_ordinal_out_of_range_43: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_naked_functions_incompatible_attribute_40: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_repr_ident_37: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_repr_ident_39: [missing] -> pass (J0)
  • [ui] tests/ui/error-codes/E0518.rs: pass -> [missing] (J1)

(and 238 additional test diffs)

Additionally, 14 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 898aff704d6f0d00343f21d31b8b9bfac8e43007 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-apple-1: 8874.7s -> 12966.9s (46.1%)
  2. dist-aarch64-apple: 6257.0s -> 8023.0s (28.2%)
  3. x86_64-apple-2: 6831.2s -> 5134.8s (-24.8%)
  4. test-various: 4931.6s -> 5989.9s (21.5%)
  5. dist-apple-various: 6748.0s -> 5365.6s (-20.5%)
  6. aarch64-apple: 5038.9s -> 6011.6s (19.3%)
  7. dist-aarch64-msvc: 6545.1s -> 5762.8s (-12.0%)
  8. dist-ohos-x86_64: 4781.2s -> 4262.8s (-10.8%)
  9. dist-x86_64-apple: 13362.7s -> 11948.1s (-10.6%)
  10. dist-powerpc64le-linux-gnu: 5676.4s -> 5151.7s (-9.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (898aff7): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

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

Max RSS (memory usage)

Results (primary 10.6%, secondary 2.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
10.6% [10.6%, 10.6%] 1
Regressions ❌
(secondary)
2.3% [0.5%, 3.9%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 10.6% [10.6%, 10.6%] 1

Cycles

Results (primary 2.7%, secondary -3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.7% [2.4%, 3.0%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-4.9%, -1.5%] 5
All ❌✅ (primary) 2.7% [2.4%, 3.0%] 2

Binary size

Results (secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) - - 0

Bootstrap: 471.131s -> 470.516s (-0.13%)
Artifact size: 377.44 MiB -> 377.36 MiB (-0.02%)

@JonathanBrouwer
Copy link
Contributor Author

Yayy :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsed attributes applied to where bounds ICE the compiler ICE: can't get the span of an arbitrary parsed attribute: Parsed(Repr([(ReprEmpty..
9 participants