Skip to content

Rewrite inline attribute parser to use new infrastructure and improve diagnostics for all parsed attributes #138165

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 8 commits into from
Jun 18, 2025

Conversation

jdonszelmann
Copy link
Contributor

@jdonszelmann jdonszelmann commented Mar 7, 2025

r? @oli-obk

This PR:

Builds on top of #138164

Closes #137950

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 7, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@@ -584,7 +546,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
return OptimizeAttr::Default;
};

inline_span = Some(attr.span());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes #137950

@jdonszelmann jdonszelmann force-pushed the inline branch 2 times, most recently from e6dad01 to 2a707bf Compare March 9, 2025 15:34
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 11, 2025

☔ The latest upstream changes (presumably #138302) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk 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 Apr 28, 2025
@jdonszelmann jdonszelmann force-pushed the inline branch 2 times, most recently from b7dda57 to 88a713a Compare June 9, 2025 22:40
@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor Author

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

This comment has been minimized.

@jdonszelmann
Copy link
Contributor Author

ah shit, broke clippy 😭

@bors
Copy link
Collaborator

bors commented Jun 17, 2025

📌 Commit 81f8b57 has been approved by oli-obk

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jun 18, 2025

⌛ Testing commit 81f8b57 with merge 1bb3352...

@bors
Copy link
Collaborator

bors commented Jun 18, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 1bb3352 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 18, 2025
@bors bors merged commit 1bb3352 into rust-lang:master Jun 18, 2025
11 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 18, 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 27733d4 (parent) -> 1bb3352 (this PR)

Test differences

Show 284 test diffs

Stage 1

  • errors::verify_codegen_ssa_aarch64_softfloat_neon_135: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_add_native_library_36: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_archive_build_failure_78: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_binary_output_to_tty_34: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_check_installed_visual_studio_51: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_check_installed_visual_studio_53: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_create_temp_dir_37: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_dlltool_fail_import_library_124: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_dlltool_fail_import_library_126: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_error_creating_import_library_131: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_error_creating_remark_dir_127: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_error_writing_def_file_127: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_extract_bundled_libs_archive_member_72: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_extract_bundled_libs_write_file_72: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_extract_bundled_libs_write_file_74: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_failed_to_get_layout_123: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_ignoring_emit_path_33: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_ignoring_emit_path_35: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_insufficient_vs_code_product_54: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_argument_29: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_basic_float_type_85: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_basic_integer_type_82: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_cast_wide_pointer_112: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_expected_element_type_111: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_expected_pointer_113: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_expected_usize_114: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_expected_vector_element_type_117: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_float_to_int_unchecked_86: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_floating_point_vector_85: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_inserted_type_105: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_mask_wrong_element_type_109: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_return_element_101: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_return_element_103: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_return_integer_type_100: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_return_integer_type_98: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_return_length_100: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_return_length_input_type_95: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_argument_88: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_argument_90: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_first_90: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds_104: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_input_89: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_input_91: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_return_95: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_shuffle_99: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_simd_third_94: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_third_argument_length_99: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_monomorphization_unsupported_symbol_of_size_112: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_no_sanitize_118: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_invalid_no_sanitize_120: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_invalid_windows_subsystem_82: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_link_exe_unexpected_error_42: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_link_script_unavailable_63: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_link_script_write_failure_64: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_linker_not_found_47: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_missing_cpp_build_tool_component_46: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_processing_dymutil_failed_54: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_read_file_76: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_rlib_missing_format_40: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_rlib_only_rmeta_found_39: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_self_contained_linker_missing_50: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_shuffle_indices_evaluation_83: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_static_library_native_artifacts_59: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_static_library_native_artifacts_to_file_60: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_stripping_debug_info_failed_58: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_target_feature_safe_trait_121: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_unable_to_exe_linker_50: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_unable_to_run_dsymutil_55: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_unknown_archive_kind_77: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_unsupported_link_self_contained_75: [missing] -> pass (J0)
  • errors::verify_codegen_ssa_xcrun_failed_invoking_134: pass -> [missing] (J0)
  • errors::verify_codegen_ssa_xcrun_unsuccessful_133: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_cfg_predicate_identifier_19: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_deprecated_item_suggestion_19: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_expected_single_version_literal_20: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_expected_single_version_literal_21: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_expected_version_literal_21: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_expects_features_23: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_ill_formed_attribute_input_29: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_incorrect_repr_format_align_one_arg_14: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_incorrect_repr_format_expect_literal_integer_16: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_incorrect_repr_format_packed_expect_integer_10: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_incorrect_repr_format_packed_one_or_zero_arg_9: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_invalid_repr_align_need_arg_12: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_invalid_repr_generic_14: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_invalid_repr_hint_no_paren_10: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_invalid_repr_hint_no_value_12: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_missing_feature_5: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_missing_issue_8: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_missing_since_2: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_missing_since_3: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_multiple_stability_levels_5: pass -> [missing] (J0)
  • session_diagnostics::verify_attr_parsing_non_ident_feature_6: [missing] -> pass (J0)
  • session_diagnostics::verify_attr_parsing_rustc_promotable_pairing_16: [missing] -> pass (J0)
  • [ui] tests/ui/error-codes/E0534.rs: pass -> [missing] (J1)
  • [ui] tests/ui/error-codes/E0565-2.rs: pass -> [missing] (J1)
  • [ui] tests/ui/span/E0535.rs: pass -> [missing] (J1)

Stage 2

  • [ui] tests/ui/error-codes/E0534.rs: pass -> [missing] (J2)
  • [ui] tests/ui/error-codes/E0539.rs: [missing] -> pass (J2)
  • [ui] tests/ui/error-codes/E0565-2.rs: pass -> [missing] (J2)

(and 184 additional test diffs)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 1bb335244c311a07cee165c28c553c869e6f64a9 --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. dist-x86_64-apple: 6930.5s -> 9478.9s (36.8%)
  2. x86_64-apple-2: 4485.4s -> 5824.0s (29.8%)
  3. dist-aarch64-linux: 7866.8s -> 5851.5s (-25.6%)
  4. dist-apple-various: 6856.3s -> 8435.4s (23.0%)
  5. x86_64-rust-for-linux: 2503.9s -> 2980.9s (19.0%)
  6. dist-ohos-x86_64: 4141.5s -> 4687.3s (13.2%)
  7. x86_64-apple-1: 7636.9s -> 8593.2s (12.5%)
  8. x86_64-gnu-stable: 6826.0s -> 7562.2s (10.8%)
  9. i686-gnu-1: 7233.0s -> 8011.3s (10.8%)
  10. dist-powerpc64le-linux-musl: 5010.6s -> 5533.5s (10.4%)
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.

@jdonszelmann
Copy link
Contributor Author

Yay!

// Latest feature: rustdoc JSON: Don't apply #[repr] privacy heuristics
pub const FORMAT_VERSION: u32 = 46;
// Latest feature: Pretty printing of inline attributes changed
pub const FORMAT_VERSION: u32 = 48;
Copy link
Contributor

Choose a reason for hiding this comment

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

Uh, we skipped 47. Oh well, not much to be done about it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@GuillaumeGomez: when you add the (tidy?) check for updating the number and comment in tandem, could you also add a check that the number is being increased by one?

Copy link
Member

Choose a reason for hiding this comment

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

I opened #142677 for that. But that's a good point. Added to my TODO list.

Copy link
Member

@aDotInTheVoid aDotInTheVoid Jun 19, 2025

Choose a reason for hiding this comment

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

#138165 (comment), earlier it was thaught that someone else was going to do 46->47, to this should do 47->48. I think the takeaways are:

a) Don't try to be too clever and do a double bounce
b) #142601 should fix this. 🤞

