Add try_instantiate to EarlyBinder for fallible instantiation#153904
Add try_instantiate to EarlyBinder for fallible instantiation#153904ViewWay wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @JonathanBrouwer. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
For the love of god, please drop your cherry-pick of the commit I authored in open PR RUST-153738. It makes no sense whatsoever to take ownership of it & to include it here and in your ~5 other PRs. Your PRs can't proceed otherwise.
|
Reminder, once the PR becomes ready for a review, use |
This adds a fallible version of EarlyBinder::instantiate that returns a Result instead of panicking when parameter instantiation fails. The new try_instantiate method and InstantiationError enum allow callers to gracefully handle cases where: - Type/const/region parameters are out of range - Wrong kind of argument is provided (e.g., const when type expected) - No args provided but the value has parameters This is useful in error recovery paths where we want to continue compilation and report the actual error instead of ICE-ing.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
This adds a fallible version of
EarlyBinder::instantiatethat returns aResultinstead of panicking when parameter instantiation fails.Motivation
The existing
instantiatemethod panics when:In error recovery paths, we want to continue compilation and report the actual error to the user instead of ICE-ing.
Changes
EarlyBinder::try_instantiate- returnsResult<T, InstantiationError<I>>InstantiationErrorenum with detailed error variants:TypeParamOutOfRange/ConstParamOutOfRange/RegionParamOutOfRangeTypeParamExpected/ConstParamExpected/RegionParamExpectedMissingArgsTryArgFolderimplementingFallibleTypeFolderThis infrastructure can be used by callers that need graceful error handling during instantiation.