diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 41af59388f798..47bd2fd37dff5 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -190,7 +190,7 @@ fn get_impl_args( } let assumed_wf_types = ocx.assumed_wf_types_and_report_errors(param_env, impl1_def_id)?; - let _ = ocx.resolve_regions_and_report_errors(impl1_def_id, param_env, assumed_wf_types); + ocx.resolve_regions_and_report_errors(impl1_def_id, param_env, assumed_wf_types)?; let Ok(impl2_args) = infcx.fully_resolve(impl2_args) else { let span = tcx.def_span(impl1_def_id); let guar = tcx.dcx().emit_err(GenericArgsOnOverriddenImpl { span }); diff --git a/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs new file mode 100644 index 0000000000000..d4b74802c2df7 --- /dev/null +++ b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs @@ -0,0 +1,26 @@ +//@ compile-flags: -Znext-solver=globally +// Regression test for https://github.com/rust-lang/rust/issues/151327 + +#![feature(min_specialization)] + +trait Foo { + type Item; +} + +trait Baz {} + +impl<'a, T> Foo for &'a T //~ ERROR not all trait items implemented, missing: `Item` +//~| ERROR the trait bound `&'a T: Foo` is not satisfied +where + Self::Item: 'a, //~ ERROR the trait bound `&'a T: Foo` is not satisfied +{ +} + +impl<'a, T> Foo for &T //~ ERROR not all trait items implemented, missing: `Item` +//~| ERROR cannot normalize `<&_ as Foo>::Item: '_` +where + Self::Item: Baz, +{ +} + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr b/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr new file mode 100644 index 0000000000000..df0e8fefaa848 --- /dev/null +++ b/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr @@ -0,0 +1,69 @@ +error[E0046]: not all trait items implemented, missing: `Item` + --> $DIR/next-solver-region-resolution.rs:12:1 + | +LL | type Item; + | --------- `Item` from trait +... +LL | / impl<'a, T> Foo for &'a T +LL | | +LL | | where +LL | | Self::Item: 'a, + | |___________________^ missing `Item` in implementation + +error[E0277]: the trait bound `&'a T: Foo` is not satisfied + --> $DIR/next-solver-region-resolution.rs:12:21 + | +LL | impl<'a, T> Foo for &'a T + | ^^^^^ the trait `Foo` is not implemented for `&'a T` + | +help: the trait `Foo` is not implemented for `&'a _` + but it is implemented for `&_` + --> $DIR/next-solver-region-resolution.rs:12:1 + | +LL | / impl<'a, T> Foo for &'a T +LL | | +LL | | where +LL | | Self::Item: 'a, + | |___________________^ + +error[E0277]: the trait bound `&'a T: Foo` is not satisfied + --> $DIR/next-solver-region-resolution.rs:15:17 + | +LL | Self::Item: 'a, + | ^^ the trait `Foo` is not implemented for `&'a T` + | +help: the trait `Foo` is not implemented for `&'a _` + but it is implemented for `&_` + --> $DIR/next-solver-region-resolution.rs:12:1 + | +LL | / impl<'a, T> Foo for &'a T +LL | | +LL | | where +LL | | Self::Item: 'a, + | |___________________^ + +error[E0046]: not all trait items implemented, missing: `Item` + --> $DIR/next-solver-region-resolution.rs:19:1 + | +LL | type Item; + | --------- `Item` from trait +... +LL | / impl<'a, T> Foo for &T +LL | | +LL | | where +LL | | Self::Item: Baz, + | |____________________^ missing `Item` in implementation + +error: cannot normalize `<&_ as Foo>::Item: '_` + --> $DIR/next-solver-region-resolution.rs:19:1 + | +LL | / impl<'a, T> Foo for &T +LL | | +LL | | where +LL | | Self::Item: Baz, + | |____________________^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`.