Skip to content

Comments

refactor(allocator/vec): limit scope of #[expect(clippy::cast_possible_truncation)]#11074

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_
May 17, 2025
Merged

refactor(allocator/vec): limit scope of #[expect(clippy::cast_possible_truncation)]#11074
graphite-app[bot] merged 1 commit intomainfrom
05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented May 16, 2025

Follow-on after #10884.

Pure refactor. Move the #[expect(clippy::cast_possible_truncation)] attributes so they only apply to a single statement, rather than the whole function. That way we can see clearly where there's a dangerous conversion happening.

Annoyingly Rust doesn't allow putting attributes on expressions, so this requires statements that can then be attributed-up. But in my view, it's worth it.

Copy link
Member Author

overlookmotel commented May 16, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label May 16, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 16, 2025

CodSpeed Instrumentation Performance Report

Merging #11074 will create unknown performance changes

Comparing 05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_ (2f05c54) with main (7e69c08)

Summary

🆕 36 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 codegen[checker.ts] N/A 22.3 ms N/A
🆕 codegen_sourcemap[checker.ts] N/A 68.9 ms N/A
🆕 formatter[antd.js] N/A 714.3 ms N/A
🆕 formatter[react.development.js] N/A 8.1 ms N/A
🆕 formatter[typescript.js] N/A 1.1 s N/A
🆕 isolated-declarations[vue-id.ts] N/A 57 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 21.7 µs N/A
🆕 lexer[antd.js] N/A 24.7 ms N/A
🆕 lexer[cal.com.tsx] N/A 6 ms N/A
🆕 lexer[checker.ts] N/A 14.7 ms N/A
🆕 lexer[pdf.mjs] N/A 4 ms N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.8 ms N/A
🆕 linter[cal.com.tsx] N/A 1.3 s N/A
🆕 linter[checker.ts] N/A 3.1 s N/A
🆕 mangler[antd.js] N/A 15.7 ms N/A
🆕 mangler[react.development.js] N/A 289.1 µs N/A
🆕 mangler[typescript.js] N/A 39 ms N/A
🆕 minifier[antd.js] N/A 161.2 ms N/A
🆕 minifier[react.development.js] N/A 1.8 ms N/A
🆕 minifier[typescript.js] N/A 285.6 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@overlookmotel overlookmotel marked this pull request as ready for review May 16, 2025 12:58
@overlookmotel overlookmotel force-pushed the 05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_ branch from a9da8fd to 5ec2e61 Compare May 16, 2025 13:03
@overlookmotel overlookmotel force-pushed the 05-16-perf_allocator_vec_remove_alloc_guard_from_rawvec_from_raw_parts_in_clarify_safety_docs branch from cab4f00 to 51b5b12 Compare May 16, 2025 13:03
@overlookmotel overlookmotel force-pushed the 05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_ branch from 5ec2e61 to 290ae50 Compare May 16, 2025 13:14
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

I forgot that attributes can be attached to statements.

Copy link
Member Author

overlookmotel commented May 17, 2025

Merge activity

…le_truncation)]` (#11074)

Follow-on after #10884.

Pure refactor. Move the `#[expect(clippy::cast_possible_truncation)]` attributes so they only apply to a single statement, rather than the whole function. That way we can see clearly where there's a dangerous conversion happening.

Annoyingly Rust doesn't allow putting attributes on expressions, so this requires statements that can then be attributed-up. But in my view, it's worth it.
@graphite-app graphite-app bot force-pushed the 05-16-perf_allocator_vec_remove_alloc_guard_from_rawvec_from_raw_parts_in_clarify_safety_docs branch from 51b5b12 to 7e69c08 Compare May 17, 2025 10:17
@graphite-app graphite-app bot force-pushed the 05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_ branch from 290ae50 to 2f05c54 Compare May 17, 2025 10:17
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 17, 2025
Base automatically changed from 05-16-perf_allocator_vec_remove_alloc_guard_from_rawvec_from_raw_parts_in_clarify_safety_docs to main May 17, 2025 10:24
@graphite-app graphite-app bot merged commit 2f05c54 into main May 17, 2025
27 of 28 checks passed
@graphite-app graphite-app bot deleted the 05-16-refactor_allocator_vec_limit_scope_of_expect_clippy_cast_possible_truncation_ branch May 17, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants