@@ -1121,6 +1121,41 @@ fn some_func() {
1121
1121
```
1122
1122
"## ,
1123
1123
1124
+ E0269 : r##"
1125
+ Functions must eventually return a value of their return type. For example, in
1126
+ the following function
1127
+
1128
+ ```
1129
+ fn foo(x: u8) -> u8 {
1130
+ if x > 0 {
1131
+ x // alternatively, `return x`
1132
+ }
1133
+ // nothing here
1134
+ }
1135
+ ```
1136
+
1137
+ if the condition is true, the value `x` is returned, but if the condition is
1138
+ false, control exits the `if` block and reaches a place where nothing is being
1139
+ returned. All possible control paths must eventually return a `u8`, which is not
1140
+ happening here.
1141
+
1142
+ An easy fix for this in a complicated function is to specify a default return
1143
+ value, if possible:
1144
+
1145
+ ```
1146
+ fn foo(x: u8) -> u8 {
1147
+ if x > 0 {
1148
+ x // alternatively, `return x`
1149
+ }
1150
+ // lots of other if branches
1151
+ 0 // return 0 if all else fails
1152
+ }
1153
+ ```
1154
+
1155
+ It is advisable to find out what the unhandled cases are and check for them,
1156
+ returning an appropriate value or panicking if necessary.
1157
+ "## ,
1158
+
1124
1159
E0271 : r##"
1125
1160
This is because of a type mismatch between the associated type of some
1126
1161
trait (e.g. `T::Bar`, where `T` implements `trait Quux { type Bar; }`)
@@ -1681,7 +1716,6 @@ register_diagnostics! {
1681
1716
// E0134,
1682
1717
// E0135,
1683
1718
E0264 , // unknown external lang item
1684
- E0269 , // not all control paths return a value
1685
1719
E0270 , // computation may converge in a function marked as diverging
1686
1720
E0272 , // rustc_on_unimplemented attribute refers to non-existent type parameter
1687
1721
E0273 , // rustc_on_unimplemented must have named format arguments
0 commit comments