diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index f6ef97e9583cd..9ae0c60d09264 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -1199,11 +1199,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(local_did) = def_id.as_local() && let Some(node) = self.tcx.opt_hir_node(self.tcx.local_def_id_to_hir_id(local_did)) - && let hir::Node::TraitItem(hir::TraitItem { - kind: hir::TraitItemKind::Fn(sig, ..), - .. - }) - | hir::Node::ImplItem(hir::ImplItem { + && let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(sig, ..), .. }) | hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, ..), .. }) = node diff --git a/tests/ui/associated-type-bounds/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.stderr b/tests/ui/associated-type-bounds/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.stderr index 96bca643ae28b..4d893a758a950 100644 --- a/tests/ui/associated-type-bounds/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.stderr +++ b/tests/ui/associated-type-bounds/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/do-not-look-at-parent-item-in-suggestion-for-type-param-of-current-assoc-item.rs:24:37 | -LL | fn identify(&self) -> Self::Id; - | -------- help: consider changing identify's return type: `&I` -... LL | let _low = self.lows.remove(low.identify()).unwrap(); | ------ ^^^^^^^^^^^^^^ expected `&I`, found associated type | | diff --git a/tests/ui/associated-types/associated-types-eq-3.stderr b/tests/ui/associated-types/associated-types-eq-3.stderr index 78a9662187a1d..07cdf272ba970 100644 --- a/tests/ui/associated-types/associated-types-eq-3.stderr +++ b/tests/ui/associated-types/associated-types-eq-3.stderr @@ -17,10 +17,6 @@ help: consider constraining the associated type `::A` to `Bar` | LL | fn foo2>(x: I) { | +++++++++ -help: consider changing boo's return type - | -LL | fn boo(&self) -> Bar; - | ~~~ error[E0271]: type mismatch resolving `::A == Bar` --> $DIR/associated-types-eq-3.rs:38:10 diff --git a/tests/ui/impl-trait/equality2.stderr b/tests/ui/impl-trait/equality2.stderr index dc6be133a95a4..88b8908802b87 100644 --- a/tests/ui/impl-trait/equality2.stderr +++ b/tests/ui/impl-trait/equality2.stderr @@ -52,10 +52,6 @@ help: consider constraining the associated type `::T` to `i32` | LL | fn hide(x: T) -> impl Foo { | +++++++++ -help: consider changing Leak's return type - | -LL | fn leak(self) -> i32; - | ~~~ error[E0308]: mismatched types --> $DIR/equality2.rs:38:10 diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr index 05a78c7a66f29..9faf40e975cef 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/opaque-in-impl-is-opaque.rs:14:19 | -LL | fn bar(&self) -> impl Display; - | ------------ help: consider changing bar's return type: `&str` -... LL | fn bar(&self) -> impl Display { | ------------ the found opaque type ... diff --git a/tests/ui/issues/issue-22684.stderr b/tests/ui/issues/issue-22684.stderr index e0d5db773afb3..ecb9517772f4b 100644 --- a/tests/ui/issues/issue-22684.stderr +++ b/tests/ui/issues/issue-22684.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/issue-22684.rs:17:17 | -LL | fn bar(&self) -> bool { true } - | ---- help: consider changing bar's return type: `()` -... LL | let _: () = foo::Foo.bar(); | -- ^^^^^^^^^^^^^^ expected `()`, found `bool` | | diff --git a/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index c938be03ca836..d0cae444dafdb 100644 --- a/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -45,10 +45,6 @@ help: you can convert an `isize` to a `usize` and panic if the converted value d | LL | let y: usize = x.foo().try_into().unwrap(); | ++++++++++++++++++++ -help: consider changing foo's return type - | -LL | fn foo(&self) -> usize; - | ~~~~~ error: aborting due to 3 previous errors diff --git a/tests/ui/specialization/specialization-default-types.stderr b/tests/ui/specialization/specialization-default-types.stderr index be4c3b7395d33..7f5534c55c8e5 100644 --- a/tests/ui/specialization/specialization-default-types.stderr +++ b/tests/ui/specialization/specialization-default-types.stderr @@ -24,9 +24,6 @@ LL | Box::new(self) error[E0308]: mismatched types --> $DIR/specialization-default-types.rs:25:5 | -LL | fn generate(self) -> Self::Output; - | ------------ help: consider changing Example's return type: `Box` -... LL | fn trouble(t: T) -> Box { | ------ expected `Box` because of return type LL | Example::generate(t) diff --git a/tests/ui/suggestions/box-future-wrong-output.stderr b/tests/ui/suggestions/box-future-wrong-output.stderr index a27ae60336a20..685bd7273d215 100644 --- a/tests/ui/suggestions/box-future-wrong-output.stderr +++ b/tests/ui/suggestions/box-future-wrong-output.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/box-future-wrong-output.rs:20:39 | -LL | fn boxed<'a>(self) -> BoxFuture<'a, Self::Output> - | --------------------------- help: consider changing boxed's return type: `Pin + Send + 'static)>>` -... LL | let _: BoxFuture<'static, bool> = async {}.boxed(); | ------------------------ ^^^^^^^^^^^^^^^^ expected `bool`, found `()` | | diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed b/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed index f4c68b3fbefc0..8ef7e34ab3050 100644 --- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed +++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.fixed @@ -4,7 +4,7 @@ trait Trait { type A; - fn func(&self) -> usize; + fn func(&self) -> Self::A; } struct S(T); diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr b/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr index c768b415677a9..e590d264f26a8 100644 --- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr +++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction-fixable.stderr @@ -22,10 +22,6 @@ help: consider constraining the associated type `::A` to `u | LL | fn foo<'a, T: Trait + 'a>(&self, _: impl Trait, x: impl Trait, _: T) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:17:13 @@ -51,10 +47,6 @@ help: consider constraining the associated type `::A` to `usize` | LL | fn ban(x: T) where T: Trait { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:22:9 @@ -80,10 +72,6 @@ help: consider constraining the associated type `::A` to `u | LL | fn foo<'a, T: Trait + 'a>(_: impl Trait, x: impl Trait, _: T) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:26:9 @@ -109,10 +97,6 @@ help: consider constraining the associated type `::A` to `usize` | LL | fn bar>(x: T) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:30:9 @@ -138,10 +122,6 @@ help: consider constraining the associated type ` as Trait> | LL | fn foo2(x: impl Trait) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:34:9 @@ -167,10 +147,6 @@ help: consider constraining the associated type `>::A` to `usize | LL | fn bar2>(x: T) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction-fixable.rs:38:9 @@ -196,10 +172,6 @@ help: consider constraining the associated type `::A` to `usize` | LL | fn ban(x: T) where T: Trait { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error: aborting due to 7 previous errors diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr index 8453d7903563f..5d36a533b35f1 100644 --- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr +++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr @@ -36,10 +36,6 @@ help: consider constraining the associated type `::A` to `u | LL | fn foo(_: impl Trait, x: impl Trait) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:18:9 @@ -65,10 +61,6 @@ help: consider constraining the associated type `::A` to `usize` | LL | fn bar>(x: T) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:22:9 @@ -94,10 +86,6 @@ help: consider constraining the associated type ` as Trait> | LL | fn foo2(x: impl Trait) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:26:12 @@ -151,17 +139,10 @@ help: consider constraining the associated type `>::A` to `usize | LL | fn bar2>(x: T) { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:31:9 | -LL | fn func(&self) -> Self::A; - | ------- help: consider changing func's return type: `usize` -... LL | fn baz>(x: T) { | - found this type parameter LL | qux(x.func()) @@ -185,9 +166,6 @@ LL | fn qux(_: usize) {} error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:35:9 | -LL | fn func(&self) -> Self::A; - | ------- help: consider changing func's return type: `usize` -... LL | qux(x.func()) | --- ^^^^^^^^ expected `usize`, found `()` | | @@ -228,10 +206,6 @@ help: consider constraining the associated type `::A` to `usize` | LL | fn ban(x: T) where T: Trait { | +++++++++++ -help: consider changing func's return type - | -LL | fn func(&self) -> usize; - | ~~~~~ error: aborting due to 9 previous errors