Skip to content

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed
 

‎compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ fn compare_method_predicate_entailment<'tcx>(
308308
}
309309

310310
if check_implied_wf == CheckImpliedWfMode::Check && !(impl_sig, trait_sig).references_error() {
311+
// Select obligations to make progress on inference before processing
312+
// the wf obligation below.
313+
// FIXME(-Ztrait-solver=next): Not needed when the hack below is removed.
314+
let errors = ocx.select_where_possible();
315+
if !errors.is_empty() {
316+
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
317+
return Err(reported);
318+
}
319+
311320
// See #108544. Annoying, we can end up in cases where, because of winnowing,
312321
// we pick param env candidates over a more general impl, leading to more
313322
// stricter lifetime requirements than we would otherwise need. This can
@@ -378,7 +387,7 @@ fn compare_method_predicate_entailment<'tcx>(
378387
// lifetime parameters.
379388
let outlives_env = OutlivesEnvironment::with_bounds(
380389
param_env,
381-
infcx.implied_bounds_tys(param_env, impl_m_def_id, wf_tys.clone()),
390+
infcx.implied_bounds_tys(param_env, impl_m_def_id, wf_tys),
382391
);
383392
let errors = infcx.resolve_regions(&outlives_env);
384393
if !errors.is_empty() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
3+
pub trait Foo {
4+
type Error: Error;
5+
6+
fn foo(&self, stream: &<Self::Error as Error>::Span);
7+
}
8+
9+
pub struct Wrapper<Inner>(Inner);
10+
11+
impl<E: Error, Inner> Foo for Wrapper<Inner>
12+
where
13+
Inner: Foo<Error = E>,
14+
{
15+
type Error = E;
16+
17+
fn foo(&self, stream: &<Self::Error as Error>::Span) {
18+
todo!()
19+
}
20+
}
21+
22+
pub trait Error {
23+
type Span;
24+
}
25+
26+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
3+
trait AsBufferView {
4+
type Device;
5+
}
6+
7+
trait Error {
8+
type Span;
9+
}
10+
11+
trait Foo {
12+
type Error: Error;
13+
fn foo(&self) -> &<Self::Error as Error>::Span;
14+
}
15+
16+
impl<D: Error, VBuf0> Foo for VBuf0
17+
where
18+
VBuf0: AsBufferView<Device = D>,
19+
{
20+
type Error = D;
21+
fn foo(&self) -> &<Self::Error as Error>::Span {
22+
todo!()
23+
}
24+
}
25+
26+
fn main() {}

0 commit comments

Comments
 (0)
Please sign in to comment.