Skip to content

Commit ac610cf

Browse files
committed
---
yaml --- r: 129669 b: refs/heads/master c: 2e4a21c h: refs/heads/master i: 129667: 8e397e4 v: v3
1 parent 647e882 commit ac610cf

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e3549ee202355731003002e813cf071cd89f04cb
2+
refs/heads/master: 2e4a21c2c2cc0702044dabf11d0839e4ed65a079
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 602592675ce86aeca465c4ac748cee2bff291443
55
refs/heads/try: 55c1a67fa1eb621bb8e73e0b13af2823391eb1be

trunk/src/librustc/middle/typeck/check/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,12 +2168,13 @@ fn lookup_method_for_for_loop(fcx: &FnCtxt,
21682168
}
21692169
};
21702170

2171+
let expr_type = fcx.expr_ty(&*iterator_expr);
21712172
let method = method::lookup_in_trait(fcx,
21722173
iterator_expr.span,
21732174
Some(&*iterator_expr),
21742175
token::intern("next"),
21752176
trait_did,
2176-
fcx.expr_ty(&*iterator_expr),
2177+
expr_type,
21772178
[],
21782179
DontAutoderefReceiver,
21792180
IgnoreStaticMethods);
@@ -2184,8 +2185,9 @@ fn lookup_method_for_for_loop(fcx: &FnCtxt,
21842185
Some(ref method) => method.ty,
21852186
None => {
21862187
fcx.tcx().sess.span_err(iterator_expr.span,
2187-
"`for` loop expression does not \
2188-
implement the `Iterator` trait");
2188+
format!("`for` loop expression has type `{}` which does \
2189+
not implement the `Iterator` trait",
2190+
fcx.infcx().ty_to_string(expr_type)).as_slice());
21892191
ty::mk_err()
21902192
}
21912193
};

trunk/src/test/compile-fail/for-loop-bogosity.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ pub fn main() {
2424
x: 1,
2525
y: 2,
2626
};
27-
for x in bogus { //~ ERROR does not implement the `Iterator` trait
27+
for x in bogus { //~ ERROR has type `MyStruct` which does not implement the `Iterator` trait
2828
drop(x);
2929
}
3030
}
31-

0 commit comments

Comments
 (0)