Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ fn compare_method_predicate_entailment<'tcx>(
}

if check_implied_wf == CheckImpliedWfMode::Check && !(impl_sig, trait_sig).references_error() {
// Select obligations to make progress on inference before processing
// the wf obligation below.
// FIXME(-Ztrait-solver=next): Not needed when the hack below is removed.
let errors = ocx.select_where_possible();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
return Err(reported);
}

// See #108544. Annoying, we can end up in cases where, because of winnowing,
// we pick param env candidates over a more general impl, leading to more
// stricter lifetime requirements than we would otherwise need. This can
Expand Down Expand Up @@ -378,7 +387,7 @@ fn compare_method_predicate_entailment<'tcx>(
// lifetime parameters.
let outlives_env = OutlivesEnvironment::with_bounds(
param_env,
infcx.implied_bounds_tys(param_env, impl_m_def_id, wf_tys.clone()),
infcx.implied_bounds_tys(param_env, impl_m_def_id, wf_tys),
);
let errors = infcx.resolve_regions(&outlives_env);
if !errors.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// check-pass

pub trait Foo {
type Error: Error;

fn foo(&self, stream: &<Self::Error as Error>::Span);
}

pub struct Wrapper<Inner>(Inner);

impl<E: Error, Inner> Foo for Wrapper<Inner>
where
Inner: Foo<Error = E>,
{
type Error = E;

fn foo(&self, stream: &<Self::Error as Error>::Span) {
todo!()
}
}

pub trait Error {
type Span;
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// check-pass

trait AsBufferView {
type Device;
}

trait Error {
type Span;
}

trait Foo {
type Error: Error;
fn foo(&self) -> &<Self::Error as Error>::Span;
}

impl<D: Error, VBuf0> Foo for VBuf0
where
VBuf0: AsBufferView<Device = D>,
{
type Error = D;
fn foo(&self) -> &<Self::Error as Error>::Span {
todo!()
}
}

fn main() {}