diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index c02db15d744de..945eac5c14e0f 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -22,7 +22,7 @@ use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::traits::solve::NoSolution; use rustc_middle::ty::trait_def::TraitSpecializationKind; use rustc_middle::ty::{ - self, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFlags, TypeFoldable, + self, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Unnormalized, Upcast, }; @@ -2293,7 +2293,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { /// aren't true. #[instrument(level = "debug", skip(self))] fn check_false_global_bounds(&mut self) { - let tcx = self.ocx.infcx.tcx; + let infcx = self.ocx.infcx; + let tcx = infcx.tcx; let mut span = tcx.def_span(self.body_def_id); let empty_env = ty::ParamEnv::empty(); @@ -2312,10 +2313,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { _ => {} } - // Match the existing behavior. - if pred.is_global() && !pred.has_type_flags(TypeFlags::HAS_BINDER_VARS) { - let pred = self.normalize(span, None, Unnormalized::new_wip(pred)); - + let pred = self.deeply_normalize(span, None, Unnormalized::new_wip(pred)); + if pred.is_global() && pred.kind().bound_vars().is_empty() { // only use the span of the predicate clause (#90869) let hir_node = tcx.hir_node_by_def_id(self.body_def_id); if let Some(hir::Generics { predicates, .. }) = hir_node.generics() { @@ -2327,16 +2326,12 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { .unwrap_or(obligation_span); } - let obligation = Obligation::new( - tcx, - traits::ObligationCause::new( - span, - self.body_def_id, - ObligationCauseCode::TrivialBound, - ), - empty_env, - pred, + let cause = traits::ObligationCause::new( + span, + self.body_def_id, + ObligationCauseCode::TrivialBound, ); + let obligation = Obligation::new(tcx, cause, empty_env, pred); self.ocx.register_obligation(obligation); } } diff --git a/tests/crashes/148630.rs b/tests/crashes/148630.rs deleted file mode 100644 index 7b857bbb408a1..0000000000000 --- a/tests/crashes/148630.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #148630 -#![feature(unboxed_closures)] - -trait Tr {} -trait Foo { - fn foo() -> impl Sized - where - for<'a> <() as FnOnce<&'a i32>>::Output: Tr, - { - } -} - -fn main() {} diff --git a/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.rs b/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.rs index f62f8396e9911..74ebf2b9c3ed3 100644 --- a/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.rs +++ b/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.rs @@ -14,5 +14,6 @@ pub(crate) const B: usize = 5; pub trait Tec: Bar {} pub struct Structure { //~ ERROR the trait bound `C: Bar<5>` is not satisfied - _field: C::BarType, //~ ERROR the trait bound `C: Bar<5>` is not satisfied + //~| ERROR the trait bound `C: Bar<5>` is not satisfied + _field: C::BarType, } diff --git a/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.stderr b/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.stderr index 045516d7d2ff6..d97fc5b85c570 100644 --- a/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.stderr +++ b/tests/rustdoc-ui/synthetic-auto-trait-impls/projections-in-super-trait-bound-unsatisfied.stderr @@ -10,11 +10,12 @@ LL | pub struct Structure> { | ++++++++ error[E0277]: the trait bound `C: Bar<5>` is not satisfied - --> $DIR/projections-in-super-trait-bound-unsatisfied.rs:17:13 + --> $DIR/projections-in-super-trait-bound-unsatisfied.rs:16:1 | -LL | _field: C::BarType, - | ^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C` +LL | pub struct Structure { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C` | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `C` with trait `Bar` | LL | pub struct Structure> { diff --git a/tests/ui/associated-types/issue-38821.rs b/tests/ui/associated-types/issue-38821.rs index 35c371235e640..c9be1369f1634 100644 --- a/tests/ui/associated-types/issue-38821.rs +++ b/tests/ui/associated-types/issue-38821.rs @@ -34,14 +34,14 @@ pub trait Column: Expression {} //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied -pub enum ColumnInsertValue where -//~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied +//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied +pub enum ColumnInsertValue where +//~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied Col: Column, Expr: Expression::Nullable>, -//~^ ERROR the trait bound `::SqlType: IntoNullable` is not satisfied { Expression(Col, Expr), Default(Col), diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr index d7fcec380a3de..437e4318ed64d 100644 --- a/tests/ui/associated-types/issue-38821.stderr +++ b/tests/ui/associated-types/issue-38821.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:1 + --> $DIR/issue-38821.rs:40:1 | LL | pub enum ColumnInsertValue where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` @@ -16,11 +16,11 @@ help: consider extending the `where` clause, but there might be an alternative b LL | Expr: Expression::Nullable>, ::SqlType: NotNull | +++++++++++++++++++++++++++++++++++++ -error[E0277]: the trait bound `::SqlType: IntoNullable` is not satisfied - --> $DIR/issue-38821.rs:43:22 +error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied + --> $DIR/issue-38821.rs:40:1 | -LL | Expr: Expression::Nullable>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` +LL | pub enum ColumnInsertValue where + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -29,6 +29,7 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider extending the `where` clause, but there might be an alternative better way to express this requirement | LL | Expr: Expression::Nullable>, ::SqlType: NotNull @@ -82,13 +83,10 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:10 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -97,19 +95,7 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here -note: required for `ColumnInsertValue` to implement `Debug` - --> $DIR/issue-38821.rs:37:10 - | -LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ -... -LL | Expr: Expression::Nullable>, - | ------------------------------------------------ unsatisfied trait bound - = help: consider manually implementing `Debug` to avoid undesired bounds caused by "imperfect derives" - = note: to learn more, visit + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting the associated type | LL | Expr: Expression::Nullable>, ::SqlType: NotNull, @@ -134,13 +120,10 @@ LL | Expr: Expression::Nullable>, ::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:17 | LL | #[derive(Debug, Copy, Clone)] - | ---- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -149,17 +132,7 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here -note: required for `ColumnInsertValue` to implement `Copy` - --> $DIR/issue-38821.rs:37:10 - | -LL | #[derive(Debug, Copy, Clone)] - | ---- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ -... -LL | Expr: Expression::Nullable>, - | ------------------------------------------------ unsatisfied trait bound + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting the associated type | LL | Expr: Expression::Nullable>, ::SqlType: NotNull, @@ -213,13 +186,10 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:23:23 | LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -228,19 +198,7 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here -note: required for `ColumnInsertValue` to implement `Clone` - --> $DIR/issue-38821.rs:37:10 - | -LL | #[derive(Debug, Copy, Clone)] - | ----- in this derive macro expansion -... -LL | pub enum ColumnInsertValue where - | ^^^^^^^^^^^^^^^^^ -... -LL | Expr: Expression::Nullable>, - | ------------------------------------------------ unsatisfied trait bound - = help: consider manually implementing `Clone` to avoid undesired bounds caused by "imperfect derives" - = note: to learn more, visit + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting the associated type | LL | Expr: Expression::Nullable>, ::SqlType: NotNull, diff --git a/tests/ui/associated-types/issue-59324.rs b/tests/ui/associated-types/issue-59324.rs index 9d4c7cb39ae9e..3abe84730526d 100644 --- a/tests/ui/associated-types/issue-59324.rs +++ b/tests/ui/associated-types/issue-59324.rs @@ -10,8 +10,8 @@ pub trait Service { pub trait ThriftService: //~^ ERROR the trait bound `Bug: Foo` is not satisfied +//~| ERROR the trait bound `Bug: Foo` is not satisfied Service::OnlyFoo> -//~^ ERROR the trait bound `Bug: Foo` is not satisfied { fn get_service( //~^ ERROR the trait bound `Bug: Foo` is not satisfied diff --git a/tests/ui/associated-types/issue-59324.stderr b/tests/ui/associated-types/issue-59324.stderr index 3e2b0f4188973..e1f742f673dc6 100644 --- a/tests/ui/associated-types/issue-59324.stderr +++ b/tests/ui/associated-types/issue-59324.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied --> $DIR/issue-59324.rs:11:1 | LL | / pub trait ThriftService: -LL | | +... | LL | | Service::OnlyFoo> | |______________________________________________^ the trait `Foo` is not implemented for `Bug` | @@ -12,11 +12,14 @@ LL | pub trait ThriftService: | +++++ error[E0277]: the trait bound `Bug: Foo` is not satisfied - --> $DIR/issue-59324.rs:13:13 + --> $DIR/issue-59324.rs:11:1 | -LL | Service::OnlyFoo> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug` +LL | / pub trait ThriftService: +... | +LL | | Service::OnlyFoo> + | |______________________________________________^ the trait `Foo` is not implemented for `Bug` | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `Bug` with trait `Foo` | LL | pub trait ThriftService: diff --git a/tests/ui/associated-types/issue-69398.rs b/tests/ui/associated-types/issue-69398.rs index 654c0f6e4b54a..4e12d50834dd6 100644 --- a/tests/ui/associated-types/issue-69398.rs +++ b/tests/ui/associated-types/issue-69398.rs @@ -1,5 +1,3 @@ -//@ check-pass - pub trait Foo { type Bar; } @@ -12,6 +10,7 @@ pub trait Broken { impl Broken for T { type Assoc = (); fn broken(&self) where Self::Assoc: Foo { + //~^ ERROR the trait bound `(): Foo` is not satisfied let _x: ::Bar; } } diff --git a/tests/ui/associated-types/issue-69398.stderr b/tests/ui/associated-types/issue-69398.stderr new file mode 100644 index 0000000000000..2cbe4d5d30949 --- /dev/null +++ b/tests/ui/associated-types/issue-69398.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/issue-69398.rs:12:28 + | +LL | fn broken(&self) where Self::Assoc: Foo { + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/issue-69398.rs:1:1 + | +LL | pub trait Foo { + | ^^^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.rs b/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.rs index 4d223152866d3..c1cd29b38a0cc 100644 --- a/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.rs +++ b/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ compile-flags: -Znext-solver -Zassumptions-on-binders #![crate_type = "lib"] @@ -16,6 +15,7 @@ fn mk() -> for<'b> fn(&'b ()) { loop {} } fn ice() where (for<'b> fn(&'b ())): Trait + //~^ ERROR the trait bound `for<'b> fn(&'b ()): Trait` is not satisfied { req_trait(mk()); } diff --git a/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.stderr b/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.stderr new file mode 100644 index 0000000000000..706bba22a54b6 --- /dev/null +++ b/tests/ui/assumptions_on_binders/type_relation_binders_inside_solver-3.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `for<'b> fn(&'b ()): Trait` is not satisfied + --> $DIR/type_relation_binders_inside_solver-3.rs:17:5 + | +LL | (for<'b> fn(&'b ())): Trait + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `for<'b> fn(&'b ())` + | +help: this trait has no implementations, consider adding one + --> $DIR/type_relation_binders_inside_solver-3.rs:9:1 + | +LL | trait Trait { } + | ^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs index 13b2e031b118b..241d04c56929f 100644 --- a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs +++ b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs @@ -1,5 +1,4 @@ //! regression test for -//@ run-pass #![expect(incomplete_features)] #![feature(min_generic_const_args)] #![allow(dead_code)] @@ -19,6 +18,7 @@ trait S {} trait Handler where (): S<{ ::VALUE }>, + //~^ ERROR the trait bound `(): S<0>` is not satisfied { } diff --git a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.stderr b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.stderr new file mode 100644 index 0000000000000..34da4a7abe727 --- /dev/null +++ b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `(): S<0>` is not satisfied + --> $DIR/assoc-const-projection-in-bound.rs:20:5 + | +LL | (): S<{ ::VALUE }>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `S<0>` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/assoc-const-projection-in-bound.rs:16:1 + | +LL | trait S {} + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/issue-67696-const-prop-ice.rs b/tests/ui/consts/issue-67696-const-prop-ice.rs index 09e5ba74c338a..c459efe96b492 100644 --- a/tests/ui/consts/issue-67696-const-prop-ice.rs +++ b/tests/ui/consts/issue-67696-const-prop-ice.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ compile-flags: --emit=mir,link -Zmir-opt-level=4 // Checks that we don't ICE due to attempting to run const prop // on a function with unsatisifable 'where' clauses @@ -11,6 +10,7 @@ trait A { impl A for [fn(&())] { fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) } + //~^ ERROR the trait bound `[for<'a> fn(&'a ())]: Copy` is not satisfied } impl A for i32 { diff --git a/tests/ui/consts/issue-67696-const-prop-ice.stderr b/tests/ui/consts/issue-67696-const-prop-ice.stderr new file mode 100644 index 0000000000000..39b71a5485687 --- /dev/null +++ b/tests/ui/consts/issue-67696-const-prop-ice.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `[for<'a> fn(&'a ())]: Copy` is not satisfied + --> $DIR/issue-67696-const-prop-ice.rs:12:33 + | +LL | fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) } + | ^^^^^^^^^^ the trait `Copy` is not implemented for `[for<'a> fn(&'a ())]` + | +help: the trait `Copy` is implemented for `[T; N]` + --> $SRC_DIR/core/src/array/mod.rs:LL:COL +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.rs b/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.rs index bc7efac9dfccd..3f36273bd091a 100644 --- a/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.rs +++ b/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.rs @@ -17,12 +17,12 @@ impl Dyn for dyn Foo + '_ {} trait Foo: Super //~^ ERROR type mismatch resolving //~| ERROR the size for values of type `Self` cannot be known +//~| ERROR type mismatch resolving +//~| ERROR the size for values of type `Self` cannot be known where ::Assoc: Super, //~^ ERROR type mismatch resolving //~| ERROR the size for values of type `Self` cannot be known - //~| ERROR type mismatch resolving - //~| ERROR the size for values of type `Self` cannot be known { fn transmute(&self, t: T) -> ::Assoc; //~^ ERROR cannot find trait `B` in this scope diff --git a/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.stderr b/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.stderr index cf00ee45a43e5..ade0fe6e196ec 100644 --- a/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.stderr +++ b/tests/ui/dyn-compatibility/ice-generics-of-crate-root-152335.stderr @@ -50,7 +50,7 @@ LL | impl Dyn for dyn Foo + '_ {} | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit - --> $DIR/ice-generics-of-crate-root-152335.rs:21:30 + --> $DIR/ice-generics-of-crate-root-152335.rs:23:30 | LL | trait Foo: Super | --- this trait is not dyn compatible... @@ -95,16 +95,10 @@ LL | trait Foo: Super + Sized | +++++++ error[E0271]: type mismatch resolving `>::Assoc == Self` - --> $DIR/ice-generics-of-crate-root-152335.rs:21:30 + --> $DIR/ice-generics-of-crate-root-152335.rs:17:1 | LL | trait Foo: Super - | ------------------------------------------------ - | | | - | | found type parameter - | expected type parameter -... -LL | ::Assoc: Super, - | ^^^^^ expected type parameter `Self`, found type parameter `T` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `Self`, found type parameter `T` | = note: expected type parameter `Self` found type parameter `T` @@ -117,12 +111,13 @@ LL | impl> Mirror for T {} | --------- ^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/ice-generics-of-crate-root-152335.rs:21:30 + --> $DIR/ice-generics-of-crate-root-152335.rs:17:1 | -LL | ::Assoc: Super, - | ^^^^^ doesn't have a size known at compile-time +LL | trait Foo: Super + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | note: required for `Self` to implement `Mirror` --> $DIR/ice-generics-of-crate-root-152335.rs:38:42 @@ -131,6 +126,7 @@ LL | impl> Mirror for T {} | - ^^^^^^ ^ | | | unsatisfied trait bound implicitly introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting `Self` | LL | trait Foo: Super + Sized @@ -188,7 +184,7 @@ LL | fn transmute(&self, t: T) -> ::Assoc where Self: Sized; | +++++++++++++++++ error[E0271]: type mismatch resolving `>::Assoc == Self` - --> $DIR/ice-generics-of-crate-root-152335.rs:21:30 + --> $DIR/ice-generics-of-crate-root-152335.rs:23:30 | LL | trait Foo: Super | ------------------------------------------------ @@ -210,10 +206,9 @@ LL | impl> Mirror for T {} | --------- ^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/ice-generics-of-crate-root-152335.rs:21:30 + --> $DIR/ice-generics-of-crate-root-152335.rs:23:30 | LL | ::Assoc: Super, | ^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.rs b/tests/ui/feature-gates/feature-gate-trivial_bounds.rs index 3dbaf5dea250e..e81a14af5e2b8 100644 --- a/tests/ui/feature-gates/feature-gate-trivial_bounds.rs +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -60,9 +60,8 @@ fn return_str() -> str where str: Sized { //~ ERROR *"Sized".to_string().into_boxed_str() } -// This is currently accepted because the function pointer isn't -// considered global. -fn global_hr(x: fn(&())) where fn(&()): Foo { // OK +// The higher-ranked function pointer bound is global after normalization. +fn global_hr(x: fn(&())) where fn(&()): Foo { //~ ERROR x.test(); } diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr index e9bee1597c5cd..c2aac33800bc0 100644 --- a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -158,6 +158,22 @@ help: add `#![feature(trivial_bounds)]` to the crate attributes to enable LL + #![feature(trivial_bounds)] | -error: aborting due to 11 previous errors +error[E0277]: the trait bound `for<'a> fn(&'a ()): Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:64:32 + | +LL | fn global_hr(x: fn(&())) where fn(&()): Foo { + | ^^^^^^^^^^^^ the trait `Foo` is not implemented for `for<'a> fn(&'a ())` + | +help: the trait `Foo` is implemented for `()` + --> $DIR/feature-gate-trivial_bounds.rs:20:1 + | +LL | impl Foo for () where i32: Foo { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr index f136f5ffc82b4..6294275978d31 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr @@ -42,7 +42,7 @@ LL | F: Callback + MyFn, | +++++++++++ error[E0277]: the trait bound `F: Callback` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:48:12 + --> $DIR/false-positive-predicate-entailment-error.rs:49:12 | LL | F: Callback, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn` is not implemented for `F` @@ -118,16 +118,22 @@ LL | F: Callback + MyFn, | +++++++++++ error[E0277]: the trait bound `F: MyFn` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:48:12 + --> $DIR/false-positive-predicate-entailment-error.rs:41:5 | -LL | F: Callback, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn` is not implemented for `F` +LL | / fn autobatch(self) -> impl Trait +... | +LL | | where +LL | | F: Callback, + | |_______________________________________^ the trait `MyFn` is not implemented for `F` | -note: required by a bound in `Callback` - --> $DIR/false-positive-predicate-entailment-error.rs:15:20 +note: required for `F` to implement `Callback` + --> $DIR/false-positive-predicate-entailment-error.rs:19:21 | -LL | trait Callback: MyFn { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Callback` +LL | impl> Callback for F { + | ------- ^^^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `F` with trait `MyFn` | LL | F: Callback + MyFn, diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs index 044765233f56d..c2d53e4bbca60 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs @@ -43,11 +43,11 @@ impl ChannelSender for Sender { //~| ERROR the trait bound `F: MyFn` is not satisfied //~| ERROR the trait bound `F: MyFn` is not satisfied //~| ERROR the trait bound `F: MyFn` is not satisfied + //[current]~| ERROR the trait bound `F: MyFn` is not satisfied //[next]~| ERROR the trait bound `F: MyFn` is not satisfied where F: Callback, - //[current]~^ ERROR the trait bound `F: MyFn` is not satisfied - //[current]~| ERROR the trait bound `F: Callback` is not satisfied + //[current]~^ ERROR the trait bound `F: Callback` is not satisfied { Thing } diff --git a/tests/ui/issues/issue-42796.rs b/tests/ui/issues/issue-42796.rs index 5e83a1cd67785..8523e7521c8ce 100644 --- a/tests/ui/issues/issue-42796.rs +++ b/tests/ui/issues/issue-42796.rs @@ -7,6 +7,7 @@ impl Mirror for T { } pub fn poison(victim: String) where >::Image: Copy { +//~^ ERROR the trait bound `String: Copy` is not satisfied loop { drop(victim); } } diff --git a/tests/ui/issues/issue-42796.stderr b/tests/ui/issues/issue-42796.stderr index 0e7ce9e98c4d7..9586031261de7 100644 --- a/tests/ui/issues/issue-42796.stderr +++ b/tests/ui/issues/issue-42796.stderr @@ -1,5 +1,16 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/issue-42796.rs:9:40 + | +LL | pub fn poison(victim: String) where >::Image: Copy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + error[E0382]: borrow of moved value: `s` - --> $DIR/issue-42796.rs:18:20 + --> $DIR/issue-42796.rs:19:20 | LL | let s = "Hello!".to_owned(); | - move occurs because `s` has type `String`, which does not implement the `Copy` trait @@ -14,6 +25,7 @@ help: consider cloning the value if the performance cost is acceptable LL | let mut s_copy = s.clone(); | ++++++++ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0382`. +Some errors have detailed explanations: E0277, E0382. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/layout/unsatisfiable-sized-ungated.rs b/tests/ui/layout/unsatisfiable-sized-ungated.rs index d9c1f739bdbfa..2152be106d6b8 100644 --- a/tests/ui/layout/unsatisfiable-sized-ungated.rs +++ b/tests/ui/layout/unsatisfiable-sized-ungated.rs @@ -1,8 +1,7 @@ -//@ check-pass // issue: #123134 -//! This is a variant of `trivial-bounds-sized.rs` that compiles without any -//! feature gates and used to trigger a delayed bug. +//! This is a variant of `trivial-bounds-sized.rs` with an unsatisfiable bound +//! that used to trigger a delayed bug. trait Api: Sized { type Device: ?Sized; @@ -36,6 +35,7 @@ impl Adapter for T { fn open() -> OpenDevice where ::Device: Sized, + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time // ^ the bound expands to `<::A as Api>::Device: Sized`, which // is not considered trivial due to containing the type parameter `T` { diff --git a/tests/ui/layout/unsatisfiable-sized-ungated.stderr b/tests/ui/layout/unsatisfiable-sized-ungated.stderr new file mode 100644 index 0000000000000..ed2c593b5b6c0 --- /dev/null +++ b/tests/ui/layout/unsatisfiable-sized-ungated.stderr @@ -0,0 +1,15 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsatisfiable-sized-ungated.rs:37:9 + | +LL | ::Device: Sized, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs index ab3bf619f83b2..c88f98d5cd60e 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs @@ -7,6 +7,7 @@ async fn wrapper(f: F) //~^ ERROR: expected an `FnOnce(&'a mut i32)` closure, found `i32` //~| ERROR: expected an `FnOnce(&'a mut i32)` closure, found `i32` //~| ERROR: expected an `FnOnce(&'a mut i32)` closure, found `i32` +//~| ERROR: expected an `FnOnce(&'a mut i32)` closure, found `i32` where F:, for<'a> >::Output: Future + 'a, diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr index 7a825b93461c0..ea5de345ba150 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr @@ -9,6 +9,18 @@ LL | | for<'a> >::Output: Future | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` +error[E0277]: expected an `FnOnce(&'a mut i32)` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:6:1 + | +LL | / async fn wrapper(f: F) +... | +LL | | F:, +LL | | for<'a> >::Output: Future + 'a, + | |______________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32` + | + = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0277]: expected an `FnOnce(&'a mut i32)` closure, found `i32` --> $DIR/issue-76168-hr-outlives-3.rs:6:26 | @@ -26,6 +38,6 @@ LL | async fn wrapper(f: F) = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/methods/filter-relevant-fn-bounds.rs b/tests/ui/methods/filter-relevant-fn-bounds.rs index a23f4600d6d1b..91269735d2e40 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.rs +++ b/tests/ui/methods/filter-relevant-fn-bounds.rs @@ -7,6 +7,7 @@ struct Wrapper; impl Wrapper { fn do_something_wrapper(self, _: F) //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied + //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied where F: for<'a> FnOnce(>::Type), { diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index 9ad0319440e9a..17a2264e35a57 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -3,31 +3,48 @@ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied | LL | / fn do_something_wrapper(self, _: F) LL | | +LL | | +LL | | where +LL | | F: for<'a> FnOnce(>::Type), + | |___________________________________________________^ the trait `for<'a> Output<'a>` is not implemented for `F` + | +help: consider further restricting type parameter `F` with trait `Output` + | +LL | F: for<'a> FnOnce(>::Type) + for<'a> Output<'a>, + | ++++++++++++++++++++ + +error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied + --> $DIR/filter-relevant-fn-bounds.rs:8:5 + | +LL | / fn do_something_wrapper(self, _: F) +LL | | +LL | | LL | | where LL | | F: for<'a> FnOnce(>::Type), | |___________________________________________________^ the trait `for<'a> Output<'a>` is not implemented for `F` | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `F` with trait `Output` | LL | F: for<'a> FnOnce(>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ -error[E0277]: expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41}` - --> $DIR/filter-relevant-fn-bounds.rs:18:34 +error[E0277]: expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:19:34: 19:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:19:34: 19:41}` + --> $DIR/filter-relevant-fn-bounds.rs:19:34 | LL | wrapper.do_something_wrapper(|value| ()); - | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41}` + | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:19:34: 19:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:19:34: 19:41}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41}` + = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:19:34: 19:41}` help: this trait has no implementations, consider adding one --> $DIR/filter-relevant-fn-bounds.rs:1:1 | LL | trait Output<'a> { | ^^^^^^^^^^^^^^^^ note: required by a bound in `Wrapper::do_something_wrapper` - --> $DIR/filter-relevant-fn-bounds.rs:11:12 + --> $DIR/filter-relevant-fn-bounds.rs:12:12 | LL | fn do_something_wrapper(self, _: F) | -------------------- required by a bound in this associated function @@ -35,6 +52,6 @@ LL | fn do_something_wrapper(self, _: F) LL | F: for<'a> FnOnce(>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/mir/issue-91745.rs b/tests/ui/mir/issue-91745.rs index 654c0f6e4b54a..4e12d50834dd6 100644 --- a/tests/ui/mir/issue-91745.rs +++ b/tests/ui/mir/issue-91745.rs @@ -1,5 +1,3 @@ -//@ check-pass - pub trait Foo { type Bar; } @@ -12,6 +10,7 @@ pub trait Broken { impl Broken for T { type Assoc = (); fn broken(&self) where Self::Assoc: Foo { + //~^ ERROR the trait bound `(): Foo` is not satisfied let _x: ::Bar; } } diff --git a/tests/ui/mir/issue-91745.stderr b/tests/ui/mir/issue-91745.stderr new file mode 100644 index 0000000000000..e282a9d99bc95 --- /dev/null +++ b/tests/ui/mir/issue-91745.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/issue-91745.rs:12:28 + | +LL | fn broken(&self) where Self::Assoc: Foo { + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/issue-91745.rs:1:1 + | +LL | pub trait Foo { + | ^^^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.rs b/tests/ui/regions/regions-normalize-in-where-clause-list.rs index bcc5da406b4e6..e9315bb34b512 100644 --- a/tests/ui/regions/regions-normalize-in-where-clause-list.rs +++ b/tests/ui/regions/regions-normalize-in-where-clause-list.rs @@ -22,10 +22,10 @@ where // Here we get an error: we need `'a: 'b`. fn bar<'a, 'b>() +//~^ ERROR cannot infer where <() as Project<'a, 'b>>::Item: Eq, //~^ ERROR cannot infer - //~| ERROR cannot infer { } diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr index 1a20055836acd..224998ea32dc7 100644 --- a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr +++ b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr @@ -1,8 +1,11 @@ error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 + --> $DIR/regions-normalize-in-where-clause-list.rs:24:1 | -LL | <() as Project<'a, 'b>>::Item: Eq, - | ^^ +LL | / fn bar<'a, 'b>() +LL | | +LL | | where +LL | | <() as Project<'a, 'b>>::Item: Eq, + | |______________________________________^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... --> $DIR/regions-normalize-in-where-clause-list.rs:24:8 @@ -15,15 +18,18 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he LL | fn bar<'a, 'b>() | ^^ note: ...so that the types are compatible - --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 + --> $DIR/regions-normalize-in-where-clause-list.rs:24:1 | -LL | <() as Project<'a, 'b>>::Item: Eq, - | ^^ +LL | / fn bar<'a, 'b>() +LL | | +LL | | where +LL | | <() as Project<'a, 'b>>::Item: Eq, + | |______________________________________^ = note: expected `Project<'a, 'b>` found `Project<'_, '_>` error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 + --> $DIR/regions-normalize-in-where-clause-list.rs:27:36 | LL | <() as Project<'a, 'b>>::Item: Eq, | ^^ @@ -39,13 +45,12 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he LL | fn bar<'a, 'b>() | ^^ note: ...so that the types are compatible - --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 + --> $DIR/regions-normalize-in-where-clause-list.rs:27:36 | LL | <() as Project<'a, 'b>>::Item: Eq, | ^^ = note: expected `Project<'a, 'b>` found `Project<'_, '_>` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 2 previous errors diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs index c5e9d147d5671..18ed0dcf00dfa 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs @@ -32,9 +32,9 @@ enum RefIndirect<'a, T> { } enum RefDouble<'a, 'b, T> { +//~^ ERROR the parameter type `T` may not live long enough [E0309] RefDoubleVariant1(&'a RequireOutlives<'b, T>), //~^ ERROR the parameter type `T` may not live long enough [E0309] - //~| ERROR the parameter type `T` may not live long enough [E0309] } fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr index 2799164bbda2c..be441d7b8a896 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr @@ -26,12 +26,13 @@ LL | enum Ref2<'a, T: 'a> { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:35:23 + --> $DIR/regions-enum-not-wf.rs:34:1 | LL | enum RefDouble<'a, 'b, T> { - | -- the parameter type `T` must be valid for the lifetime `'b` as defined here... -LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^--^^^^ + | | | + | | the parameter type `T` must be valid for the lifetime `'b` as defined here... + | ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound | @@ -39,14 +40,14 @@ LL | enum RefDouble<'a, 'b, T: 'b> { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:35:23 + --> $DIR/regions-enum-not-wf.rs:36:23 | LL | enum RefDouble<'a, 'b, T> { | -- the parameter type `T` must be valid for the lifetime `'b` as defined here... +LL | LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit lifetime bound | LL | enum RefDouble<'a, 'b, T: 'b> { diff --git a/tests/ui/trait-bounds/issue-94999.rs b/tests/ui/trait-bounds/issue-94999.rs index b6a180a1579c7..dd16d8cb186fc 100644 --- a/tests/ui/trait-bounds/issue-94999.rs +++ b/tests/ui/trait-bounds/issue-94999.rs @@ -1,5 +1,3 @@ -//@ check-pass - trait Identity { type T; } @@ -24,6 +22,7 @@ impl Holds for X { impl Clone for X where >::T: Clone, + //~^ ERROR the trait bound `S: Clone` is not satisfied X: Holds, { fn clone(&self) -> Self { diff --git a/tests/ui/trait-bounds/issue-94999.stderr b/tests/ui/trait-bounds/issue-94999.stderr new file mode 100644 index 0000000000000..265fbfc4b3cb2 --- /dev/null +++ b/tests/ui/trait-bounds/issue-94999.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `S: Clone` is not satisfied + --> $DIR/issue-94999.rs:24:5 + | +LL | >::T: Clone, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `S` + | +help: consider annotating `S` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct S; + | +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs index 83e300b077428..99d1e664b13ad 100644 --- a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs +++ b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.rs @@ -39,6 +39,7 @@ fn impls_bound() { // - via blanket impl, requires where-clause `Foo: Bound` -> cycle fn generic() //~^ ERROR the trait bound `Foo: Bound` is not satisfied +//~| ERROR the trait bound `Foo: Bound` is not satisfied where >::Assoc: Bound, //~^ ERROR the trait bound `Foo: Bound` is not satisfied diff --git a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr index e18265190278a..a5694a968f0c5 100644 --- a/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr +++ b/tests/ui/traits/next-solver/cycles/normalizes-to-is-not-productive.stderr @@ -3,6 +3,35 @@ error[E0277]: the trait bound `Foo: Bound` is not satisfied | LL | / fn generic() LL | | +LL | | +LL | | where +LL | | >::Assoc: Bound, + | |____________________________________^ unsatisfied trait bound + | +help: the trait `Bound` is not implemented for `Foo` + --> $DIR/normalizes-to-is-not-productive.rs:18:1 + | +LL | struct Foo; + | ^^^^^^^^^^ +help: the trait `Bound` is implemented for `u32` + --> $DIR/normalizes-to-is-not-productive.rs:11:1 + | +LL | impl Bound for u32 { + | ^^^^^^^^^^^^^^^^^^ +note: required for `Foo` to implement `Trait` + --> $DIR/normalizes-to-is-not-productive.rs:23:19 + | +LL | impl Trait for T { + | ----- ^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error[E0277]: the trait bound `Foo: Bound` is not satisfied + --> $DIR/normalizes-to-is-not-productive.rs:40:1 + | +LL | / fn generic() +LL | | +LL | | LL | | where LL | | >::Assoc: Bound, | |____________________________________^ unsatisfied trait bound @@ -24,9 +53,10 @@ LL | impl Trait for T { | ----- ^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `Foo: Bound` is not satisfied - --> $DIR/normalizes-to-is-not-productive.rs:43:31 + --> $DIR/normalizes-to-is-not-productive.rs:44:31 | LL | >::Assoc: Bound, | ^^^^^ unsatisfied trait bound @@ -57,7 +87,7 @@ LL | | } | |_^ required by this bound in `Bound` error[E0277]: the trait bound `Foo: Bound` is not satisfied - --> $DIR/normalizes-to-is-not-productive.rs:48:19 + --> $DIR/normalizes-to-is-not-productive.rs:49:19 | LL | impls_bound::(); | ^^^ unsatisfied trait bound @@ -78,6 +108,6 @@ note: required by a bound in `impls_bound` LL | fn impls_bound() { | ^^^^^ required by this bound in `impls_bound` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/global-param-env-after-norm.rs b/tests/ui/traits/next-solver/global-param-env-after-norm.rs index 0d098db67d36d..64d6c4c678c15 100644 --- a/tests/ui/traits/next-solver/global-param-env-after-norm.rs +++ b/tests/ui/traits/next-solver/global-param-env-after-norm.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ compile-flags: -Znext-solver struct NewSolver; @@ -8,6 +7,7 @@ fn foo() where T: Iterator, OldSolver: Into, + //~^ ERROR the trait bound `NewSolver: From` is not satisfied { let x: OldSolver = OldSolver.into(); } diff --git a/tests/ui/traits/next-solver/global-param-env-after-norm.stderr b/tests/ui/traits/next-solver/global-param-env-after-norm.stderr new file mode 100644 index 0000000000000..56096f5ea51fe --- /dev/null +++ b/tests/ui/traits/next-solver/global-param-env-after-norm.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `NewSolver: From` is not satisfied + --> $DIR/global-param-env-after-norm.rs:9:5 + | +LL | OldSolver: Into, + | ^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | +help: the trait `From` is not implemented for `NewSolver` + --> $DIR/global-param-env-after-norm.rs:3:1 + | +LL | struct NewSolver; + | ^^^^^^^^^^^^^^^^ + = note: required for `OldSolver` to implement `Into` +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/normalize/deep-norm-pending.rs b/tests/ui/traits/normalize/deep-norm-pending.rs index 9b1ec522bef31..b164ef32263cd 100644 --- a/tests/ui/traits/normalize/deep-norm-pending.rs +++ b/tests/ui/traits/normalize/deep-norm-pending.rs @@ -7,7 +7,7 @@ trait Bar { //~^ ERROR the trait bound `T: Foo` is not satisfied } impl Bar for T -//~^ ERROR the trait bound `T: Bar` is not satisfied +//~^ ERROR the trait bound `T: Foo` is not satisfied //~| ERROR the trait bound `T: Foo` is not satisfied where ::Assoc: Sized, diff --git a/tests/ui/traits/normalize/deep-norm-pending.stderr b/tests/ui/traits/normalize/deep-norm-pending.stderr index f2b59748ced90..ff693b33432ee 100644 --- a/tests/ui/traits/normalize/deep-norm-pending.stderr +++ b/tests/ui/traits/normalize/deep-norm-pending.stderr @@ -86,20 +86,17 @@ help: consider further restricting type parameter `T` with trait `Foo` LL | ::Assoc: Sized, T: Foo | ++++++ -error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/deep-norm-pending.rs:9:17 - | -LL | impl Bar for T - | ^ the trait `Foo` is not implemented for `T` +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:9:1 | -note: required for `T` to implement `Bar` - --> $DIR/deep-norm-pending.rs:9:9 +LL | / impl Bar for T +LL | | +LL | | +LL | | where +LL | | ::Assoc: Sized, + | |_____________________________^ the trait `Foo` is not implemented for `T` | -LL | impl Bar for T - | ^^^ ^ -... -LL | ::Assoc: Sized, - | ----- unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `T` with trait `Foo` | LL | ::Assoc: Sized, T: Foo diff --git a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.current.stderr b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.current.stderr new file mode 100644 index 0000000000000..7cfa088cb395e --- /dev/null +++ b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.current.stderr @@ -0,0 +1,11 @@ +error[E0477]: the type `&'a ()` does not fulfill the required lifetime + --> $DIR/normalize-param-env-missing-implied-bound-1.rs:38:1 + | +LL | fn hrtb Trait<&'a ()>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0477`. diff --git a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.next.stderr b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.next.stderr new file mode 100644 index 0000000000000..7cfa088cb395e --- /dev/null +++ b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.next.stderr @@ -0,0 +1,11 @@ +error[E0477]: the type `&'a ()` does not fulfill the required lifetime + --> $DIR/normalize-param-env-missing-implied-bound-1.rs:38:1 + | +LL | fn hrtb Trait<&'a ()>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0477`. diff --git a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.rs b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.rs index 7fcb164d3a95d..c9e3d804c85d1 100644 --- a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.rs +++ b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-1.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver @@ -37,5 +36,6 @@ trait Trait: Supertrait { } fn hrtb Trait<&'a ()>>() {} +//~^ ERROR the type `&'a ()` does not fulfill the required lifetime pub fn main() {} diff --git a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.current.stderr b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.current.stderr new file mode 100644 index 0000000000000..0c5493cdc910d --- /dev/null +++ b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.current.stderr @@ -0,0 +1,11 @@ +error: implementation of `WithAssoc` is not general enough + --> $DIR/normalize-param-env-missing-implied-bound-2.rs:36:1 + | +LL | fn hrtb Trait<&'a ()>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `WithAssoc` is not general enough + | + = note: `&'0 ()` must implement `WithAssoc`, for any lifetime `'0`... + = note: ...but `WithAssoc` is actually implemented for the type `&'static ()` + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.next.stderr b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.next.stderr new file mode 100644 index 0000000000000..94b61c792db40 --- /dev/null +++ b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.next.stderr @@ -0,0 +1,11 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/normalize-param-env-missing-implied-bound-2.rs:36:1 + | +LL | fn hrtb Trait<&'a ()>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: but lifetime parameter must outlive the static lifetime + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0478`. diff --git a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.rs b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.rs index 9339518aae1a0..999ff5ae96f25 100644 --- a/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.rs +++ b/tests/ui/traits/normalize/normalize-param-env-missing-implied-bound-2.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver @@ -35,5 +34,7 @@ trait Trait: Supertrait { } fn hrtb Trait<&'a ()>>() {} +//[current]~^ ERROR implementation of `WithAssoc` is not general enough +//[next]~^^ ERROR lifetime bound not satisfied pub fn main() {} diff --git a/tests/ui/traits/trait-associated-type-bounds-36839.rs b/tests/ui/traits/trait-associated-type-bounds-36839.rs index 156c063abc23f..8567b5a834adc 100644 --- a/tests/ui/traits/trait-associated-type-bounds-36839.rs +++ b/tests/ui/traits/trait-associated-type-bounds-36839.rs @@ -1,5 +1,3 @@ -//@ check-pass - pub trait Foo { type Bar; } @@ -12,6 +10,7 @@ pub trait Broken { impl Broken for T { type Assoc = (); fn broken(&self) where Self::Assoc: Foo { + //~^ ERROR the trait bound `(): Foo` is not satisfied let _x: ::Bar; } } diff --git a/tests/ui/traits/trait-associated-type-bounds-36839.stderr b/tests/ui/traits/trait-associated-type-bounds-36839.stderr new file mode 100644 index 0000000000000..6a5139195cd33 --- /dev/null +++ b/tests/ui/traits/trait-associated-type-bounds-36839.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/trait-associated-type-bounds-36839.rs:12:28 + | +LL | fn broken(&self) where Self::Assoc: Foo { + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/trait-associated-type-bounds-36839.rs:1:1 + | +LL | pub trait Foo { + | ^^^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/unhandled-crate-mod-issue-144888.rs b/tests/ui/traits/unhandled-crate-mod-issue-144888.rs index 779faae6688c8..c456e683e1979 100644 --- a/tests/ui/traits/unhandled-crate-mod-issue-144888.rs +++ b/tests/ui/traits/unhandled-crate-mod-issue-144888.rs @@ -10,12 +10,12 @@ impl dyn Foo<()> {} trait Foo: Super //~^ ERROR type mismatch resolving //~| ERROR the size for values of type `Self` cannot be known at compilation time +//~| ERROR type mismatch resolving +//~| ERROR the size for values of type `Self` cannot be known at compilation time where ::Assoc: Clone, //~^ ERROR type mismatch resolving //~| ERROR the size for values of type `Self` cannot be known at compilation time - //~| ERROR type mismatch resolving - //~| ERROR the size for values of type `Self` cannot be known at compilation time { fn transmute(&self) {} //~^ ERROR type mismatch resolving diff --git a/tests/ui/traits/unhandled-crate-mod-issue-144888.stderr b/tests/ui/traits/unhandled-crate-mod-issue-144888.stderr index 9829dab3029bb..05a5a7dffbd00 100644 --- a/tests/ui/traits/unhandled-crate-mod-issue-144888.stderr +++ b/tests/ui/traits/unhandled-crate-mod-issue-144888.stderr @@ -63,13 +63,10 @@ LL | trait Foo: Super + Sized | +++++++ error[E0271]: type mismatch resolving `::Assoc == ()` - --> $DIR/unhandled-crate-mod-issue-144888.rs:14:30 + --> $DIR/unhandled-crate-mod-issue-144888.rs:10:1 | LL | trait Foo: Super - | - found this type parameter -... -LL | ::Assoc: Clone, - | ^^^^^ expected `()`, found type parameter `T` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found type parameter `T` | = note: expected unit type `()` found type parameter `T` @@ -80,12 +77,13 @@ LL | impl> Mirror for T {} | ---------- ^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/unhandled-crate-mod-issue-144888.rs:14:30 + --> $DIR/unhandled-crate-mod-issue-144888.rs:10:1 | -LL | ::Assoc: Clone, - | ^^^^^ doesn't have a size known at compile-time +LL | trait Foo: Super + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | note: required for `Self` to implement `Mirror` --> $DIR/unhandled-crate-mod-issue-144888.rs:31:28 @@ -94,6 +92,7 @@ LL | impl> Mirror for T {} | - ^^^^^^ ^ | | | unsatisfied trait bound implicitly introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting `Self` | LL | trait Foo: Super + Sized @@ -146,7 +145,7 @@ LL | fn transmute(&self) where Self: Sized {} | +++++++++++++++++ error[E0271]: type mismatch resolving `::Assoc == ()` - --> $DIR/unhandled-crate-mod-issue-144888.rs:14:30 + --> $DIR/unhandled-crate-mod-issue-144888.rs:16:30 | LL | trait Foo: Super | - found this type parameter @@ -163,10 +162,9 @@ LL | impl> Mirror for T {} | ---------- ^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/unhandled-crate-mod-issue-144888.rs:14:30 + --> $DIR/unhandled-crate-mod-issue-144888.rs:16:30 | LL | ::Assoc: Clone, | ^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/trivial-bounds/normalize-global-bounds-hrtb-issue-148630.rs b/tests/ui/trivial-bounds/normalize-global-bounds-hrtb-issue-148630.rs new file mode 100644 index 0000000000000..3d7fec94a6a07 --- /dev/null +++ b/tests/ui/trivial-bounds/normalize-global-bounds-hrtb-issue-148630.rs @@ -0,0 +1,22 @@ +// regression test for #148630 + +#![feature(unboxed_closures)] + +trait Tr {} +trait Foo { + fn foo() -> impl Sized + //~^ ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + //~| ERROR expected an `FnOnce<&'a i32>` closure, found `()` + where + for<'a> <() as FnOnce<&'a i32>>::Output: Tr, + { + } +} + +fn main() {} diff --git a/tests/ui/trivial-bounds/normalize-global-bounds-hrtb-issue-148630.stderr b/tests/ui/trivial-bounds/normalize-global-bounds-hrtb-issue-148630.stderr new file mode 100644 index 0000000000000..25fd0909deb73 --- /dev/null +++ b/tests/ui/trivial-bounds/normalize-global-bounds-hrtb-issue-148630.stderr @@ -0,0 +1,77 @@ +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:17 + | +LL | fn foo() -> impl Sized + | ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:17 + | +LL | fn foo() -> impl Sized + | ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:5 + | +LL | / fn foo() -> impl Sized +... | +LL | | where +LL | | for<'a> <() as FnOnce<&'a i32>>::Output: Tr, + | |____________________________________________________^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:5 + | +LL | / fn foo() -> impl Sized +... | +LL | | where +LL | | for<'a> <() as FnOnce<&'a i32>>::Output: Tr, + | |____________________________________________________^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:17 + | +LL | fn foo() -> impl Sized + | ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:22 + | +LL | fn foo() -> impl Sized + | ^^^^^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:17 + | +LL | fn foo() -> impl Sized + | ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0277]: expected an `FnOnce<&'a i32>` closure, found `()` + --> $DIR/normalize-global-bounds-hrtb-issue-148630.rs:7:17 + | +LL | fn foo() -> impl Sized + | ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()` + | + = help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/trivial-bounds/normalize-global-bounds-pass.rs b/tests/ui/trivial-bounds/normalize-global-bounds-pass.rs new file mode 100644 index 0000000000000..6ba63f393f6da --- /dev/null +++ b/tests/ui/trivial-bounds/normalize-global-bounds-pass.rs @@ -0,0 +1,51 @@ +// Normalize aliases before checking trivial bounds +// Regression test for #154145 and #140309 + +//@ check-pass + +#![allow(dead_code)] + +trait Trait { + type Assoc; +} + +impl Trait for T { + type Assoc = T; +} + +trait IceBaby {} +impl IceBaby for [u8; N] {} + +trait Hello {} +impl Hello for [(); N] {} + +trait Foo { + type Assoc; +} + +impl Foo for u32 { + type Assoc = u8; +} + +fn foo() +where + (): Trait, + <() as Trait>::Assoc: Sized, +{ +} + +fn bar() +where + (): Trait, + <() as Trait>::Assoc: IceBaby, +{ +} + +fn baz() +where + ::Assoc: Hello, + u32: Foo, +{ +} + +fn main() {} diff --git a/tests/ui/trivial-bounds/normalize-global-bounds.rs b/tests/ui/trivial-bounds/normalize-global-bounds.rs new file mode 100644 index 0000000000000..4f844e5a4ee98 --- /dev/null +++ b/tests/ui/trivial-bounds/normalize-global-bounds.rs @@ -0,0 +1,26 @@ +// Normalize aliases before checking trivial bounds +// Regression test for #154145 and #140309 + +trait Trait { + type Assoc; +} + +trait Impossible {} + +struct Inner(T); + +fn foo() +where + T: Trait, + ::Assoc: Copy, //~ ERROR the trait bound `String: Copy` is not satisfied +{ +} + +fn bar() +where + Inner: Impossible, + //~^ ERROR the trait bound `Inner fn(&'a ())>: Impossible` is not satisfied +{ +} + +fn main() {} diff --git a/tests/ui/trivial-bounds/normalize-global-bounds.stderr b/tests/ui/trivial-bounds/normalize-global-bounds.stderr new file mode 100644 index 0000000000000..b07f1dc85d34d --- /dev/null +++ b/tests/ui/trivial-bounds/normalize-global-bounds.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/normalize-global-bounds.rs:15:5 + | +LL | ::Assoc: Copy, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error[E0277]: the trait bound `Inner fn(&'a ())>: Impossible` is not satisfied + --> $DIR/normalize-global-bounds.rs:21:5 + | +LL | Inner: Impossible, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | +help: the trait `Impossible` is not implemented for `Inner fn(&'a ())>` + --> $DIR/normalize-global-bounds.rs:10:1 + | +LL | struct Inner(T); + | ^^^^^^^^^^^^^^^ +help: this trait has no implementations, consider adding one + --> $DIR/normalize-global-bounds.rs:8:1 + | +LL | trait Impossible {} + | ^^^^^^^^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-116864.current.stderr b/tests/ui/typeck/issue-116864.current.stderr index b3fbf6b0e570f..9abe2f674c147 100644 --- a/tests/ui/typeck/issue-116864.current.stderr +++ b/tests/ui/typeck/issue-116864.current.stderr @@ -18,6 +18,27 @@ LL | where LL | F: FnMut(P) -> FUT, | --------------- unsatisfied trait bound introduced here +error[E0277]: expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` + --> $DIR/issue-116864.rs:28:1 + | +LL | / async fn foo(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>) +... | +LL | | where +LL | | BAZ: Baz, + | |__________________________^ expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` + | + = note: expected a closure with signature `for<'any> fn(&'any i32)` + found a closure with signature `fn(&::Param)` +note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `for<'any> FnMutFut<&'any i32, ()>` + --> $DIR/issue-116864.rs:20:20 + | +LL | impl FnMutFut for F + | ^^^^^^^^^^^^^^ ^ +LL | where +LL | F: FnMut(P) -> FUT, + | --------------- unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0277]: expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` --> $DIR/issue-116864.rs:28:81 | @@ -41,7 +62,7 @@ LL | async fn foo(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` error[E0277]: expected an `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` - --> $DIR/issue-116864.rs:36:5 + --> $DIR/issue-116864.rs:37:5 | LL | cb(&1i32).await; | ^^^^^^^^^ expected an `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` @@ -58,7 +79,7 @@ LL | F: FnMut(P) -> FUT, | --------------- unsatisfied trait bound introduced here error[E0308]: mismatched types - --> $DIR/issue-116864.rs:36:8 + --> $DIR/issue-116864.rs:37:8 | LL | cb(&1i32).await; | -- ^^^^^ expected `&::Param`, found `&i32` @@ -102,7 +123,7 @@ LL | async fn foo(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-116864.rs b/tests/ui/typeck/issue-116864.rs index 568b56bfc44ee..47c37d257e3c0 100644 --- a/tests/ui/typeck/issue-116864.rs +++ b/tests/ui/typeck/issue-116864.rs @@ -30,6 +30,7 @@ async fn foo(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>) //[current]~^^ ERROR: expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` //[current]~| ERROR: expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` //[current]~| ERROR: expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` +//[current]~| ERROR: expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` where BAZ: Baz, { diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr b/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr index 6de4caa76ee0e..eb1285585ae43 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr +++ b/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr @@ -1,5 +1,21 @@ +error[E0277]: the trait bound `for<'a> fn(&'a ()): Foo` is not satisfied + --> $DIR/higher-ranked-fn-type.rs:18:5 + | +LL | (for<'a> fn(&'a ())): Foo, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `for<'a> fn(&'a ())` + | +help: this trait has no implementations, consider adding one + --> $DIR/higher-ranked-fn-type.rs:6:1 + | +LL | trait Foo { + | ^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + error[E0277]: the trait bound `for<'b> fn(&'b ()): Foo` is not satisfied - --> $DIR/higher-ranked-fn-type.rs:20:5 + --> $DIR/higher-ranked-fn-type.rs:22:5 | LL | called() | ^^^^^^^^ the trait `for<'b> Foo` is not implemented for `fn(&'b ())` @@ -18,6 +34,6 @@ LL | where LL | for<'b> fn(&'b ()): Foo, | ^^^ required by this bound in `called` -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.rs b/tests/ui/where-clauses/higher-ranked-fn-type.rs index 7ad7a896e8d38..9ba752b1df32e 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.rs +++ b/tests/ui/where-clauses/higher-ranked-fn-type.rs @@ -16,6 +16,8 @@ where fn caller() where (for<'a> fn(&'a ())): Foo, + //[quiet]~^ ERROR the trait bound `for<'a> fn(&'a ()): Foo` is not satisfied + //[verbose]~^^ ERROR the trait bound `for fn(&'b ()): Foo` is not satisfied diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr index 89a91a1f1ad7b..e8d8b55ae5f72 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr +++ b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr @@ -1,5 +1,22 @@ +error[E0277]: the trait bound `for fn(&'^0.Named(DefId(0:8 ~ higher_ranked_fn_type[9e51]::caller::'a)) ()): Foo` is not satisfied + --> $DIR/higher-ranked-fn-type.rs:18:5 + | +LL | (for<'a> fn(&'a ())): Foo, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound + | + = help: the trait `Foo` is not implemented for `for fn(&'^0.Named(DefId(0:8 ~ higher_ranked_fn_type[9e51]::caller::'a)) ())` +help: this trait has no implementations, consider adding one + --> $DIR/higher-ranked-fn-type.rs:6:1 + | +LL | trait Foo { + | ^^^^^^^^^ +help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + | +LL + #![feature(trivial_bounds)] + | + error[E0277]: the trait bound `for fn(&'^1_0.Named(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b)) ()): Foo` is not satisfied - --> $DIR/higher-ranked-fn-type.rs:20:5 + --> $DIR/higher-ranked-fn-type.rs:22:5 | LL | called() | ^^^^^^^^ unsatisfied trait bound @@ -19,6 +36,6 @@ LL | where LL | for<'b> fn(&'b ()): Foo, | ^^^ required by this bound in `called` -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`.