Skip to content

Implement EII for statics#154193

Merged
rust-bors[bot] merged 7 commits intorust-lang:mainfrom
JonathanBrouwer:external-static
Apr 13, 2026
Merged

Implement EII for statics#154193
rust-bors[bot] merged 7 commits intorust-lang:mainfrom
JonathanBrouwer:external-static

Conversation

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer commented Mar 22, 2026

View all comments

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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 Mar 22, 2026
@JonathanBrouwer JonathanBrouwer added the F-extern_item_impls `#![feature(extern_item_impls)]` label Mar 22, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Mar 22, 2026
@JonathanBrouwer JonathanBrouwer force-pushed the external-static branch 5 times, most recently from c7aa3cf to d9d3b13 Compare March 26, 2026 15:48
Comment thread compiler/rustc_hir_analysis/src/check/compare_eii.rs
Copy link
Copy Markdown
Contributor Author

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

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

r? @jdonszelmann

This code touches quite a few areas of the compiler I'm not super familiar yet with, so please review carefully whether I'm doing any stupid things :3

View changes since this review

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

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

@JonathanBrouwer JonathanBrouwer changed the title [VERY WIP] Implement EII for statics Implement EII for statics Mar 26, 2026
@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review March 26, 2026 15:51
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

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

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@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 Mar 26, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_analysis/src/check/compare_eii.rs Outdated
Comment thread compiler/rustc_codegen_llvm/src/mono_item.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/check/compare_eii.rs Outdated
@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Mar 30, 2026

The fact that eii_impls is a list seems to imply that a single item can define multiple EIIs at the same time. Wouldn't that result in multiple statics aliasing each other with this PR? Especially with static mut that would be rather dangerous. But even without, I'm not sure that is not UB.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor Author

JonathanBrouwer commented Apr 12, 2026

I don't have time to review today, but if you believe you have resolved my previous review comments, I don't have any objections to merging this without me reviewing it again.

I have resolved your previous review comments by disallowing EII on static muts and by disallowing multiple eii impls on 1 static, and Jana reviewed this.

If you only defining a single EII per static, then tcx.symbol_name() on the impl can return the symbol name of the declaration.

I have however not implemented this suggestion, because the implementation is significantly more complex especially around default impls, and I don't understand why the current implementation would be problematic.

@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 12, 2026

I have resolved your previous review comments by disallowing EII on static muts and by disallowing multiple eii impls on 1 static, and Jana reviewed this.

👍

I have however not implemented this suggestion, because the implementation is significantly more complex especially around default impls, and I don't understand why the current implementation would be problematic.

That is fine to leave for later. For functions I believe the same is done as this PR does for statics. If statics without defaults get changed in the way I suggested, functions without defaults should be changed too.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor Author

Then
@bors r=jdonszelmann rollup
Thanks for the review to both of you <3

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 12, 2026

📋 This PR cannot be approved because it currently has the following label: S-blocked.

@JonathanBrouwer JonathanBrouwer removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Apr 12, 2026
@JonathanBrouwer
Copy link
Copy Markdown
Contributor Author

@bors r=jdonszelmann

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 12, 2026

📌 Commit 106b16c has been approved by jdonszelmann

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 12, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 12, 2026
…=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 12, 2026
…=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 12, 2026
…=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
rust-bors bot pushed a commit that referenced this pull request Apr 12, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #155162 (relnotes for 1.95)
 - #154193 (Implement EII for statics)
 - #154435 (resolve: Some import resolution cleanups)
 - #155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 12, 2026
…=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
rust-bors bot pushed a commit that referenced this pull request Apr 13, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #155162 (relnotes for 1.95)
 - #154049 (delegation: Track more precise spans for glob delegations)
 - #154193 (Implement EII for statics)
 - #154435 (resolve: Some import resolution cleanups)
 - #154624 (Make `DerefPure` dyn-incompatible)
 - #155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 13, 2026
…=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
rust-bors bot pushed a commit that referenced this pull request Apr 13, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #155162 (relnotes for 1.95)
 - #140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - #154049 (delegation: Track more precise spans for glob delegations)
 - #154193 (Implement EII for statics)
 - #154435 (resolve: Some import resolution cleanups)
 - #153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - #154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - #154624 (Make `DerefPure` dyn-incompatible)
 - #154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - #154944 (Small refactor of `arena_cache` query values)
 - #155131 (Stabilize feature `uint_bit_width`)
 - #155147 (Stabilize feature `int_lowest_highest_one`)
 - #155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 13, 2026
…=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
rust-bors bot pushed a commit that referenced this pull request Apr 13, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #155162 (relnotes for 1.95)
 - #140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - #153604 (Fix thread::available_parallelism on WASI targets with threads)
 - #154193 (Implement EII for statics)
 - #154389 (Add more robust handling of nested query cycles)
 - #154435 (resolve: Some import resolution cleanups)
 - #155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - #155243 (cg_ssa: transmute between scalable vectors)
 - #153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - #154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - #154624 (Make `DerefPure` dyn-incompatible)
 - #154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - #154944 (Small refactor of `arena_cache` query values)
 - #155055 (UI automation)
 - #155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - #155131 (Stabilize feature `uint_bit_width`)
 - #155147 (Stabilize feature `int_lowest_highest_one`)
 - #155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - #155194 (Fix manpage version replacement and use verbose version)
@rust-bors rust-bors bot merged commit d2fa85c into rust-lang:main Apr 13, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 13, 2026
rust-timer added a commit that referenced this pull request Apr 13, 2026
Rollup merge of #154193 - JonathanBrouwer:external-static, r=jdonszelmann

Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 13, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Apr 16, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-extern_item_impls `#![feature(extern_item_impls)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. 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.

6 participants