Repository navigation
A default trait method's declared return type is a demand on its tail as on any function's: the implicit Ok and the Result[Unit, E] fall-off (#3360) - #3362
Merged
Conversation
… as on any function's: the implicit Ok and the Result[Unit, E] fall-off (#3360)
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.
Exact line.
SemaCheck.check_trait_default_method_body_for_implchecked the body against the return type and then ran onlycheck_body_explicit_value_results. A value tail underResult[T, E]was accepted and no wrap recorded (implicit_ok_tail_sigs, which MIR reads, D65):internal compiler error: invalid MIR before codegen … in S.checked.Fix: one owner for the rules. The return rules of
check_fn_body_with_sig_at_settledbecome functions:note_option_tail_demand,check_body_result(the returned tail's effects and origins) andcheck_annotated_body_result(the declared type against the tail: implicitOk, falling off aResult[Unit, E], the missing-Default and-> Nevererrors). The ordinary check calls all three, unchanged in behavior; the default-method check now calls the first and the third.Not in this change (#3360 stays open): a
Ttail underOption[T]in a default method is still refused (the ordinary check also sets the body's tail context before checking it), and the default body's returned-tail effects are still its own. Both go with giving the two checks one body.Test:
behav_3360_default_method_implicit_ok(ICE before,ok 4/err -2/doneafter).Battery: GREEN.