Skip to content

Commit 49b100b

Browse files
committed
---
yaml --- r: 235805 b: refs/heads/stable c: 4337e82 h: refs/heads/master i: 235803: 9baff8a v: v3
1 parent ac117ec commit 49b100b

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: d6be183af1d76a2716f1a3dc00b3ad3a2b746b37
32+
refs/heads/stable: 4337e822fb043e3e3abd085ca6483f15f11d913a
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc/diagnostics.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,41 @@ fn some_func() {
11211121
```
11221122
"##,
11231123

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+
11241159
E0271: r##"
11251160
This is because of a type mismatch between the associated type of some
11261161
trait (e.g. `T::Bar`, where `T` implements `trait Quux { type Bar; }`)
@@ -1681,7 +1716,6 @@ register_diagnostics! {
16811716
// E0134,
16821717
// E0135,
16831718
E0264, // unknown external lang item
1684-
E0269, // not all control paths return a value
16851719
E0270, // computation may converge in a function marked as diverging
16861720
E0272, // rustc_on_unimplemented attribute refers to non-existent type parameter
16871721
E0273, // rustc_on_unimplemented must have named format arguments

0 commit comments

Comments
 (0)