Skip to content

Commit d9f73e1

Browse files
committed
---
yaml --- r: 157221 b: refs/heads/master c: 737e396 h: refs/heads/master i: 157219: ee10ca1 v: v3
1 parent a6d7831 commit d9f73e1

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
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: 14398f29290b0d96dbe60f329b69062442eefb33
2+
refs/heads/master: 737e39696ba0964729f29410cf4e75a061ce120a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: d44ea720fa9dfe062ef06d0eb49a58d4e7e92344
55
refs/heads/try: 6ecdf1fa83d7cdbf44a0091132e9c6580be72275

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,25 @@ pub fn maybe_report_ambiguity(fcx: &FnCtxt, obligation: &Obligation) {
303303
// has_errors() to be sure that compilation isn't happening
304304
// anyway. In that case, why inundate the user.
305305
if !fcx.tcx().sess.has_errors() {
306-
fcx.tcx().sess.span_err(
307-
obligation.cause.span,
308-
format!(
309-
"unable to infer enough type information to \
310-
locate the impl of the trait `{}` for \
311-
the type `{}`; type annotations required",
312-
trait_ref.user_string(fcx.tcx()),
313-
self_ty.user_string(fcx.tcx())).as_slice());
314-
note_obligation_cause(fcx, obligation);
306+
if fcx.ccx.tcx.lang_items.sized_trait()
307+
.map_or(false, |sized_id| sized_id == trait_ref.def_id) {
308+
fcx.tcx().sess.span_err(
309+
obligation.cause.span,
310+
format!(
311+
"unable to infer enough type information about `{}`; type annotations \
312+
required",
313+
self_ty.user_string(fcx.tcx())).as_slice());
314+
} else {
315+
fcx.tcx().sess.span_err(
316+
obligation.cause.span,
317+
format!(
318+
"unable to infer enough type information to \
319+
locate the impl of the trait `{}` for \
320+
the type `{}`; type annotations required",
321+
trait_ref.user_string(fcx.tcx()),
322+
self_ty.user_string(fcx.tcx())).as_slice());
323+
note_obligation_cause(fcx, obligation);
324+
}
315325
}
316326
} else if !fcx.tcx().sess.has_errors() {
317327
// Ambiguity. Coherence should have reported an error.

trunk/src/test/compile-fail/issue-16562.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ struct Col<D, C> {
1616
}
1717

1818
impl<T, M: MatrixShape> Collection for Col<M, uint> {
19-
//~^ ERROR unable to infer enough type information to locate the impl of the trait
20-
//~^^ NOTE the trait `core::kinds::Sized` must be implemented because it is required by
19+
//~^ ERROR unable to infer enough type information
2120
fn len(&self) -> uint {
2221
unimplemented!()
2322
}

trunk/src/test/compile-fail/issue-17551.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
struct B<T>;
1414

1515
fn main() {
16-
let foo = B; //~ ERROR unable to infer enough type information to locate the impl of the trait
16+
let foo = B; //~ ERROR unable to infer enough type information
1717
let closure = |:| foo;
1818
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let x; //~ ERROR unable to infer enough type information
13+
}

0 commit comments

Comments
 (0)