Skip to content

internal: calculate pattern adjustments #9105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2021

Conversation

iDawer
Copy link
Contributor

@iDawer iDawer commented Jun 1, 2021

This extends InferenceResult with pub pat_adjustments: FxHashMap<PatId, Vec<Ty>>.

Fixes #9095

Copy link
Member

@flodiebold flodiebold left a comment

Choose a reason for hiding this comment

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

bors r+

@@ -331,8 +331,7 @@ impl<'a> MatchCheckCtx<'a> {

#[track_caller]
pub(super) fn bug(&self, info: &str) -> ! {
Copy link
Member

@flodiebold flodiebold Jun 3, 2021

Choose a reason for hiding this comment

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

(note: I haven't checked where this is called, but in general we want to be a bit more resilient about panicking on errors than rustc: Showing some inaccurate information in the IDE is often better than breaking completely. Hence the always! macro etc. that panic on debug assertions, but only log and continue in release builds. In the case of match check, it'd be ideal if we could just skip the match if we encounter some bug condition, if it's not too complicated to do.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. This is worth some experimenting with fallible implementation then including it into future libraryfied match checking.
For now it just relies on correct lowering and filtering out erroneous input in match_check::PatCtxt::lower_pattern. But in case of bugs, yeah.. that's bad.

Copy link
Member

Choose a reason for hiding this comment

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

Note, it's not worth making functions return results to avoid assertions. It's just, if there's a straightforward way to e.g. return no errors instead of panicking on an assertion, we should do that.

@bors
Copy link
Contributor

bors bot commented Jun 3, 2021

@bors bors bot merged commit 5093639 into rust-lang:master Jun 3, 2021
@iDawer iDawer deleted the pat-adjustments branch June 3, 2021 14:50
bors bot added a commit that referenced this pull request Sep 12, 2021
10213: minor: Improve resilience of match checking r=flodiebold a=iDawer

In bug condition the match checking strives to recover giving false no-error diagnostic.

Suggested in #9105 (comment)

Co-authored-by: Dawer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in match checking
2 participants