Skip to content

Commit 0223b5d

Browse files
committed
---
yaml --- r: 221545 b: refs/heads/snap-stage3 c: 4337e82 h: refs/heads/master i: 221543: 5869aa5 v: v3
1 parent d604720 commit 0223b5d

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
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 607f74df2ad6b6fb32ce5b862a9e48a8c4afdad2
3-
refs/heads/snap-stage3: d6be183af1d76a2716f1a3dc00b3ad3a2b746b37
3+
refs/heads/snap-stage3: 4337e822fb043e3e3abd085ca6483f15f11d913a
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/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)