Skip to content

Commit 942dde5

Browse files
committed
Don't suggest changing ret ty for trait methods
1 parent d8fb04e commit 942dde5

12 files changed

+2
-87
lines changed

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,11 +1199,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11991199

12001200
if let Some(local_did) = def_id.as_local()
12011201
&& let Some(node) = self.tcx.opt_hir_node(self.tcx.local_def_id_to_hir_id(local_did))
1202-
&& let hir::Node::TraitItem(hir::TraitItem {
1203-
kind: hir::TraitItemKind::Fn(sig, ..),
1204-
..
1205-
})
1206-
| hir::Node::ImplItem(hir::ImplItem {
1202+
&& let hir::Node::ImplItem(hir::ImplItem {
12071203
kind: hir::ImplItemKind::Fn(sig, ..), ..
12081204
})
12091205
| hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, ..), .. }) = node

tests/ui/associated-type-bounds/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.rs:24:37
33
|
4-
LL | fn identify(&self) -> Self::Id;
5-
| -------- help: consider changing identify's return type: `&I`
6-
...
74
LL | let _low = self.lows.remove(low.identify()).unwrap();
85
| ------ ^^^^^^^^^^^^^^ expected `&I`, found associated type
96
| |

tests/ui/associated-types/associated-types-eq-3.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ help: consider constraining the associated type `<I as Foo>::A` to `Bar`
1717
|
1818
LL | fn foo2<I: Foo<A = Bar>>(x: I) {
1919
| +++++++++
20-
help: consider changing boo's return type
21-
|
22-
LL | fn boo(&self) -> Bar;
23-
| ~~~
2420

2521
error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
2622
--> $DIR/associated-types-eq-3.rs:38:10

tests/ui/impl-trait/equality2.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ help: consider constraining the associated type `<impl Foo as Leak>::T` to `i32`
5252
|
5353
LL | fn hide<T: Foo>(x: T) -> impl Foo<T = i32> {
5454
| +++++++++
55-
help: consider changing Leak's return type
56-
|
57-
LL | fn leak(self) -> i32;
58-
| ~~~
5955

6056
error[E0308]: mismatched types
6157
--> $DIR/equality2.rs:38:10

tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/opaque-in-impl-is-opaque.rs:14:19
33
|
4-
LL | fn bar(&self) -> impl Display;
5-
| ------------ help: consider changing bar's return type: `&str`
6-
...
74
LL | fn bar(&self) -> impl Display {
85
| ------------ the found opaque type
96
...

tests/ui/issues/issue-22684.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/issue-22684.rs:17:17
33
|
4-
LL | fn bar(&self) -> bool { true }
5-
| ---- help: consider changing bar's return type: `()`
6-
...
74
LL | let _: () = foo::Foo.bar();
85
| -- ^^^^^^^^^^^^^^ expected `()`, found `bool`
96
| |

tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ help: you can convert an `isize` to a `usize` and panic if the converted value d
4545
|
4646
LL | let y: usize = x.foo().try_into().unwrap();
4747
| ++++++++++++++++++++
48-
help: consider changing foo's return type
49-
|
50-
LL | fn foo(&self) -> usize;
51-
| ~~~~~
5248

5349
error: aborting due to 3 previous errors
5450

tests/ui/specialization/specialization-default-types.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ LL | Box::new(self)
2424
error[E0308]: mismatched types
2525
--> $DIR/specialization-default-types.rs:25:5
2626
|
27-
LL | fn generate(self) -> Self::Output;
28-
| ------------ help: consider changing Example's return type: `Box<T>`
29-
...
3027
LL | fn trouble<T>(t: T) -> Box<T> {
3128
| ------ expected `Box<T>` because of return type
3229
LL | Example::generate(t)

tests/ui/suggestions/box-future-wrong-output.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/box-future-wrong-output.rs:20:39
33
|
4-
LL | fn boxed<'a>(self) -> BoxFuture<'a, Self::Output>
5-
| --------------------------- help: consider changing boxed's return type: `Pin<Box<(dyn Future<Output = bool> + Send + 'static)>>`
6-
...
74
LL | let _: BoxFuture<'static, bool> = async {}.boxed();
85
| ------------------------ ^^^^^^^^^^^^^^^^ expected `bool`, found `()`
96
| |

tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
trait Trait<T = Self> {
55
type A;
66

7-
fn func(&self) -> usize;
7+
fn func(&self) -> Self::A;
88
}
99

1010
struct S<T>(T);

0 commit comments

Comments
 (0)