Skip to content

fix: Prevent ICE when comparing EII impl against generic declaration - #164811

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GauravPawar101:fix-issue-164621
Oct 28, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
GauravPawar101:fix-issue-164621

Conversation

@GauravPawar101

@GauravPawar101 GauravPawar101 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Added a guard in compare_eii_function_types and check_no_generics to skip signature comparison when the EII declaration has type/const parameters.

Problem

An EII declaration with type parameters rust (e.g., #[eii(foo)] fn bar<T>()) triggers error E0044 -> "externally implementable items may not have type parameters". Even aftre the compiler continued analysis and called to compare the implementation's signature against the declaration's. This comparison generated a TypeError containing the decl's ty::Param(T), and the error reporter subsequently tried to look up parameter T in the implementation's generics that werent' there, this caused an ICE:
index out of bounds: the len is 0 but the index is 0

Fix

Added an early return guard

Tested variatns

  • Generic declaration only
  • Generic impl only
  • Generic declaration + impl (ICE case)
  • No generics (original reproducer)

Closes #164621

@rustbot rustbot added 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 Oct 23, 2026
@rustbot

rustbot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
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 77 candidates
  • Random selection from 19 candidates

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir_analysis/src/check/compare_eii.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/check/compare_eii.rs Outdated
@GauravPawar101
GauravPawar101 requested a review from mejrs October 27, 2026 11:26
@mejrs

mejrs commented Oct 27, 2026

Copy link
Copy Markdown
Member

@bors squash msg="Prevent ICE when comparing EII impl against generic declaration"

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

🔨 4 commits were squashed into 199fb74.

@rust-bors
rust-bors Bot force-pushed the fix-issue-164621 branch from a9d6b6a to 199fb74 Compare October 27, 2026 12:47

@mejrs mejrs left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rust-bors

rust-bors Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 199fb74 has been tentatively approved by mejrs

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot 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 Oct 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 27, 2026
…=mejrs

fix: Prevent ICE when comparing EII impl against generic declaration

## Summary

Added a guard in compare_eii_function_types and check_no_generics to skip signature comparison when the EII declaration has type/const parameters.

## Problem

An EII declaration with type parameters ```rust (e.g., #[eii(foo)] fn bar<T>()) ``` triggers error E0044 -> "externally implementable items may not have type parameters". Even aftre the compiler continued analysis and called  to compare the implementation's signature against the declaration's. This comparison generated a `TypeError` containing the decl's `ty::Param(T)`, and the error reporter subsequently tried to look up parameter T in the implementation's generics that werent' there, this caused an ICE:
index out of bounds: the len is 0 but the index is 0

## Fix

Added an early return guard

## Tested variatns

- Generic declaration only
- Generic impl only
- Generic declaration + impl (ICE case)
- No generics (original reproducer)

Closes rust-lang#164621
rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)

> [!WARNING]
> This rollup conflicts with pending auto build #165042 and may need to be recreated if the pending build succeeds.
rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
…uwer

Rollup of 21 pull requests



Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
@rust-bors
rust-bors Bot merged commit 2c1381b into rust-lang:main Oct 28, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 28, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
Rollup merge of #164811 - GauravPawar101:fix-issue-164621, r=mejrs

fix: Prevent ICE when comparing EII impl against generic declaration

## Summary

Added a guard in compare_eii_function_types and check_no_generics to skip signature comparison when the EII declaration has type/const parameters.

## Problem

An EII declaration with type parameters ```rust (e.g., #[eii(foo)] fn bar<T>()) ``` triggers error E0044 -> "externally implementable items may not have type parameters". Even aftre the compiler continued analysis and called  to compare the implementation's signature against the declaration's. This comparison generated a `TypeError` containing the decl's `ty::Param(T)`, and the error reporter subsequently tried to look up parameter T in the implementation's generics that werent' there, this caused an ICE:
index out of bounds: the len is 0 but the index is 0

## Fix

Added an early return guard

## Tested variatns

- Generic declaration only
- Generic impl only
- Generic declaration + impl (ICE case)
- No generics (original reproducer)

Closes #164621
@GauravPawar101
GauravPawar101 deleted the fix-issue-164621 branch October 28, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[ICE]: index out of bounds in Generics::param_at when checking generic EII functions

4 participants