Skip to content

Commit a80496d

Browse files
---
yaml --- r: 277054 b: refs/heads/try c: de82fc4 h: refs/heads/master
1 parent b174354 commit a80496d

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-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: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: e45c7955e94fe55b7ca83dfb76b1bb50dfea74f6
4+
refs/heads/try: de82fc4dc6bbb87e50618f40e8fc671fb016f815
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,5 +1544,5 @@ register_diagnostics! {
15441544
E0490, // a value of type `..` is borrowed for too long
15451545
E0491, // in type `..`, reference has a longer lifetime than the data it...
15461546
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
1547-
E0524, // the closure implements `..` but not `..`
1547+
E0524, // expected a closure that implements `..` but this closure only implements `..`
15481548
}

branches/try/src/librustc/traits/error_reporting.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
471471
let closure_span = infcx.tcx.map.span_if_local(closure_def_id).unwrap();
472472
let mut err = struct_span_err!(
473473
infcx.tcx.sess, closure_span, E0524,
474-
"the closure implements `{}` but not `{}`",
475-
found_kind,
476-
kind);
474+
"expected a closure that implements the `{}` trait, but this closure \
475+
only implements `{}`",
476+
kind,
477+
found_kind);
477478
err.span_note(
478479
obligation.cause.span,
479480
&format!("the requirement to implement `{}` derives from here", kind));

branches/try/src/librustc_typeck/check/closure.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,16 @@ fn deduce_expectations_from_obligations<'a,'tcx>(
179179
ty::Predicate::TypeOutlives(..) => None,
180180
ty::Predicate::WellFormed(..) => None,
181181
ty::Predicate::ObjectSafe(..) => None,
182-
ty::Predicate::ClosureKind(_closure_def_id, kind) => {
183-
return Some(kind);
184-
}
182+
183+
// NB: This predicate is created by breaking down a
184+
// `ClosureType: FnFoo()` predicate, where
185+
// `ClosureType` represents some `TyClosure`. It can't
186+
// possibly be referring to the current closure,
187+
// because we haven't produced the `TyClosure` for
188+
// this closure yet; this is exactly why the other
189+
// code is looking for a self type of a unresolved
190+
// inference variable.
191+
ty::Predicate::ClosureKind(..) => None,
185192
};
186193
opt_trait_ref
187194
.and_then(|trait_ref| self_type_matches_expected_vid(fcx, trait_ref, expected_vid))

branches/try/src/test/compile-fail/closure-wrong-kind.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fn bar<T: Fn(u32)>(_: T) {}
1717

1818
fn main() {
1919
let x = X;
20-
let closure = |_| foo(x);
21-
//~^ ERROR the closure implements `FnOnce` but not `Fn`
20+
let closure = |_| foo(x); //~ ERROR E0524
2221
bar(closure);
2322
}

0 commit comments

Comments
 (0)