Skip to content

Propagate #[allow(dead_code)] on adts to their inherent impls#157885

Open
mu001999 wants to merge 2 commits into
rust-lang:mainfrom
mu001999-contrib:dead-code/improve
Open

Propagate #[allow(dead_code)] on adts to their inherent impls#157885
mu001999 wants to merge 2 commits into
rust-lang:mainfrom
mu001999-contrib:dead-code/improve

Conversation

@mu001999

@mu001999 mu001999 commented Jun 14, 2026

Copy link
Copy Markdown
Member

View all comments

This PR does:

  1. propagate #[allow(dead_code)] on adts to their inherent impls and impl items
  2. refactor the previous implementation for impl items of traits, and improve the performance

After the above, there is still some slight perf regressions because we indeed do more things (for inherent impls).

Fixes #149142

@rustbot rustbot added 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. labels Jun 14, 2026
Comment thread compiler/rustc_passes/src/dead.rs Outdated
Comment thread compiler/rustc_passes/src/dead.rs Outdated
@mu001999 mu001999 force-pushed the dead-code/improve branch from 0ff50d6 to 93cdd71 Compare June 14, 2026 14:43
@mu001999

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 15, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 15, 2026
Propagate `#[allow(dead_code)]` on adts to their inherent impls
@rust-bors

rust-bors Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 25aedf1 (25aedf1c569cd8fb010ed559082eacf12d56aaa2, parent: 3daae5e42ec9ba435212987331af1b7b8634fa90)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (25aedf1): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +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.5% [0.1%, 0.9%] 52
Regressions ❌
(secondary)
0.4% [0.2%, 0.7%] 16
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [-0.2%, 0.9%] 53

Max RSS (memory usage)

Results (primary -2.3%, 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)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.9% [-6.9%, -0.9%] 3
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) -2.3% [-6.9%, 2.3%] 4

Cycles

Results (secondary 21.3%)

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)
21.3% [20.3%, 22.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 519.503s -> 518.599s (-0.17%)
Artifact size: 401.51 MiB -> 401.51 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 15, 2026
@mu001999 mu001999 force-pushed the dead-code/improve branch from 93cdd71 to cbc2406 Compare June 16, 2026 16:12
@mu001999

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 16, 2026
Propagate `#[allow(dead_code)]` on adts to their inherent impls
@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 16, 2026
@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 848b0fa (848b0fabbf422f36bd3435a5abda617bf5da7395, parent: 89a99936d9e76a50e8df622e7242190841fd871b)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (848b0fa): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +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.2% [0.2%, 0.2%] 3
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 12
Improvements ✅
(primary)
-0.3% [-0.7%, -0.2%] 14
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) -0.2% [-0.7%, 0.2%] 17

Max RSS (memory usage)

Results (primary -5.4%, secondary 1.7%)

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)
3.3% [1.6%, 5.8%] 3
Improvements ✅
(primary)
-5.4% [-5.4%, -5.4%] 1
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) -5.4% [-5.4%, -5.4%] 1

Cycles

Results (secondary 1.4%)

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 522.035s -> 522.314s (0.05%)
Artifact size: 401.81 MiB -> 401.26 MiB (-0.14%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 16, 2026
@mu001999 mu001999 force-pushed the dead-code/improve branch from cbc2406 to f1229af Compare June 17, 2026 01:16
@mu001999

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 17, 2026
@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ed5706a (ed5706a69a8b278c09e17ef108bbf5a831a23316, parent: 9e2abe0c6ab27fcbb95c30695188a75776e2feb1)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ed5706a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +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.3% [0.2%, 0.3%] 7
Regressions ❌
(secondary)
0.3% [0.1%, 0.4%] 14
Improvements ✅
(primary)
-0.6% [-1.4%, -0.2%] 23
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) -0.4% [-1.4%, 0.3%] 30

Max RSS (memory usage)

Results (primary 0.9%, secondary 4.7%)

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

mean range count
Regressions ❌
(primary)
1.8% [1.2%, 2.3%] 2
Regressions ❌
(secondary)
4.7% [2.1%, 7.3%] 2
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.9% [-0.9%, 2.3%] 3

Cycles

Results (secondary 3.8%)

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 522.871s -> 521.923s (-0.18%)
Artifact size: 401.31 MiB -> 401.34 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 17, 2026
@mu001999 mu001999 force-pushed the dead-code/improve branch from f1229af to 79b739f Compare June 17, 2026 07:58
@mu001999

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 17, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 17, 2026
Propagate `#[allow(dead_code)]` on adts to their inherent impls
@rust-bors

rust-bors Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 4d34c0f (4d34c0f5d692d92842d17a23bb004c9a68935c62)
Base parent: 98594f4 (98594f404ee741f97fefbae4aca049cde911bc94)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4d34c0f): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +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.3% [0.2%, 0.3%] 7
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 6
Improvements ✅
(primary)
-0.6% [-1.4%, -0.2%] 25
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) -0.4% [-1.4%, 0.3%] 32

Max RSS (memory usage)

Results (primary 3.9%, secondary 3.8%)

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

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

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 523.739s -> 522.828s (-0.17%)
Artifact size: 401.37 MiB -> 401.86 MiB (0.12%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 17, 2026
@mu001999

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 18, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 18, 2026
Propagate `#[allow(dead_code)]` on adts to their inherent impls
@rust-bors

rust-bors Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ac3f172 (ac3f1720b43fdf1c580ee653c1a9db9b9e07b739)
Base parent: 3768ec0 (3768ec06c826ef667b65a7d084610a11baf10776)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ac3f172): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +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.2% [0.2%, 0.3%] 3
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 6
Improvements ✅
(primary)
-0.6% [-1.4%, -0.2%] 29
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.3%] 2
All ❌✅ (primary) -0.5% [-1.4%, 0.3%] 32

Max RSS (memory usage)

Results (primary -1.0%)

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

mean range count
Regressions ❌
(primary)
1.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.8%, -1.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.0% [-2.8%, 1.3%] 3

Cycles

Results (primary 2.9%, secondary -0.1%)

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

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 522.822s -> 523.673s (0.16%)
Artifact size: 401.33 MiB -> 401.44 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 18, 2026
@mu001999 mu001999 marked this pull request as ready for review June 18, 2026 14:44
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 18, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 18, 2026
@rustbot

rustbot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suppress warnings on dead inherent methods when allowing dead types

5 participants