Skip to content

Commit 1558709

Browse files
committed
---
yaml --- r: 228734 b: refs/heads/try c: 4337e82 h: refs/heads/master v: v3
1 parent 0da1ced commit 1558709

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,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: d6be183af1d76a2716f1a3dc00b3ad3a2b746b37
4+
refs/heads/try: 4337e822fb043e3e3abd085ca6483f15f11d913a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/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)