Skip to content

Commit 009d1fe

Browse files
committed
---
yaml --- r: 194524 b: refs/heads/snap-stage3 c: e15bebf h: refs/heads/master v: v3
1 parent 4a776d0 commit 009d1fe

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
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: 242ed0b7c0f6a21096f2cc3e1ad1bdb176d02545
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 385b5a3a7d2d96701ebabd7a48a6332a212d9c99
4+
refs/heads/snap-stage3: e15bebfefa34e155101663f2e110903911c37492
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc/middle/infer/mod.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,27 @@ pub enum TypeOrigin {
129129
EquatePredicate(Span),
130130
}
131131

132-
impl fmt::Display for TypeOrigin {
133-
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error> {
134-
let msg = match self {
135-
&TypeOrigin::Misc(_) => "mismatched types",
136-
&TypeOrigin::MethodCompatCheck(_) => "method not compatible with trait",
132+
impl TypeOrigin {
133+
fn as_str(&self) -> &'static str {
134+
match self {
135+
&TypeOrigin::Misc(_) |
136+
&TypeOrigin::RelateSelfType(_) |
137+
&TypeOrigin::RelateOutputImplTypes(_) |
137138
&TypeOrigin::ExprAssignable(_) => "mismatched types",
138139
&TypeOrigin::RelateTraitRefs(_) => "mismatched traits",
139-
&TypeOrigin::RelateSelfType(_) => "mismatched types",
140-
&TypeOrigin::RelateOutputImplTypes(_) => "mismatched types",
140+
&TypeOrigin::MethodCompatCheck(_) => "method not compatible with trait",
141141
&TypeOrigin::MatchExpressionArm(_, _) => "match arms have incompatible types",
142142
&TypeOrigin::IfExpression(_) => "if and else have incompatible types",
143143
&TypeOrigin::IfExpressionWithNoElse(_) => "if may be missing an else clause",
144144
&TypeOrigin::RangeExpression(_) => "start and end of range have incompatible types",
145145
&TypeOrigin::EquatePredicate(_) => "equality predicate not satisfied",
146-
};
147-
fmt::Display::fmt(msg, f)
146+
}
147+
}
148+
}
149+
150+
impl fmt::Display for TypeOrigin {
151+
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error> {
152+
fmt::Display::fmt(self.as_str(), f)
148153
}
149154
}
150155

0 commit comments

Comments
 (0)