File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: 012bb7de5ba65bfd7b3483595e65a4cda1d1f682
4
+ refs/heads/snap-stage3: 860573e3e00b5a807021b8c7a94a9672de4fa687
5
5
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Original file line number Diff line number Diff line change @@ -936,11 +936,13 @@ fn f(i: int) -> int {
936
936
}
937
937
~~~~
938
938
939
- The typechecker would complain that ` f ` doesn't return a value in the
940
- ` else ` branch. Adding the ` ! ` annotation on ` my_err ` would
941
- express that ` f ` requires no explicit ` return ` , as if it returns
942
- control to the caller, it returns a value (true because it never returns
943
- control).
939
+ This will not compile without the ` ! ` annotation on ` my_err ` ,
940
+ since the ` else ` branch of the conditional in ` f ` does not return an ` int ` ,
941
+ as required by the signature of ` f ` .
942
+ Adding the ` ! ` annotation to ` my_err ` informs the typechecker that,
943
+ should control ever enter ` my_err ` , no further type judgments about ` f ` need to hold,
944
+ since control will never resume in any context that relies on those judgments.
945
+ Thus the return type on ` f ` only needs to reflect the ` if ` branch of the conditional.
944
946
945
947
#### Pure functions
946
948
You can’t perform that action at this time.
0 commit comments