From ef11db803cd6aa8aea6ba501fea62f8c6601294c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 26 Aug 2023 19:35:54 +0000 Subject: [PATCH] Remove unnecessary `select_obligations_where_possible` and redundant errors --- compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs | 1 - ...ted-types-invalid-trait-ref-issue-18865.rs | 1 - ...types-invalid-trait-ref-issue-18865.stderr | 13 +---- .../multiple-type-params-with-unmet-bounds.rs | 1 - ...tiple-type-params-with-unmet-bounds.stderr | 14 +---- .../own-bound-span.rs | 4 -- .../own-bound-span.stderr | 16 +----- tests/ui/issues/issue-66353.rs | 1 - tests/ui/issues/issue-66353.stderr | 8 +-- .../assoc_type_bounds_sized_used.rs | 1 - .../assoc_type_bounds_sized_used.stderr | 54 ++++++------------- .../assoc-type-const-bound-usage.stderr | 13 +---- 12 files changed, 22 insertions(+), 105 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 45bf43efa83..823422fab14 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -322,7 +322,6 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { ty.kind() { self.add_required_obligations_for_hir(span, *def_id, args, hir_id); - self.select_obligations_where_possible(|_| {}); } self.normalize(span, ty) } else { diff --git a/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.rs b/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.rs index 473a68833b6..3bd3f3a757c 100644 --- a/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.rs +++ b/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.rs @@ -9,7 +9,6 @@ trait Foo { fn f>(t: &T) { let u: >::Bar = t.get_bar(); //~^ ERROR the trait bound `T: Foo` is not satisfied - //~| ERROR the trait bound `T: Foo` is not satisfied } fn main() { } diff --git a/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr b/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr index fc63f4b3e30..676d6353d98 100644 --- a/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr +++ b/tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr @@ -9,17 +9,6 @@ help: consider further restricting this bound LL | fn f + Foo>(t: &T) { | ++++++++++++ -error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:12 - | -LL | let u: >::Bar = t.get_bar(); - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` - | -help: consider further restricting this bound - | -LL | fn f + Foo>(t: &T) { - | ++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs index ffb45f4bc75..b127b3f6e1f 100644 --- a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs +++ b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs @@ -7,5 +7,4 @@ impl Trait for () { fn main() { let _: <() as Trait>::P; //~^ ERROR the trait bound `String: Copy` is not satisfied - //~| ERROR the trait bound `String: Copy` is not satisfied } diff --git a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr index 7f3b75c0629..72a987b4a1d 100644 --- a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr +++ b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr @@ -10,18 +10,6 @@ note: required by a bound in `Trait::P` LL | type P; | ^^^^ required by this bound in `Trait::P` -error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/multiple-type-params-with-unmet-bounds.rs:8:12 - | -LL | let _: <() as Trait>::P; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` - | -note: required by a bound in `Trait::P` - --> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15 - | -LL | type P; - | ^^^^ required by this bound in `Trait::P` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-associated-types/own-bound-span.rs b/tests/ui/generic-associated-types/own-bound-span.rs index 72d0fd9897f..3699f7296f5 100644 --- a/tests/ui/generic-associated-types/own-bound-span.rs +++ b/tests/ui/generic-associated-types/own-bound-span.rs @@ -4,8 +4,6 @@ trait D { type P; //~^ NOTE required by this bound in `D::P` //~| NOTE required by a bound in `D::P` - //~| NOTE required by this bound in `D::P` - //~| NOTE required by a bound in `D::P` } impl D for S { @@ -16,6 +14,4 @@ fn main() { let _: ::P; //~^ ERROR the trait bound `String: Copy` is not satisfied //~| NOTE the trait `Copy` is not implemented for `String` - //~| ERROR the trait bound `String: Copy` is not satisfied - //~| NOTE the trait `Copy` is not implemented for `String` } diff --git a/tests/ui/generic-associated-types/own-bound-span.stderr b/tests/ui/generic-associated-types/own-bound-span.stderr index 98bf55bc208..4a0566ca7b5 100644 --- a/tests/ui/generic-associated-types/own-bound-span.stderr +++ b/tests/ui/generic-associated-types/own-bound-span.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/own-bound-span.rs:16:24 + --> $DIR/own-bound-span.rs:14:24 | LL | let _: ::P; | ^^^^^^ the trait `Copy` is not implemented for `String` @@ -10,18 +10,6 @@ note: required by a bound in `D::P` LL | type P; | ^^^^ required by this bound in `D::P` -error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/own-bound-span.rs:16:12 - | -LL | let _: ::P; - | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` - | -note: required by a bound in `D::P` - --> $DIR/own-bound-span.rs:4:15 - | -LL | type P; - | ^^^^ required by this bound in `D::P` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-66353.rs b/tests/ui/issues/issue-66353.rs index 484a28e564b..d8abdd5206e 100644 --- a/tests/ui/issues/issue-66353.rs +++ b/tests/ui/issues/issue-66353.rs @@ -11,6 +11,5 @@ trait _A { fn main() { _Func::< <() as _A>::AssocT >::func(()); //~^ ERROR the trait bound `(): _A` is not satisfied - //~| ERROR the trait bound `(): _A` is not satisfied //~| ERROR the trait bound `(): _Func<_>` is not satisfied } diff --git a/tests/ui/issues/issue-66353.stderr b/tests/ui/issues/issue-66353.stderr index 49eb013c1d8..71530f58220 100644 --- a/tests/ui/issues/issue-66353.stderr +++ b/tests/ui/issues/issue-66353.stderr @@ -4,12 +4,6 @@ error[E0277]: the trait bound `(): _A` is not satisfied LL | _Func::< <() as _A>::AssocT >::func(()); | ^^ the trait `_A` is not implemented for `()` -error[E0277]: the trait bound `(): _A` is not satisfied - --> $DIR/issue-66353.rs:12:14 - | -LL | _Func::< <() as _A>::AssocT >::func(()); - | ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()` - error[E0277]: the trait bound `(): _Func<_>` is not satisfied --> $DIR/issue-66353.rs:12:41 | @@ -18,6 +12,6 @@ LL | _Func::< <() as _A>::AssocT >::func(()); | | | required by a bound introduced by this call -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.rs b/tests/ui/object-safety/assoc_type_bounds_sized_used.rs index f685a7f626f..cf5345b1c1d 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_used.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.rs @@ -12,7 +12,6 @@ fn bop() { let _ = ::Bar::default(); //~^ ERROR: trait bounds were not satisfied //~| ERROR: the size for values of type `T` cannot be known at compilation time - //~| ERROR: the size for values of type `T` cannot be known at compilation time } fn main() { diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr index f551d657ab5..6b5bc360349 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr @@ -1,3 +1,17 @@ +error[E0599]: the function or associated item `default` exists for associated type `::Bar`, but its trait bounds were not satisfied + --> $DIR/assoc_type_bounds_sized_used.rs:12:30 + | +LL | let _ = ::Bar::default(); + | ^^^^^^^ function or associated item cannot be called on `::Bar` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `T: Sized` + which is required by `::Bar: Default` +help: consider restricting the type parameter to satisfy the trait bound + | +LL | fn bop() where T: Sized { + | ++++++++++++++ + error[E0277]: the size for values of type `T` cannot be known at compilation time --> $DIR/assoc_type_bounds_sized_used.rs:12:14 | @@ -20,44 +34,8 @@ LL - fn bop() { LL + fn bop() { | -error[E0599]: the function or associated item `default` exists for associated type `::Bar`, but its trait bounds were not satisfied - --> $DIR/assoc_type_bounds_sized_used.rs:12:30 - | -LL | let _ = ::Bar::default(); - | ^^^^^^^ function or associated item cannot be called on `::Bar` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `T: Sized` - which is required by `::Bar: Default` -help: consider restricting the type parameter to satisfy the trait bound - | -LL | fn bop() where T: Sized { - | ++++++++++++++ - -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:12:13 - | -LL | fn bop() { - | - this type parameter needs to be `Sized` -LL | let _ = ::Bar::default(); - | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -note: required by a bound in `Bop::Bar` - --> $DIR/assoc_type_bounds_sized_used.rs:8:15 - | -LL | type Bar: Default - | --- required by a bound in this associated type -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bop::Bar` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn bop() { -LL + fn bop() { - | - error[E0277]: the size for values of type `dyn Bop` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:19:11 + --> $DIR/assoc_type_bounds_sized_used.rs:18:11 | LL | bop::(); | ^^^^^^^ doesn't have a size known at compile-time @@ -69,7 +47,7 @@ note: required by a bound in `bop` LL | fn bop() { | ^^^ required by this bound in `bop` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr index 72ff11d586f..ad11c090f12 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr @@ -9,17 +9,6 @@ help: consider further restricting this bound LL | const fn foo() { | +++++ -error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/assoc-type-const-bound-usage.rs:12:5 - | -LL | ::Assoc::foo(); - | ^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` - | -help: consider further restricting this bound - | -LL | const fn foo() { - | +++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`.