Skip to content

Commit 7a0f2e0

Browse files
wip
1 parent a201e67 commit 7a0f2e0

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
447447
) {
448448
if !ty.references_error() {
449449
let lang_item = self.tcx.require_lang_item(LangItem::Sized, None);
450-
self.require_type_meets(ty, span, code, lang_item);
450+
self.require_type_meets(
451+
self.normalize_associated_types_in(span, ty),
452+
span,
453+
code,
454+
lang_item,
455+
);
451456
}
452457
}
453458

src/test/ui/associated-types/issue-59324.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub trait ThriftService<Bug: NotFoo>:
1515
{
1616
fn get_service(
1717
//~^ ERROR the trait bound `Bug: Foo` is not satisfied
18-
&self,
18+
//~| ERROR the trait bound `Bug: Foo` is not satisfied
19+
&self,
1920
) -> Self::AssocType;
20-
//~^ the trait bound `Bug: Foo` is not satisfied
2121
}
2222

2323
fn with_factory<H>(factory: dyn ThriftService<()>) {}

src/test/ui/associated-types/issue-59324.stderr

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | |
66
LL | |
77
LL | | Service<AssocType = <Bug as Foo>::OnlyFoo>
88
... |
9-
LL | |
9+
LL | | ) -> Self::AssocType;
1010
LL | | }
1111
| |_^ the trait `Foo` is not implemented for `Bug`
1212
|
@@ -23,7 +23,7 @@ LL | |
2323
LL | |
2424
LL | | Service<AssocType = <Bug as Foo>::OnlyFoo>
2525
... |
26-
LL | |
26+
LL | | ) -> Self::AssocType;
2727
LL | | }
2828
| |_^ the trait `Foo` is not implemented for `Bug`
2929
|
@@ -37,7 +37,8 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied
3737
|
3838
LL | / fn get_service(
3939
LL | |
40-
LL | | &self,
40+
LL | |
41+
LL | | &self,
4142
LL | | ) -> Self::AssocType;
4243
| |_________________________^ the trait `Foo` is not implemented for `Bug`
4344
|
@@ -47,10 +48,10 @@ LL | pub trait ThriftService<Bug: NotFoo + Foo>:
4748
| +++++
4849

4950
error[E0277]: the trait bound `Bug: Foo` is not satisfied
50-
--> $DIR/issue-59324.rs:19:10
51+
--> $DIR/issue-59324.rs:16:8
5152
|
52-
LL | ) -> Self::AssocType;
53-
| ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug`
53+
LL | fn get_service(
54+
| ^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug`
5455
|
5556
help: consider further restricting this bound
5657
|

src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ note: previous use here
1010
LL | fn two<T: Debug + Foo, U: Debug>(t: T, u: U) -> Two<T, U> {
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error[E0277]: the trait bound `A: Foo` is not satisfied
13+
error[E0277]: the trait bound `A: Foo` is not satisfied in `(A, B, <A as Foo>::Bar)`
1414
--> $DIR/generic_duplicate_param_use9.rs:7:18
1515
|
1616
LL | type Two<A, B> = impl Debug;
17-
| ^^^^^^^^^^ the trait `Foo` is not implemented for `A`
17+
| ^^^^^^^^^^ within `(A, B, <A as Foo>::Bar)`, the trait `Foo` is not implemented for `A`
1818
|
19+
= note: required because it appears within the type `(A, B, <A as Foo>::Bar)`
1920
help: consider restricting type parameter `A`
2021
|
2122
LL | type Two<A: Foo, B> = impl Debug;
@@ -27,7 +28,7 @@ error[E0277]: `A` doesn't implement `Debug`
2728
LL | type Two<A, B> = impl Debug;
2829
| ^^^^^^^^^^ `A` cannot be formatted using `{:?}` because it doesn't implement `Debug`
2930
|
30-
= note: required because of the requirements on the impl of `Debug` for `(A, B, _)`
31+
= note: required because of the requirements on the impl of `Debug` for `(A, B, <A as Foo>::Bar)`
3132
help: consider restricting type parameter `A`
3233
|
3334
LL | type Two<A: std::fmt::Debug, B> = impl Debug;
@@ -39,7 +40,7 @@ error[E0277]: `B` doesn't implement `Debug`
3940
LL | type Two<A, B> = impl Debug;
4041
| ^^^^^^^^^^ `B` cannot be formatted using `{:?}` because it doesn't implement `Debug`
4142
|
42-
= note: required because of the requirements on the impl of `Debug` for `(A, B, _)`
43+
= note: required because of the requirements on the impl of `Debug` for `(A, B, <A as Foo>::Bar)`
4344
help: consider restricting type parameter `B`
4445
|
4546
LL | type Two<A, B: std::fmt::Debug> = impl Debug;

src/test/ui/type-alias-impl-trait/issue-89686.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::future::Future;
66

77
type G<'a, T> = impl Future<Output = ()>;
88
//~^ ERROR: the trait bound `T: Trait` is not satisfied
9+
//~| ERROR type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()`
910

1011
trait Trait {
1112
type F: Future<Output = ()>;

src/test/ui/type-alias-impl-trait/issue-89686.stderr

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as Future>::Output == ()`
2+
--> $DIR/issue-89686.rs:7:17
3+
|
4+
LL | type G<'a, T> = impl Future<Output = ()>;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
6+
...
7+
LL | async move { self.f().await }
8+
| ------------------ the found `async` block
9+
|
10+
::: $SRC_DIR/core/src/future/mod.rs:LL:COL
11+
|
12+
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
13+
| ------------------------------- the found opaque type
14+
|
15+
= note: expected unit type `()`
16+
found associated type `<impl Future<Output = [async output]> as Future>::Output`
17+
= help: consider constraining the associated type `<impl Future<Output = [async output]> as Future>::Output` to `()`
18+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
19+
120
error[E0277]: the trait bound `T: Trait` is not satisfied
221
--> $DIR/issue-89686.rs:7:17
322
|
@@ -9,6 +28,7 @@ help: consider restricting type parameter `T`
928
LL | type G<'a, T: Trait> = impl Future<Output = ()>;
1029
| +++++++
1130

12-
error: aborting due to previous error
31+
error: aborting due to 2 previous errors
1332

14-
For more information about this error, try `rustc --explain E0277`.
33+
Some errors have detailed explanations: E0271, E0277.
34+
For more information about an error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)