Skip to content

Commit ef11db8

Browse files
committed
Remove unnecessary select_obligations_where_possible and redundant errors
1 parent b6494a7 commit ef11db8

12 files changed

+10
-93
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
322322
ty.kind()
323323
{
324324
self.add_required_obligations_for_hir(span, *def_id, args, hir_id);
325-
self.select_obligations_where_possible(|_| {});
326325
}
327326
self.normalize(span, ty)
328327
} else {

tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ trait Foo<T> {
99
fn f<T:Foo<isize>>(t: &T) {
1010
let u: <T as Foo<usize>>::Bar = t.get_bar();
1111
//~^ ERROR the trait bound `T: Foo<usize>` is not satisfied
12-
//~| ERROR the trait bound `T: Foo<usize>` is not satisfied
1312
}
1413

1514
fn main() { }

tests/ui/associated-types/associated-types-invalid-trait-ref-issue-18865.stderr

+1-12
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ help: consider further restricting this bound
99
LL | fn f<T:Foo<isize> + Foo<usize>>(t: &T) {
1010
| ++++++++++++
1111

12-
error[E0277]: the trait bound `T: Foo<usize>` is not satisfied
13-
--> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:12
14-
|
15-
LL | let u: <T as Foo<usize>>::Bar = t.get_bar();
16-
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo<usize>` is not implemented for `T`
17-
|
18-
help: consider further restricting this bound
19-
|
20-
LL | fn f<T:Foo<isize> + Foo<usize>>(t: &T) {
21-
| ++++++++++++
22-
23-
error: aborting due to 2 previous errors
12+
error: aborting due to previous error
2413

2514
For more information about this error, try `rustc --explain E0277`.

tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ impl Trait for () {
77
fn main() {
88
let _: <() as Trait>::P<String, String>;
99
//~^ ERROR the trait bound `String: Copy` is not satisfied
10-
//~| ERROR the trait bound `String: Copy` is not satisfied
1110
}

tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr

+1-13
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ note: required by a bound in `Trait::P`
1010
LL | type P<T: Copy, U: Copy>;
1111
| ^^^^ required by this bound in `Trait::P`
1212

13-
error[E0277]: the trait bound `String: Copy` is not satisfied
14-
--> $DIR/multiple-type-params-with-unmet-bounds.rs:8:12
15-
|
16-
LL | let _: <() as Trait>::P<String, String>;
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
18-
|
19-
note: required by a bound in `Trait::P`
20-
--> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15
21-
|
22-
LL | type P<T: Copy, U: Copy>;
23-
| ^^^^ required by this bound in `Trait::P`
24-
25-
error: aborting due to 2 previous errors
13+
error: aborting due to previous error
2614

2715
For more information about this error, try `rustc --explain E0277`.

tests/ui/generic-associated-types/own-bound-span.rs

-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ trait D {
44
type P<T: Copy>;
55
//~^ NOTE required by this bound in `D::P`
66
//~| NOTE required by a bound in `D::P`
7-
//~| NOTE required by this bound in `D::P`
8-
//~| NOTE required by a bound in `D::P`
97
}
108

119
impl D for S {
@@ -16,6 +14,4 @@ fn main() {
1614
let _: <S as D>::P<String>;
1715
//~^ ERROR the trait bound `String: Copy` is not satisfied
1816
//~| NOTE the trait `Copy` is not implemented for `String`
19-
//~| ERROR the trait bound `String: Copy` is not satisfied
20-
//~| NOTE the trait `Copy` is not implemented for `String`
2117
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `String: Copy` is not satisfied
2-
--> $DIR/own-bound-span.rs:16:24
2+
--> $DIR/own-bound-span.rs:14:24
33
|
44
LL | let _: <S as D>::P<String>;
55
| ^^^^^^ the trait `Copy` is not implemented for `String`
@@ -10,18 +10,6 @@ note: required by a bound in `D::P`
1010
LL | type P<T: Copy>;
1111
| ^^^^ required by this bound in `D::P`
1212

13-
error[E0277]: the trait bound `String: Copy` is not satisfied
14-
--> $DIR/own-bound-span.rs:16:12
15-
|
16-
LL | let _: <S as D>::P<String>;
17-
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
18-
|
19-
note: required by a bound in `D::P`
20-
--> $DIR/own-bound-span.rs:4:15
21-
|
22-
LL | type P<T: Copy>;
23-
| ^^^^ required by this bound in `D::P`
24-
25-
error: aborting due to 2 previous errors
13+
error: aborting due to previous error
2614

2715
For more information about this error, try `rustc --explain E0277`.

tests/ui/issues/issue-66353.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ trait _A {
1111
fn main() {
1212
_Func::< <() as _A>::AssocT >::func(());
1313
//~^ ERROR the trait bound `(): _A` is not satisfied
14-
//~| ERROR the trait bound `(): _A` is not satisfied
1514
//~| ERROR the trait bound `(): _Func<_>` is not satisfied
1615
}

tests/ui/issues/issue-66353.stderr

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error[E0277]: the trait bound `(): _A` is not satisfied
44
LL | _Func::< <() as _A>::AssocT >::func(());
55
| ^^ the trait `_A` is not implemented for `()`
66

7-
error[E0277]: the trait bound `(): _A` is not satisfied
8-
--> $DIR/issue-66353.rs:12:14
9-
|
10-
LL | _Func::< <() as _A>::AssocT >::func(());
11-
| ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()`
12-
137
error[E0277]: the trait bound `(): _Func<_>` is not satisfied
148
--> $DIR/issue-66353.rs:12:41
159
|
@@ -18,6 +12,6 @@ LL | _Func::< <() as _A>::AssocT >::func(());
1812
| |
1913
| required by a bound introduced by this call
2014

21-
error: aborting due to 3 previous errors
15+
error: aborting due to 2 previous errors
2216

2317
For more information about this error, try `rustc --explain E0277`.

tests/ui/object-safety/assoc_type_bounds_sized_used.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn bop<T: Bop + ?Sized>() {
1212
let _ = <T as Bop>::Bar::default();
1313
//~^ ERROR: trait bounds were not satisfied
1414
//~| ERROR: the size for values of type `T` cannot be known at compilation time
15-
//~| ERROR: the size for values of type `T` cannot be known at compilation time
1615
}
1716

1817
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
error[E0277]: the size for values of type `T` cannot be known at compilation time
2-
--> $DIR/assoc_type_bounds_sized_used.rs:12:14
3-
|
4-
LL | fn bop<T: Bop + ?Sized>() {
5-
| - this type parameter needs to be `Sized`
6-
LL | let _ = <T as Bop>::Bar::default();
7-
| ^ doesn't have a size known at compile-time
8-
|
9-
note: required by a bound in `Bop::Bar`
10-
--> $DIR/assoc_type_bounds_sized_used.rs:8:15
11-
|
12-
LL | type Bar: Default
13-
| --- required by a bound in this associated type
14-
LL | where
15-
LL | Self: Sized;
16-
| ^^^^^ required by this bound in `Bop::Bar`
17-
help: consider removing the `?Sized` bound to make the type parameter `Sized`
18-
|
19-
LL - fn bop<T: Bop + ?Sized>() {
20-
LL + fn bop<T: Bop>() {
21-
|
22-
231
error[E0599]: the function or associated item `default` exists for associated type `<T as Bop>::Bar`, but its trait bounds were not satisfied
242
--> $DIR/assoc_type_bounds_sized_used.rs:12:30
253
|
@@ -35,12 +13,12 @@ LL | fn bop<T: Bop + ?Sized>() where T: Sized {
3513
| ++++++++++++++
3614

3715
error[E0277]: the size for values of type `T` cannot be known at compilation time
38-
--> $DIR/assoc_type_bounds_sized_used.rs:12:13
16+
--> $DIR/assoc_type_bounds_sized_used.rs:12:14
3917
|
4018
LL | fn bop<T: Bop + ?Sized>() {
4119
| - this type parameter needs to be `Sized`
4220
LL | let _ = <T as Bop>::Bar::default();
43-
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
21+
| ^ doesn't have a size known at compile-time
4422
|
4523
note: required by a bound in `Bop::Bar`
4624
--> $DIR/assoc_type_bounds_sized_used.rs:8:15
@@ -57,7 +35,7 @@ LL + fn bop<T: Bop>() {
5735
|
5836

5937
error[E0277]: the size for values of type `dyn Bop` cannot be known at compilation time
60-
--> $DIR/assoc_type_bounds_sized_used.rs:19:11
38+
--> $DIR/assoc_type_bounds_sized_used.rs:18:11
6139
|
6240
LL | bop::<dyn Bop>();
6341
| ^^^^^^^ doesn't have a size known at compile-time
@@ -69,7 +47,7 @@ note: required by a bound in `bop`
6947
LL | fn bop<T: Bop + ?Sized>() {
7048
| ^^^ required by this bound in `bop`
7149

72-
error: aborting due to 4 previous errors
50+
error: aborting due to 3 previous errors
7351

7452
Some errors have detailed explanations: E0277, E0599.
7553
For more information about an error, try `rustc --explain E0277`.

tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.stderr

+1-12
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ help: consider further restricting this bound
99
LL | const fn foo<T: ~const Foo + Foo>() {
1010
| +++++
1111

12-
error[E0277]: the trait bound `T: Foo` is not satisfied
13-
--> $DIR/assoc-type-const-bound-usage.rs:12:5
14-
|
15-
LL | <T as Foo>::Assoc::foo();
16-
| ^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
17-
|
18-
help: consider further restricting this bound
19-
|
20-
LL | const fn foo<T: ~const Foo + Foo>() {
21-
| +++++
22-
23-
error: aborting due to 2 previous errors
12+
error: aborting due to previous error
2413

2514
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)