Skip to content

Fix fn_sig() called on non-function in EII comparison#152365

Closed
enthropy7 wants to merge 1 commit intorust-lang:mainfrom
enthropy7:fix-ice-152337
Closed

Fix fn_sig() called on non-function in EII comparison#152365
enthropy7 wants to merge 1 commit intorust-lang:mainfrom
enthropy7:fix-ice-152337

Conversation

@enthropy7
Copy link
Contributor

@enthropy7 enthropy7 commented Feb 8, 2026

when the same name is used for a const and an #[eii] function, name resolution can give the const's DefId as the EII declaration. we then call fn_sig() on it and hit the ICE.

now, at the start of compare_eii_function_types, require the declaration to be Fn, AssocFn, or Ctor(_, Fn) before calling fn_sig(). If not, emit the new EiiDeclarationNotFn diagnostic and return.

also, added test with stderr

Fixes #152337

@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 Feb 8, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 8, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
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 21 candidates
  • Random selection from 12 candidates

@rust-log-analyzer

This comment has been minimized.

@dianne
Copy link
Contributor

dianne commented Feb 9, 2026

This feels like the wrong fix to me. I'm not an EII expert, but isn't the actual problem that EII impl resolution is returning non-fn definitions? The ICE here is helpful in that it caught that bug; we shouldn't be papering over it.

@enthropy7
Copy link
Contributor Author

This feels like the wrong fix to me. I'm not an EII expert, but isn't the actual problem that EII impl resolution is returning non-fn definitions? The ICE here is helpful in that it caught that bug; we shouldn't be papering over it.

That said, I don’t think this change is the “wrong” fix for the ICE itself. Right now compare_eii_function_types assumes that the declaration is always a function and calls fn_sig() unconditionally. When that assumption is violated we get an ICE, which is still not acceptable behaviour even if the resolver is buggy. I agree about the root cause: the EII resolver should never return a non‑fn DefId, and Ive already looked into it and tried to fix locally

@dianne
Copy link
Contributor

dianne commented Feb 9, 2026

It's totally fine for functions to ICE when their preconditions are violated; that's better for catching bugs than returning a nice error would be. In this particular case, I don't have the expertise to say whether there's a huge difference between fixing resolution and catching bad resolutions in post. But as a general matter, we shouldn't be changing ICEs to errors when the ICE is indicative of an underlying issue.

@enthropy7
Copy link
Contributor Author

It's totally fine for functions to ICE when their preconditions are violated; that's better for catching bugs than returning a nice error would be. In this particular case, I don't have the expertise to say whether there's a huge difference between fixing resolution and catching bad resolutions in post. But as a general matter, we shouldn't be changing ICEs to errors when the ICE is indicative of an underlying issue.

i'm agree with you, i will finish my tests with fixing of the root cause soon and create separate PR, tho experts could check two different solutions of the problem and we could choose from there

@dianne
Copy link
Contributor

dianne commented Feb 9, 2026

In this particular case it might be fine to validate later, since that's what check_eiis is doing. Maybe best to catch before it gets to compare_eii_function_types though. I'll leave it up to Jana.

@dianne dianne closed this Feb 9, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2026
@dianne
Copy link
Contributor

dianne commented Feb 9, 2026

oops, wrong button

@dianne dianne reopened this Feb 9, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2026
@fmease fmease assigned jdonszelmann and unassigned chenyukang Feb 9, 2026
@petrochenkov
Copy link
Contributor

Closing in favor of #152384.

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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]: unexpected sort of node in fn_sig()

7 participants