diagnostics: Fix ICE building a trait ref in method suggestions#157264
Open
Dnreikronos wants to merge 1 commit into
Open
diagnostics: Fix ICE building a trait ref in method suggestions#157264Dnreikronos wants to merge 1 commit into
Dnreikronos wants to merge 1 commit into
Conversation
When a method call fails to resolve, the suggestion machinery probes all traits for a method with the same name and builds a trait reference for the providing trait to detect duplicate trait items coming from multiple crate versions. It passed only the receiver type as the single argument, which is correct only for traits whose sole generic parameter is `Self`. For a trait with further parameters (for example `Borrow<Borrowed>`), or when the receiver type is unknown, the argument list no longer matched the trait's generics and tripped the `debug_assert_args_compatible` assertion, producing an ICE. Build the argument list with `GenericArgs::for_item` instead, using the receiver type for `Self` when known and fresh inference variables for the remaining parameters.
Collaborator
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
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 #157189
When a method call doesn't resolve, the no-method-found diagnostic probes every trait for one with a same-named method and builds a trait ref for it to spot trait items duplicated across crate versions. It only ever passed the receiver as the single argument, which works only when the trait's one generic is
Self. Call.borrow()on something and the probe findsBorrow, whose extraBorrowedparameter leaves the args out of step with the trait's generics, sodebug_assert_args_compatiblefires. Same crash when the receiver type isn't known and there are zero args.Now the args come from
GenericArgs::for_item: the receiver fillsSelfwhen we have it, fresh inference variables cover the rest.