Avoid ICE when an EII declaration conflicts with a constructor#153571
Open
TaKO8Ki wants to merge 3 commits intorust-lang:mainfrom
Open
Avoid ICE when an EII declaration conflicts with a constructor#153571TaKO8Ki wants to merge 3 commits intorust-lang:mainfrom
TaKO8Ki wants to merge 3 commits intorust-lang:mainfrom
Conversation
Collaborator
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
Contributor
|
r? me |
jdonszelmann
reviewed
Mar 8, 2026
| sig.decl.inputs.iter().map(|t| t.span).chain(iter::once(sig.decl.output.span())) | ||
| Some(sig.decl.inputs.iter().map(|t| t.span).chain(iter::once(sig.decl.output.span()))) | ||
| } else { | ||
| panic!("expected {def_id:?} to be a foreign function"); |
Contributor
There was a problem hiding this comment.
Is this change relevant given the early return at the top if it's not a foreign function?
Member
Author
There was a problem hiding this comment.
Since we have foreign function guard, it seems better to keep this line as it is or remove the panic and change it to:
let declaration_args = declaration.as_local().and_then(|def_id| {
get_declaration_sig(tcx, def_id)
.map(|sig| sig.decl.inputs.iter().map(|t| t.span).chain(iter::once(sig.decl.output.span())))
});
Contributor
|
@rustbot author |
Member
Author
|
@rustbot review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #153502
When an
#[eii]declaration conflicts with a tuple-struct constructor of the same name, error recovery can resolvethe EII target to the constructor instead of the generated foreign item.
compare_eii_function_typesthen assumesthat target is a foreign function and later ICEs while building diagnostics.
This pull request adds an early guard in
compare_eii_function_typesto skip EII signature comparison unless the resolved target is actually a foreign function.