From a8ea415b90076b2ffcf4b033906c46d89096c783 Mon Sep 17 00:00:00 2001 From: lumi Date: Tue, 18 Aug 2026 19:31:36 +0200 Subject: [PATCH 1/6] rustc_hir_analysis: register all clauses of DefKind::Fn as obligations --- compiler/rustc_hir_analysis/src/check/check.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 01df2e199a5ac..00dff67887c2c 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -818,6 +818,23 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), tcx.ensure_ok().clauses_of(def_id); tcx.ensure_ok().fn_sig(def_id); tcx.ensure_ok().codegen_fn_attrs(def_id); + let clauses = tcx.clauses_of(def_id); + let param_env = tcx.param_env(def_id); + res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { + for (clause, span) in clauses.clauses { + wfcx.register_obligation(Obligation::new( + tcx, + ObligationCause::new( + *span, + def_id, + ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))), + ), + param_env, + *clause, + )); + } + Ok(()) + })); if let Some(i) = tcx.intrinsic(def_id) { intrinsic::check_intrinsic_type( tcx, From 44c73348e05c56e3930d87fa67845aa2a7765bcf Mon Sep 17 00:00:00 2001 From: lumi Date: Wed, 19 Aug 2026 22:30:02 +0200 Subject: [PATCH 2/6] rustc_hir_analysis: move function clause checks into its own function --- .../rustc_hir_analysis/src/check/check.rs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 00dff67887c2c..7208721d60833 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -756,6 +756,26 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) { } } +fn check_function_clauses(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> { + let clauses = tcx.clauses_of(def_id); + let param_env = tcx.param_env(def_id); + enter_wf_checking_ctxt(tcx, def_id, |wfcx| { + for (clause, span) in clauses.clauses { + wfcx.register_obligation(Obligation::new( + tcx, + ObligationCause::new( + *span, + def_id, + ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))), + ), + param_env, + *clause, + )); + } + Ok(()) + }) +} + pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> { let mut res = Ok(()); let generics = tcx.generics_of(def_id); @@ -815,26 +835,9 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Fn => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().clauses_of(def_id); tcx.ensure_ok().fn_sig(def_id); tcx.ensure_ok().codegen_fn_attrs(def_id); - let clauses = tcx.clauses_of(def_id); - let param_env = tcx.param_env(def_id); - res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { - for (clause, span) in clauses.clauses { - wfcx.register_obligation(Obligation::new( - tcx, - ObligationCause::new( - *span, - def_id, - ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))), - ), - param_env, - *clause, - )); - } - Ok(()) - })); + res = res.and(check_function_clauses(tcx, def_id)); if let Some(i) = tcx.intrinsic(def_id) { intrinsic::check_intrinsic_type( tcx, From ed398debfaa3ea879caee25fc737864812a6dccb Mon Sep 17 00:00:00 2001 From: lumi Date: Wed, 19 Aug 2026 23:47:18 +0200 Subject: [PATCH 3/6] tests: add test for rust-lang/rust#151319 --- tests/ui/trait-bounds/issue-151319.rs | 9 +++++++++ tests/ui/trait-bounds/issue-151319.stderr | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/ui/trait-bounds/issue-151319.rs create mode 100644 tests/ui/trait-bounds/issue-151319.stderr diff --git a/tests/ui/trait-bounds/issue-151319.rs b/tests/ui/trait-bounds/issue-151319.rs new file mode 100644 index 0000000000000..d2ad7e38fb29a --- /dev/null +++ b/tests/ui/trait-bounds/issue-151319.rs @@ -0,0 +1,9 @@ +//@compile-flags: -Znext-solver=globally --crate-type=lib +pub trait Trait { + type Assoc; +} + +pub fn foo + Trait>() { + //~^ ERROR type annotations needed: cannot satisfy `::Assoc == u32` [E0284] + const {} +} diff --git a/tests/ui/trait-bounds/issue-151319.stderr b/tests/ui/trait-bounds/issue-151319.stderr new file mode 100644 index 0000000000000..ecb48d60b9b7c --- /dev/null +++ b/tests/ui/trait-bounds/issue-151319.stderr @@ -0,0 +1,9 @@ +error[E0284]: type annotations needed: cannot satisfy `::Assoc == u32` + --> $DIR/issue-151319.rs:6:21 + | +LL | pub fn foo + Trait>() { + | ^^^^^^^^^^^ cannot satisfy `::Assoc == u32` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0284`. From a1dd78beb19e4ec82ebef768240a9bbeefb5f83e Mon Sep 17 00:00:00 2001 From: lumi Date: Thu, 20 Aug 2026 00:22:17 +0200 Subject: [PATCH 4/6] tests: rename issue-151319 to check-fn-clauses-issue-151319 --- .../{issue-151319.rs => check-fn-clauses-issue-151319.rs} | 0 ...issue-151319.stderr => check-fn-clauses-issue-151319.stderr} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/ui/trait-bounds/{issue-151319.rs => check-fn-clauses-issue-151319.rs} (100%) rename tests/ui/trait-bounds/{issue-151319.stderr => check-fn-clauses-issue-151319.stderr} (87%) diff --git a/tests/ui/trait-bounds/issue-151319.rs b/tests/ui/trait-bounds/check-fn-clauses-issue-151319.rs similarity index 100% rename from tests/ui/trait-bounds/issue-151319.rs rename to tests/ui/trait-bounds/check-fn-clauses-issue-151319.rs diff --git a/tests/ui/trait-bounds/issue-151319.stderr b/tests/ui/trait-bounds/check-fn-clauses-issue-151319.stderr similarity index 87% rename from tests/ui/trait-bounds/issue-151319.stderr rename to tests/ui/trait-bounds/check-fn-clauses-issue-151319.stderr index ecb48d60b9b7c..f201eae959ec6 100644 --- a/tests/ui/trait-bounds/issue-151319.stderr +++ b/tests/ui/trait-bounds/check-fn-clauses-issue-151319.stderr @@ -1,5 +1,5 @@ error[E0284]: type annotations needed: cannot satisfy `::Assoc == u32` - --> $DIR/issue-151319.rs:6:21 + --> $DIR/check-fn-clauses-issue-151319.rs:6:21 | LL | pub fn foo + Trait>() { | ^^^^^^^^^^^ cannot satisfy `::Assoc == u32` From e2e86fb235f416a10aefc202cc5363580bac06c9 Mon Sep 17 00:00:00 2001 From: lumi Date: Thu, 27 Aug 2026 19:55:22 +0200 Subject: [PATCH 5/6] rustc_hir_analysis: change ObligationCauseCode for check_function_clauses --- compiler/rustc_hir_analysis/src/check/check.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 7208721d60833..50585e388fa29 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -763,11 +763,7 @@ fn check_function_clauses(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err for (clause, span) in clauses.clauses { wfcx.register_obligation(Obligation::new( tcx, - ObligationCause::new( - *span, - def_id, - ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))), - ), + ObligationCause::new(*span, def_id, ObligationCauseCode::WellFormed(None)), param_env, *clause, )); From 77e3fd24d30b28abe94b39d9c80edd688cc0dcbc Mon Sep 17 00:00:00 2001 From: lumi Date: Thu, 27 Aug 2026 20:23:53 +0200 Subject: [PATCH 6/6] tests: fix a few of the ui tests that were broken by check_function_clauses --- .../associated-inherent-types/issue-109789.rs | 1 + .../issue-109789.stderr | 12 ++- .../issue-111404-1.rs | 1 + .../issue-111404-1.stderr | 12 ++- .../associated-inherent-types/regionck-2.rs | 6 +- .../regionck-2.stderr | 18 +++- .../duplicate-bound-err.rs | 13 +-- .../duplicate-bound-err.stderr | 100 ++++++++++-------- .../assoc-type-unsatisfied-bound.rs | 1 + .../assoc-type-unsatisfied-bound.stderr | 19 +++- tests/ui/associated-types/issue-59324.rs | 1 + tests/ui/associated-types/issue-59324.stderr | 15 ++- .../projection-dyn-associated-type.rs | 1 + .../projection-dyn-associated-type.stderr | 17 ++- 14 files changed, 155 insertions(+), 62 deletions(-) diff --git a/tests/ui/associated-inherent-types/issue-109789.rs b/tests/ui/associated-inherent-types/issue-109789.rs index e3c490b2dc842..d24e7dbd35ecc 100644 --- a/tests/ui/associated-inherent-types/issue-109789.rs +++ b/tests/ui/associated-inherent-types/issue-109789.rs @@ -18,6 +18,7 @@ impl Other for u32 {} fn bar(_: Foo fn(&'a ())>::Assoc) {} //~^ ERROR mismatched types //~| ERROR mismatched types +//~| ERROR mismatched types //~| ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error diff --git a/tests/ui/associated-inherent-types/issue-109789.stderr b/tests/ui/associated-inherent-types/issue-109789.stderr index db860a64826d6..b9d851d0cc4aa 100644 --- a/tests/ui/associated-inherent-types/issue-109789.stderr +++ b/tests/ui/associated-inherent-types/issue-109789.stderr @@ -17,6 +17,16 @@ LL | fn bar(_: Foo fn(&'a ())>::Assoc) {} found struct `Foo fn(&'a ())>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +error[E0308]: mismatched types + --> $DIR/issue-109789.rs:18:11 + | +LL | fn bar(_: Foo fn(&'a ())>::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected struct `Foo` + found struct `Foo fn(&'a ())>` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: higher-ranked subtype error --> $DIR/issue-109789.rs:18:1 | @@ -39,6 +49,6 @@ LL | fn bar(_: Foo fn(&'a ())>::Assoc) {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-inherent-types/issue-111404-1.rs b/tests/ui/associated-inherent-types/issue-111404-1.rs index cad6d48b1c5af..0c20cd443aa2d 100644 --- a/tests/ui/associated-inherent-types/issue-111404-1.rs +++ b/tests/ui/associated-inherent-types/issue-111404-1.rs @@ -10,6 +10,7 @@ impl<'a> Foo { fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} //~^ ERROR mismatched types [E0308] //~| ERROR mismatched types [E0308] +//~| ERROR mismatched types [E0308] //~| ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error diff --git a/tests/ui/associated-inherent-types/issue-111404-1.stderr b/tests/ui/associated-inherent-types/issue-111404-1.stderr index 9a5b69497c0cf..b2a64fac26030 100644 --- a/tests/ui/associated-inherent-types/issue-111404-1.stderr +++ b/tests/ui/associated-inherent-types/issue-111404-1.stderr @@ -17,6 +17,16 @@ LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} found struct `Foo fn(&'b ())>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +error[E0308]: mismatched types + --> $DIR/issue-111404-1.rs:10:11 + | +LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected struct `Foo` + found struct `Foo fn(&'b ())>` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: higher-ranked subtype error --> $DIR/issue-111404-1.rs:10:1 | @@ -37,6 +47,6 @@ error: higher-ranked subtype error LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} | ^ -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-inherent-types/regionck-2.rs b/tests/ui/associated-inherent-types/regionck-2.rs index 573dd359bf2b0..dcbc7139656d8 100644 --- a/tests/ui/associated-inherent-types/regionck-2.rs +++ b/tests/ui/associated-inherent-types/regionck-2.rs @@ -9,7 +9,9 @@ impl Lexer<'static> { type Cursor = (); } -fn test(_: Lexer::Cursor) {} //~ ERROR mismatched types -//~^ ERROR: lifetime may not live long enough +fn test(_: Lexer::Cursor) {} +//~^ ERROR: mismatched types +//~| ERROR: mismatched types +//~| ERROR: lifetime may not live long enough fn main() {} diff --git a/tests/ui/associated-inherent-types/regionck-2.stderr b/tests/ui/associated-inherent-types/regionck-2.stderr index 82f5c6a72c008..9beb34f822666 100644 --- a/tests/ui/associated-inherent-types/regionck-2.stderr +++ b/tests/ui/associated-inherent-types/regionck-2.stderr @@ -13,6 +13,22 @@ LL | fn test(_: Lexer::Cursor) {} | ^^^^^ = note: ...does not necessarily outlive the static lifetime +error[E0308]: mismatched types + --> $DIR/regionck-2.rs:12:12 + | +LL | fn test(_: Lexer::Cursor) {} + | ^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected struct `Lexer<'static>` + found struct `Lexer<'_>` +note: the anonymous lifetime defined here... + --> $DIR/regionck-2.rs:12:12 + | +LL | fn test(_: Lexer::Cursor) {} + | ^^^^^ + = note: ...does not necessarily outlive the static lifetime + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: lifetime may not live long enough --> $DIR/regionck-2.rs:12:1 | @@ -22,6 +38,6 @@ LL | fn test(_: Lexer::Cursor) {} | | has type `Lexer<'1>::Cursor` | requires that `'1` must outlive `'static` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.rs b/tests/ui/associated-type-bounds/duplicate-bound-err.rs index 56403fdf6630c..b0e9387ea227b 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.rs +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.rs @@ -1,10 +1,6 @@ //@ edition: 2024 -#![feature( - min_generic_const_args, - type_alias_impl_trait, - return_type_notation -)] +#![feature(min_generic_const_args, type_alias_impl_trait, return_type_notation)] #![expect(incomplete_features)] #![allow(refining_impl_trait_internal)] @@ -74,12 +70,13 @@ impl Trait for u32 { } fn uncallable(_: impl Iterator) {} +//~^ ERROR type annotations needed fn uncallable_const(_: impl Trait) {} +//~^ ERROR type annotations needed -fn uncallable_rtn( - _: impl Trait, foo(..): Trait> -) {} +fn uncallable_rtn(_: impl Trait, foo(..): Trait>) {} +//~^ ERROR type annotations needed type MustFail = dyn Iterator; //~^ ERROR [E0719] diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr index f685b01cd8cc3..0b138adfd9103 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed - --> $DIR/duplicate-bound-err.rs:14:5 + --> $DIR/duplicate-bound-err.rs:10:5 | LL | iter::empty() | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` @@ -10,7 +10,7 @@ LL | iter::empty::() | ++++++++++++++ error[E0282]: type annotations needed - --> $DIR/duplicate-bound-err.rs:18:5 + --> $DIR/duplicate-bound-err.rs:14:5 | LL | iter::empty() | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` @@ -21,7 +21,7 @@ LL | iter::empty::() | ++++++++++++++ error[E0282]: type annotations needed - --> $DIR/duplicate-bound-err.rs:22:5 + --> $DIR/duplicate-bound-err.rs:18:5 | LL | iter::empty() | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` @@ -32,7 +32,7 @@ LL | iter::empty::() | ++++++++++++++ error: unconstrained opaque type - --> $DIR/duplicate-bound-err.rs:26:51 + --> $DIR/duplicate-bound-err.rs:22:51 | LL | type Tait1> = impl Copy; | ^^^^^^^^^ @@ -40,7 +40,7 @@ LL | type Tait1> = impl Copy; = note: `Tait1` must be used in combination with a concrete type within the same crate error: unconstrained opaque type - --> $DIR/duplicate-bound-err.rs:28:51 + --> $DIR/duplicate-bound-err.rs:24:51 | LL | type Tait2> = impl Copy; | ^^^^^^^^^ @@ -48,7 +48,7 @@ LL | type Tait2> = impl Copy; = note: `Tait2` must be used in combination with a concrete type within the same crate error: unconstrained opaque type - --> $DIR/duplicate-bound-err.rs:30:57 + --> $DIR/duplicate-bound-err.rs:26:57 | LL | type Tait3> = impl Copy; | ^^^^^^^^^ @@ -56,7 +56,7 @@ LL | type Tait3> = impl Copy; = note: `Tait3` must be used in combination with a concrete type within the same crate error: unconstrained opaque type - --> $DIR/duplicate-bound-err.rs:33:14 + --> $DIR/duplicate-bound-err.rs:29:14 | LL | type Tait4 = impl Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | type Tait4 = impl Iterator; = note: `Tait4` must be used in combination with a concrete type within the same crate error: unconstrained opaque type - --> $DIR/duplicate-bound-err.rs:35:14 + --> $DIR/duplicate-bound-err.rs:31:14 | LL | type Tait5 = impl Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | type Tait5 = impl Iterator; = note: `Tait5` must be used in combination with a concrete type within the same crate error: unconstrained opaque type - --> $DIR/duplicate-bound-err.rs:37:14 + --> $DIR/duplicate-bound-err.rs:33:14 | LL | type Tait6 = impl Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL | type Tait6 = impl Iterator; = note: `Tait6` must be used in combination with a concrete type within the same crate error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/duplicate-bound-err.rs:40:18 + --> $DIR/duplicate-bound-err.rs:36:18 | LL | fn mismatch() -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely @@ -91,7 +91,7 @@ LL | iter::empty::<*const ()>() = help: the trait `Send` is not implemented for `*const ()` error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/duplicate-bound-err.rs:45:20 + --> $DIR/duplicate-bound-err.rs:41:20 | LL | fn mismatch_2() -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` @@ -100,7 +100,7 @@ LL | iter::empty::() | ----------------------- return type was inferred to be `std::iter::Empty` here error[E0271]: expected `IntoIter` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/duplicate-bound-err.rs:107:17 + --> $DIR/duplicate-bound-err.rs:104:17 | LL | fn foo() -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` @@ -109,7 +109,7 @@ LL | [2u32].into_iter() | ------------------ return type was inferred to be `std::array::IntoIter` here | note: the method call chain might not have had the expected associated types - --> $DIR/duplicate-bound-err.rs:110:16 + --> $DIR/duplicate-bound-err.rs:107:16 | LL | [2u32].into_iter() | ------ ^^^^^^^^^^^ `Iterator::Item` is `u32` here @@ -117,19 +117,37 @@ LL | [2u32].into_iter() | this expression has type `[u32; 1]` error[E0271]: expected `impl Iterator` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/duplicate-bound-err.rs:107:17 + --> $DIR/duplicate-bound-err.rs:104:17 | LL | fn foo() -> impl Iterator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` | note: required by a bound in `Trait3::foo::{anon_assoc#0}` - --> $DIR/duplicate-bound-err.rs:103:31 + --> $DIR/duplicate-bound-err.rs:100:31 | LL | fn foo() -> impl Iterator; | ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}` +error[E0284]: type annotations needed: cannot satisfy ` as Iterator>::Item == i32` + --> $DIR/duplicate-bound-err.rs:72:32 + | +LL | fn uncallable(_: impl Iterator) {} + | ^^^^^^^^^^ cannot satisfy ` as Iterator>::Item == i32` + +error[E0284]: type annotations needed: cannot satisfy ` as Trait>::ASSOC == 3` + --> $DIR/duplicate-bound-err.rs:75:35 + | +LL | fn uncallable_const(_: impl Trait) {} + | ^^^^^^^^^ cannot satisfy ` as Trait>::ASSOC == 3` + +error[E0284]: type annotations needed: cannot satisfy `, foo(..) : Trait> as Trait>::foo(..) } as Trait>::ASSOC == 3` + --> $DIR/duplicate-bound-err.rs:78:48 + | +LL | fn uncallable_rtn(_: impl Trait, foo(..): Trait>) {} + | ^^^^^^^^^ cannot satisfy `, foo(..) : Trait> as Trait>::foo(..) } as Trait>::ASSOC == 3` + error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate-bound-err.rs:84:42 + --> $DIR/duplicate-bound-err.rs:81:42 | LL | type MustFail = dyn Iterator; | ---------- ^^^^^^^^^^ re-bound here @@ -137,7 +155,7 @@ LL | type MustFail = dyn Iterator; | `Item` bound here first error: conflicting associated type bindings for `Item` - --> $DIR/duplicate-bound-err.rs:84:17 + --> $DIR/duplicate-bound-err.rs:81:17 | LL | type MustFail = dyn Iterator; | ^^^^^^^^^^^^^----------^^----------^ @@ -146,7 +164,7 @@ LL | type MustFail = dyn Iterator; | `Item` is specified to be `i32` here error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified - --> $DIR/duplicate-bound-err.rs:92:43 + --> $DIR/duplicate-bound-err.rs:89:43 | LL | type MustFail2 = dyn Trait2; | ------------ ^^^^^^^^^^^^ re-bound here @@ -154,7 +172,7 @@ LL | type MustFail2 = dyn Trait2; | `ASSOC` bound here first error: conflicting associated constant bindings for `ASSOC` - --> $DIR/duplicate-bound-err.rs:92:18 + --> $DIR/duplicate-bound-err.rs:89:18 | LL | type MustFail2 = dyn Trait2; | ^^^^^^^^^^^------------^^------------^ @@ -163,7 +181,7 @@ LL | type MustFail2 = dyn Trait2; | `ASSOC` is specified to be `3` here error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate-bound-err.rs:96:43 + --> $DIR/duplicate-bound-err.rs:93:43 | LL | type MustFail3 = dyn Iterator; | ---------- ^^^^^^^^^^ re-bound here @@ -171,7 +189,7 @@ LL | type MustFail3 = dyn Iterator; | `Item` bound here first error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified - --> $DIR/duplicate-bound-err.rs:99:43 + --> $DIR/duplicate-bound-err.rs:96:43 | LL | type MustFail4 = dyn Trait2; | ------------ ^^^^^^^^^^^^ re-bound here @@ -179,7 +197,7 @@ LL | type MustFail4 = dyn Trait2; | `ASSOC` bound here first error[E0271]: expected `Empty` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/duplicate-bound-err.rs:115:16 + --> $DIR/duplicate-bound-err.rs:112:16 | LL | uncallable(iter::empty::()); | ---------- ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` @@ -187,13 +205,13 @@ LL | uncallable(iter::empty::()); | required by a bound introduced by this call | note: required by a bound in `uncallable` - --> $DIR/duplicate-bound-err.rs:76:32 + --> $DIR/duplicate-bound-err.rs:72:32 | LL | fn uncallable(_: impl Iterator) {} | ^^^^^^^^^^ required by this bound in `uncallable` error[E0271]: expected `Empty` to be an iterator that yields `u32`, but it yields `i32` - --> $DIR/duplicate-bound-err.rs:116:16 + --> $DIR/duplicate-bound-err.rs:113:16 | LL | uncallable(iter::empty::()); | ---------- ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32` @@ -201,13 +219,13 @@ LL | uncallable(iter::empty::()); | required by a bound introduced by this call | note: required by a bound in `uncallable` - --> $DIR/duplicate-bound-err.rs:76:44 + --> $DIR/duplicate-bound-err.rs:72:44 | LL | fn uncallable(_: impl Iterator) {} | ^^^^^^^^^^ required by this bound in `uncallable` error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4` - --> $DIR/duplicate-bound-err.rs:117:22 + --> $DIR/duplicate-bound-err.rs:114:22 | LL | uncallable_const(()); | ---------------- ^^ expected `4`, found `3` @@ -217,13 +235,13 @@ LL | uncallable_const(()); = note: expected constant `4` found constant `3` note: required by a bound in `uncallable_const` - --> $DIR/duplicate-bound-err.rs:78:46 + --> $DIR/duplicate-bound-err.rs:75:46 | LL | fn uncallable_const(_: impl Trait) {} | ^^^^^^^^^ required by this bound in `uncallable_const` error[E0271]: type mismatch resolving `::ASSOC == 3` - --> $DIR/duplicate-bound-err.rs:118:22 + --> $DIR/duplicate-bound-err.rs:115:22 | LL | uncallable_const(4u32); | ---------------- ^^^^ expected `3`, found `4` @@ -233,13 +251,13 @@ LL | uncallable_const(4u32); = note: expected constant `3` found constant `4` note: required by a bound in `uncallable_const` - --> $DIR/duplicate-bound-err.rs:78:35 + --> $DIR/duplicate-bound-err.rs:75:35 | LL | fn uncallable_const(_: impl Trait) {} | ^^^^^^^^^ required by this bound in `uncallable_const` error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4` - --> $DIR/duplicate-bound-err.rs:119:20 + --> $DIR/duplicate-bound-err.rs:116:20 | LL | uncallable_rtn(()); | -------------- ^^ expected `4`, found `3` @@ -249,15 +267,13 @@ LL | uncallable_rtn(()); = note: expected constant `4` found constant `3` note: required by a bound in `uncallable_rtn` - --> $DIR/duplicate-bound-err.rs:81:61 + --> $DIR/duplicate-bound-err.rs:78:75 | -LL | fn uncallable_rtn( - | -------------- required by a bound in this function -LL | _: impl Trait, foo(..): Trait> - | ^^^^^^^^^ required by this bound in `uncallable_rtn` +LL | fn uncallable_rtn(_: impl Trait, foo(..): Trait>) {} + | ^^^^^^^^^ required by this bound in `uncallable_rtn` error[E0271]: type mismatch resolving `::ASSOC == 3` - --> $DIR/duplicate-bound-err.rs:120:20 + --> $DIR/duplicate-bound-err.rs:117:20 | LL | uncallable_rtn(17u32); | -------------- ^^^^^ expected `3`, found `4` @@ -267,14 +283,12 @@ LL | uncallable_rtn(17u32); = note: expected constant `3` found constant `4` note: required by a bound in `uncallable_rtn` - --> $DIR/duplicate-bound-err.rs:81:34 + --> $DIR/duplicate-bound-err.rs:78:48 | -LL | fn uncallable_rtn( - | -------------- required by a bound in this function -LL | _: impl Trait, foo(..): Trait> - | ^^^^^^^^^ required by this bound in `uncallable_rtn` +LL | fn uncallable_rtn(_: impl Trait, foo(..): Trait>) {} + | ^^^^^^^^^ required by this bound in `uncallable_rtn` -error: aborting due to 25 previous errors +error: aborting due to 28 previous errors -Some errors have detailed explanations: E0271, E0277, E0282, E0719. +Some errors have detailed explanations: E0271, E0277, E0282, E0284, E0719. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/associated-types/assoc-type-unsatisfied-bound.rs b/tests/ui/associated-types/assoc-type-unsatisfied-bound.rs index 76a93eed7b663..85b7c194e24bb 100644 --- a/tests/ui/associated-types/assoc-type-unsatisfied-bound.rs +++ b/tests/ui/associated-types/assoc-type-unsatisfied-bound.rs @@ -3,6 +3,7 @@ fn add_state(op: ::State) { //~^ ERROR `isize: HasState` is not satisfied //~| ERROR `isize: HasState` is not satisfied +//~| ERROR `isize: HasState` is not satisfied } trait HasState { diff --git a/tests/ui/associated-types/assoc-type-unsatisfied-bound.stderr b/tests/ui/associated-types/assoc-type-unsatisfied-bound.stderr index 3e318fcac503a..b79fdab9cd869 100644 --- a/tests/ui/associated-types/assoc-type-unsatisfied-bound.stderr +++ b/tests/ui/associated-types/assoc-type-unsatisfied-bound.stderr @@ -5,7 +5,7 @@ LL | fn add_state(op: ::State) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasState` is not implemented for `isize` | help: this trait has no implementations, consider adding one - --> $DIR/assoc-type-unsatisfied-bound.rs:8:1 + --> $DIR/assoc-type-unsatisfied-bound.rs:9:1 | LL | trait HasState { | ^^^^^^^^^^^^^^ @@ -17,12 +17,25 @@ LL | fn add_state(op: ::State) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasState` is not implemented for `isize` | help: this trait has no implementations, consider adding one - --> $DIR/assoc-type-unsatisfied-bound.rs:8:1 + --> $DIR/assoc-type-unsatisfied-bound.rs:9:1 | LL | trait HasState { | ^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 2 previous errors +error[E0277]: the trait bound `isize: HasState` is not satisfied + --> $DIR/assoc-type-unsatisfied-bound.rs:3:18 + | +LL | fn add_state(op: ::State) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasState` is not implemented for `isize` + | +help: this trait has no implementations, consider adding one + --> $DIR/assoc-type-unsatisfied-bound.rs:9:1 + | +LL | trait HasState { + | ^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-types/issue-59324.rs b/tests/ui/associated-types/issue-59324.rs index f9b310f6f9b31..b8acd633427b7 100644 --- a/tests/ui/associated-types/issue-59324.rs +++ b/tests/ui/associated-types/issue-59324.rs @@ -22,6 +22,7 @@ pub trait ThriftService: fn with_factory(factory: dyn ThriftService<()>) {} //~^ ERROR the trait bound `(): Foo` is not satisfied //~| ERROR the trait bound `(): Foo` is not satisfied +//~| ERROR the trait bound `(): Foo` is not satisfied //~| ERROR cannot be known at compilation time fn main() {} diff --git a/tests/ui/associated-types/issue-59324.stderr b/tests/ui/associated-types/issue-59324.stderr index 929238dc29b15..7c92def535901 100644 --- a/tests/ui/associated-types/issue-59324.stderr +++ b/tests/ui/associated-types/issue-59324.stderr @@ -11,6 +11,18 @@ help: consider further restricting type parameter `Bug` with trait `Foo` LL | pub trait ThriftService: | +++++ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/issue-59324.rs:22:29 + | +LL | fn with_factory(factory: dyn ThriftService<()>) {} + | ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/issue-59324.rs:3:1 + | +LL | pub trait Foo: NotFoo { + | ^^^^^^^^^^^^^^^^^^^^^ + error[E0277]: the trait bound `Bug: Foo` is not satisfied --> $DIR/issue-59324.rs:15:5 | @@ -32,6 +44,7 @@ help: this trait has no implementations, consider adding one | LL | pub trait Foo: NotFoo { | ^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `Bug: Foo` is not satisfied --> $DIR/issue-59324.rs:15:5 @@ -79,6 +92,6 @@ help: function arguments must have a statically known size, borrowed types alway LL | fn with_factory(factory: &dyn ThriftService<()>) {} | + -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-types/projection-dyn-associated-type.rs b/tests/ui/associated-types/projection-dyn-associated-type.rs index 32328f8793c71..b446ff5b863b3 100644 --- a/tests/ui/associated-types/projection-dyn-associated-type.rs +++ b/tests/ui/associated-types/projection-dyn-associated-type.rs @@ -23,6 +23,7 @@ pub fn foo<'a>( ) -> &'a ::Assoc { //~^ ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277] //~| ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277] + //~| ERROR the trait bound `(dyn B + 'static): Mirror` is not satisfied [E0277] static } //~ ERROR expected identifier, found `}` diff --git a/tests/ui/associated-types/projection-dyn-associated-type.stderr b/tests/ui/associated-types/projection-dyn-associated-type.stderr index 58eb8cff163db..3c711c416bbc6 100644 --- a/tests/ui/associated-types/projection-dyn-associated-type.stderr +++ b/tests/ui/associated-types/projection-dyn-associated-type.stderr @@ -1,5 +1,5 @@ error: expected identifier, found `}` - --> $DIR/projection-dyn-associated-type.rs:27:1 + --> $DIR/projection-dyn-associated-type.rs:28:1 | LL | } | ^ expected identifier @@ -54,7 +54,20 @@ LL | impl Mirror for A { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 4 previous errors; 1 warning emitted +error[E0277]: the trait bound `(dyn B + 'static): Mirror` is not satisfied + --> $DIR/projection-dyn-associated-type.rs:23:6 + | +LL | ) -> &'a ::Assoc { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Mirror` is not implemented for `(dyn B + 'static)` + | +help: the trait `Mirror` is implemented for `dyn A` + --> $DIR/projection-dyn-associated-type.rs:14:1 + | +LL | impl Mirror for A { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 5 previous errors; 1 warning emitted Some errors have detailed explanations: E0207, E0277. For more information about an error, try `rustc --explain E0207`.