From aa6c2b1cb73edad3ca1e8068151dd7254a3ebce1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 18 Apr 2017 15:48:19 -0400 Subject: [PATCH] propagate obligations during overlap check --- src/librustc/traits/coherence.rs | 8 ++++---- src/test/run-pass/issue-41298.rs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/test/run-pass/issue-41298.rs diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 383fab3fcd7..a943ef30e53 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -55,16 +55,15 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, debug!("overlap: b_impl_header={:?}", b_impl_header); // Do `a` and `b` unify? If not, no overlap. - match selcx.infcx().eq_impl_headers(true, + let obligations = match selcx.infcx().eq_impl_headers(true, &ObligationCause::dummy(), &a_impl_header, &b_impl_header) { Ok(InferOk { obligations, .. }) => { - // FIXME(#32730) propagate obligations - assert!(obligations.is_empty()); + obligations } Err(_) => return None - } + }; debug!("overlap: unification check succeeded"); @@ -78,6 +77,7 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, .map(|p| Obligation { cause: ObligationCause::dummy(), recursion_depth: 0, predicate: p }) + .chain(obligations) .find(|o| !selcx.evaluate_obligation(o)); if let Some(failing_obligation) = opt_failing_obligation { diff --git a/src/test/run-pass/issue-41298.rs b/src/test/run-pass/issue-41298.rs new file mode 100644 index 00000000000..2b9baa74674 --- /dev/null +++ b/src/test/run-pass/issue-41298.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Function { t: T, f: F } + +impl Function R> { fn foo() { } } +impl Function R> { fn bar() { } } + +fn main() { }