Skip to content

Commit cb41705

Browse files
authored
Unrolled build for rust-lang#127392
Rollup merge of rust-lang#127392 - estebank:arg-type, r=jieyouxu Use verbose suggestion for changing arg type
2 parents 51917e2 + 7569205 commit cb41705

27 files changed

+206
-163
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ fn report_trait_method_mismatch<'tcx>(
981981
.next()
982982
.unwrap_or(impl_err_span);
983983

984-
diag.span_suggestion(
984+
diag.span_suggestion_verbose(
985985
span,
986986
"change the self-receiver type to match the trait",
987987
sugg,
@@ -1005,12 +1005,12 @@ fn report_trait_method_mismatch<'tcx>(
10051005
}
10061006
hir::FnRetTy::Return(hir_ty) => {
10071007
let sugg = trait_sig.output();
1008-
diag.span_suggestion(hir_ty.span, msg, sugg, ap);
1008+
diag.span_suggestion_verbose(hir_ty.span, msg, sugg, ap);
10091009
}
10101010
};
10111011
};
10121012
} else if let Some(trait_ty) = trait_sig.inputs().get(*i) {
1013-
diag.span_suggestion(
1013+
diag.span_suggestion_verbose(
10141014
impl_err_span,
10151015
"change the parameter type to match the trait",
10161016
trait_ty,

tests/ui/associated-types/defaults-specialization.stderr

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ error[E0053]: method `make` has an incompatible type for trait
1212
--> $DIR/defaults-specialization.rs:19:18
1313
|
1414
LL | fn make() -> u8 { 0 }
15-
| ^^
16-
| |
17-
| expected associated type, found `u8`
18-
| help: change the output type to match the trait: `<A<T> as Tr>::Ty`
15+
| ^^ expected associated type, found `u8`
1916
|
2017
note: type in trait
2118
--> $DIR/defaults-specialization.rs:9:18
@@ -24,6 +21,10 @@ LL | fn make() -> Self::Ty {
2421
| ^^^^^^^^
2522
= note: expected signature `fn() -> <A<T> as Tr>::Ty`
2623
found signature `fn() -> u8`
24+
help: change the output type to match the trait
25+
|
26+
LL | fn make() -> <A<T> as Tr>::Ty { 0 }
27+
| ~~~~~~~~~~~~~~~~
2728

2829
error[E0053]: method `make` has an incompatible type for trait
2930
--> $DIR/defaults-specialization.rs:35:18
@@ -32,10 +33,7 @@ LL | default type Ty = bool;
3233
| ----------------------- associated type is `default` and may be overridden
3334
LL |
3435
LL | fn make() -> bool { true }
35-
| ^^^^
36-
| |
37-
| expected associated type, found `bool`
38-
| help: change the output type to match the trait: `<B<T> as Tr>::Ty`
36+
| ^^^^ expected associated type, found `bool`
3937
|
4038
note: type in trait
4139
--> $DIR/defaults-specialization.rs:9:18
@@ -44,6 +42,10 @@ LL | fn make() -> Self::Ty {
4442
| ^^^^^^^^
4543
= note: expected signature `fn() -> <B<T> as Tr>::Ty`
4644
found signature `fn() -> bool`
45+
help: change the output type to match the trait
46+
|
47+
LL | fn make() -> <B<T> as Tr>::Ty { true }
48+
| ~~~~~~~~~~~~~~~~
4749

4850
error[E0308]: mismatched types
4951
--> $DIR/defaults-specialization.rs:10:9

tests/ui/compare-method/bad-self-type.stderr

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@ error[E0053]: method `poll` has an incompatible type for trait
22
--> $DIR/bad-self-type.rs:10:13
33
|
44
LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> {
5-
| ^^^^
6-
| |
7-
| expected `Pin<&mut MyFuture>`, found `MyFuture`
8-
| help: change the self-receiver type to match the trait: `self: Pin<&mut MyFuture>`
5+
| ^^^^ expected `Pin<&mut MyFuture>`, found `MyFuture`
96
|
107
= note: expected signature `fn(Pin<&mut MyFuture>, &mut Context<'_>) -> Poll<_>`
118
found signature `fn(MyFuture, &mut Context<'_>) -> Poll<_>`
9+
help: change the self-receiver type to match the trait
10+
|
11+
LL | fn poll(self: Pin<&mut MyFuture>, _: &mut Context<'_>) -> Poll<()> {
12+
| ~~~~~~~~~~~~~~~~~~~~~~~~
1213

1314
error[E0053]: method `foo` has an incompatible type for trait
1415
--> $DIR/bad-self-type.rs:22:18
1516
|
1617
LL | fn foo(self: Box<Self>) {}
17-
| ------^^^^^^^^^
18-
| | |
19-
| | expected `MyFuture`, found `Box<MyFuture>`
20-
| help: change the self-receiver type to match the trait: `self`
18+
| ^^^^^^^^^ expected `MyFuture`, found `Box<MyFuture>`
2119
|
2220
note: type in trait
2321
--> $DIR/bad-self-type.rs:17:12
@@ -26,6 +24,10 @@ LL | fn foo(self);
2624
| ^^^^
2725
= note: expected signature `fn(MyFuture)`
2826
found signature `fn(Box<MyFuture>)`
27+
help: change the self-receiver type to match the trait
28+
|
29+
LL | fn foo(self) {}
30+
| ~~~~
2931

3032
error[E0053]: method `bar` has an incompatible type for trait
3133
--> $DIR/bad-self-type.rs:24:17

tests/ui/compare-method/issue-90444.stderr

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ error[E0053]: method `from` has an incompatible type for trait
22
--> $DIR/issue-90444.rs:3:16
33
|
44
LL | fn from(_: fn((), (), &mut ())) -> Self {
5-
| ^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| types differ in mutability
8-
| help: change the parameter type to match the trait: `for<'a> fn((), (), &'a ())`
5+
| ^^^^^^^^^^^^^^^^^^^ types differ in mutability
96
|
107
= note: expected signature `fn(for<'a> fn((), (), &'a ())) -> A`
118
found signature `fn(for<'a> fn((), (), &'a mut ())) -> A`
9+
help: change the parameter type to match the trait
10+
|
11+
LL | fn from(_: for<'a> fn((), (), &'a ())) -> Self {
12+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
1213

1314
error[E0053]: method `from` has an incompatible type for trait
1415
--> $DIR/issue-90444.rs:11:16
1516
|
1617
LL | fn from(_: fn((), (), u64)) -> Self {
17-
| ^^^^^^^^^^^^^^^
18-
| |
19-
| expected `u32`, found `u64`
20-
| help: change the parameter type to match the trait: `fn((), (), u32)`
18+
| ^^^^^^^^^^^^^^^ expected `u32`, found `u64`
2119
|
2220
= note: expected signature `fn(fn((), (), u32)) -> B`
2321
found signature `fn(fn((), (), u64)) -> B`
22+
help: change the parameter type to match the trait
23+
|
24+
LL | fn from(_: fn((), (), u32)) -> Self {
25+
| ~~~~~~~~~~~~~~~
2426

2527
error: aborting due to 2 previous errors
2628

tests/ui/compare-method/reordered-type-param.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ error[E0053]: method `b` has an incompatible type for trait
22
--> $DIR/reordered-type-param.rs:16:30
33
|
44
LL | fn b<F:Clone,G>(&self, _x: G) -> G { panic!() }
5-
| - - ^
6-
| | | |
7-
| | | expected type parameter `F`, found type parameter `G`
8-
| | | help: change the parameter type to match the trait: `F`
5+
| - - ^ expected type parameter `F`, found type parameter `G`
6+
| | |
97
| | found type parameter
108
| expected type parameter
119
|
@@ -18,6 +16,10 @@ LL | fn b<C:Clone,D>(&self, x: C) -> C;
1816
found signature `fn(&E, G) -> G`
1917
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
2018
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
19+
help: change the parameter type to match the trait
20+
|
21+
LL | fn b<F:Clone,G>(&self, _x: F) -> G { panic!() }
22+
| ~
2123

2224
error: aborting due to 1 previous error
2325

tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr

+10-8
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ error[E0053]: method `call` has an incompatible type for trait
8989
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32
9090
|
9191
LL | extern "rust-call" fn call(self, args: ()) -> () {}
92-
| ^^^^
93-
| |
94-
| expected `&Foo`, found `Foo`
95-
| help: change the self-receiver type to match the trait: `&self`
92+
| ^^^^ expected `&Foo`, found `Foo`
9693
|
9794
= note: expected signature `extern "rust-call" fn(&Foo, ()) -> _`
9895
found signature `extern "rust-call" fn(Foo, ())`
96+
help: change the self-receiver type to match the trait
97+
|
98+
LL | extern "rust-call" fn call(&self, args: ()) -> () {}
99+
| ~~~~~
99100

100101
error[E0183]: manual implementations of `FnOnce` are experimental
101102
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:18:6
@@ -158,13 +159,14 @@ error[E0053]: method `call_mut` has an incompatible type for trait
158159
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:36
159160
|
160161
LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {}
161-
| ^^^^^
162-
| |
163-
| types differ in mutability
164-
| help: change the self-receiver type to match the trait: `&mut self`
162+
| ^^^^^ types differ in mutability
165163
|
166164
= note: expected signature `extern "rust-call" fn(&mut Bar, ()) -> _`
167165
found signature `extern "rust-call" fn(&Bar, ())`
166+
help: change the self-receiver type to match the trait
167+
|
168+
LL | extern "rust-call" fn call_mut(&mut self, args: ()) -> () {}
169+
| ~~~~~~~~~
168170

169171
error[E0046]: not all trait items implemented, missing: `Output`
170172
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:35:1

tests/ui/impl-trait/impl-generic-mismatch-ab.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ error[E0053]: method `foo` has an incompatible type for trait
22
--> $DIR/impl-generic-mismatch-ab.rs:8:32
33
|
44
LL | fn foo<B: Debug>(&self, a: &impl Debug, b: &B) { }
5-
| - ^^^^^^^^^^^
6-
| | |
7-
| | expected type parameter `B`, found type parameter `impl Debug`
8-
| | help: change the parameter type to match the trait: `&B`
5+
| - ^^^^^^^^^^^ expected type parameter `B`, found type parameter `impl Debug`
6+
| |
97
| expected type parameter
108
|
119
note: type in trait
@@ -17,6 +15,10 @@ LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug);
1715
found signature `fn(&(), &impl Debug, &B)`
1816
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
1917
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
18+
help: change the parameter type to match the trait
19+
|
20+
LL | fn foo<B: Debug>(&self, a: &B, b: &B) { }
21+
| ~~
2022

2123
error: aborting due to 1 previous error
2224

tests/ui/impl-trait/in-assoc-type-unconstrained.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ LL | type Ty = impl Sized;
2727
| ---------- the expected opaque type
2828
LL |
2929
LL | fn method() -> () {}
30-
| ^^
31-
| |
32-
| expected opaque type, found `()`
33-
| help: change the output type to match the trait: `<() as compare_method::Trait>::Ty`
30+
| ^^ expected opaque type, found `()`
3431
|
3532
note: type in trait
3633
--> $DIR/in-assoc-type-unconstrained.rs:17:24
@@ -44,6 +41,10 @@ note: this item must have the opaque type in its signature in order to be able t
4441
|
4542
LL | fn method() -> () {}
4643
| ^^^^^^
44+
help: change the output type to match the trait
45+
|
46+
LL | fn method() -> <() as compare_method::Trait>::Ty {}
47+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4748

4849
error: unconstrained opaque type
4950
--> $DIR/in-assoc-type-unconstrained.rs:20:19

tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ error[E0053]: method `early` has an incompatible type for trait
22
--> $DIR/method-signature-matches.rs:55:27
33
|
44
LL | fn early<'late, T>(_: &'late ()) {}
5-
| - ^^^^^^^^^
6-
| | |
7-
| | expected type parameter `T`, found `()`
8-
| | help: change the parameter type to match the trait: `&T`
5+
| - ^^^^^^^^^ expected type parameter `T`, found `()`
6+
| |
97
| expected this type parameter
108
|
119
note: type in trait
@@ -15,6 +13,10 @@ LL | fn early<'early, T>(x: &'early T) -> impl Sized;
1513
| ^^^^^^^^^
1614
= note: expected signature `fn(&T)`
1715
found signature `fn(&'late ())`
16+
help: change the parameter type to match the trait
17+
|
18+
LL | fn early<'late, T>(_: &T) {}
19+
| ~~
1820

1921
error: aborting due to 1 previous error
2022

tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0053]: method `owo` has an incompatible type for trait
22
--> $DIR/method-signature-matches.rs:11:15
33
|
44
LL | fn owo(_: u8) {}
5-
| ^^
6-
| |
7-
| expected `()`, found `u8`
8-
| help: change the parameter type to match the trait: `()`
5+
| ^^ expected `()`, found `u8`
96
|
107
note: type in trait
118
--> $DIR/method-signature-matches.rs:6:15
@@ -14,6 +11,10 @@ LL | fn owo(x: ()) -> impl Sized;
1411
| ^^
1512
= note: expected signature `fn(())`
1613
found signature `fn(u8)`
14+
help: change the parameter type to match the trait
15+
|
16+
LL | fn owo(_: ()) {}
17+
| ~~
1718

1819
error: aborting due to 1 previous error
1920

tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ error[E0053]: method `owo` has an incompatible type for trait
22
--> $DIR/method-signature-matches.rs:22:21
33
|
44
LL | async fn owo(_: u8) {}
5-
| ^^
6-
| |
7-
| expected `()`, found `u8`
8-
| help: change the parameter type to match the trait: `()`
5+
| ^^ expected `()`, found `u8`
96
|
107
note: type in trait
118
--> $DIR/method-signature-matches.rs:17:21
@@ -14,6 +11,10 @@ LL | async fn owo(x: ()) {}
1411
| ^^
1512
= note: expected signature `fn(()) -> _`
1613
found signature `fn(u8) -> _`
14+
help: change the parameter type to match the trait
15+
|
16+
LL | async fn owo(_: ()) {}
17+
| ~~
1718

1819
error: aborting due to 1 previous error
1920

tests/ui/impl-trait/in-trait/opaque-and-lifetime-mismatch.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ error[E0053]: method `bar` has an incompatible type for trait
7575
--> $DIR/opaque-and-lifetime-mismatch.rs:10:17
7676
|
7777
LL | fn bar() -> i32 {
78-
| ^^^
79-
| |
80-
| expected `Wrapper<'static>`, found `i32`
81-
| help: change the output type to match the trait: `Wrapper<'static>`
78+
| ^^^ expected `Wrapper<'static>`, found `i32`
8279
|
8380
note: type in trait
8481
--> $DIR/opaque-and-lifetime-mismatch.rs:4:17
@@ -87,6 +84,10 @@ LL | fn bar() -> Wrapper<impl Sized>;
8784
| ^^^^^^^^^^^^^^^^^^^
8885
= note: expected signature `fn() -> Wrapper<'static>`
8986
found signature `fn() -> i32`
87+
help: change the output type to match the trait
88+
|
89+
LL | fn bar() -> Wrapper<'static> {
90+
| ~~~~~~~~~~~~~~~~
9091

9192
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
9293
--> $DIR/opaque-and-lifetime-mismatch.rs:24:17

tests/ui/impl-trait/in-trait/specialization-broken.stderr

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | default impl<U> Foo for U
55
| - found this type parameter
66
...
77
LL | fn bar(&self) -> U {
8-
| ^
9-
| |
10-
| expected associated type, found type parameter `U`
11-
| help: change the output type to match the trait: `impl Sized`
8+
| ^ expected associated type, found type parameter `U`
129
|
1310
note: type in trait
1411
--> $DIR/specialization-broken.rs:8:22
@@ -17,6 +14,10 @@ LL | fn bar(&self) -> impl Sized;
1714
| ^^^^^^^^^^
1815
= note: expected signature `fn(&_) -> impl Sized`
1916
found signature `fn(&_) -> U`
17+
help: change the output type to match the trait
18+
|
19+
LL | fn bar(&self) -> impl Sized {
20+
| ~~~~~~~~~~
2021

2122
error: method with return-position `impl Trait` in trait cannot be specialized
2223
--> $DIR/specialization-broken.rs:15:5

0 commit comments

Comments
 (0)