Copy link
Member

Choose a reason for hiding this comment

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

I've published rustdoc-types = "0.48.0", with a note that 0.47.0/format_version=47 will never exist. https://github.com/rust-lang/rustdoc-types/blob/trunk/CHANGELOG.md#v0.48.0

Copy link
Member

Choose a reason for hiding this comment

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

I've published rustdoc-types = "0.48.0", with a note that 0.47.0/format_version=47 will never exist. https://github.com/rust-lang/rustdoc-types/blob/trunk/CHANGELOG.md#v0.48.0

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1bb3352): comparison URL.

Overall result: ❌ regressions - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.3% [0.2%, 0.8%] 12
Regressions ❌
(secondary)
0.5% [0.2%, 0.8%] 21
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 2
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) 0.3% [-0.2%, 0.8%] 14

Max RSS (memory usage)

Results (primary -0.8%, secondary -1.0%)

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

mean range count
Regressions ❌
(primary)
7.0% [7.0%, 7.0%] 1
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-1.5% [-2.5%, -0.8%] 11
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 2
All ❌✅ (primary) -0.8% [-2.5%, 7.0%] 12

Cycles

Results (secondary 4.2%)

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)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.2%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.6%] 87
Regressions ❌
(secondary)
0.2% [0.0%, 0.8%] 40
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.6%] 87

Bootstrap: 693.071s -> 692.01s (-0.15%)
Artifact size: 372.10 MiB -> 372.13 MiB (0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Jun 18, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 19, 2025
rewrite `optimize` attribute to use new attribute parsing infrastructure

r? `@oli-obk`

I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)

Waiting on rust-lang#138165 first
tgross35 added a commit to tgross35/rust that referenced this pull request Jun 20, 2025
rewrite `optimize` attribute to use new attribute parsing infrastructure

r? ``@oli-obk``

I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)

Waiting on rust-lang#138165 first
tgross35 added a commit to tgross35/rust that referenced this pull request Jun 20, 2025
rewrite `optimize` attribute to use new attribute parsing infrastructure

r? ```@oli-obk```

I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)

Waiting on rust-lang#138165 first
@therealprof
Copy link
Contributor

@jdonszelmann Is the binary size jump expected? I thought this would only change the infrastructure but not actual inlining?

@jdonszelmann
Copy link
Contributor Author

jdonszelmann commented Jun 20, 2025

@oli-obk and I have been looking at this this morning. It has to do with attribute encoding cross crate and I'm working on a fix. The fix is luckily rather simple, but it was definitely an unexpected side effect. I expect to be busy for an hour or so more and then have a pr ready :)

bors added a commit that referenced this pull request Jun 20, 2025
Encode hir attributes cross-crate properly

r? `@oli-obk`

This should return the lost perf in #138165

cc: `@therealprof`
rust-timer added a commit that referenced this pull request Jun 20, 2025
Rollup merge of #138291 - jdonszelmann:optimize-attr, r=oli-obk

rewrite `optimize` attribute to use new attribute parsing infrastructure

r? ```@oli-obk```

I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)

Waiting on #138165 first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.

Diagnostics error in interaction between #[optimize(..)] and #[no_sanitize(..)]