Skip to content

Commit f8c10ff

Browse files
committed
Remove invalid suggestion involving Fn trait bound
1 parent d5fd37f commit f8c10ff

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
16041604
if generics.params.iter().any(|p| p.name != kw::SelfUpper)
16051605
&& !snippet.ends_with('>')
16061606
&& !generics.has_impl_trait()
1607+
&& !self.tcx.fn_trait_kind_from_lang_item(*def_id).is_some()
16071608
{
16081609
// FIXME: To avoid spurious suggestions in functions where type arguments
16091610
// where already supplied, we check the snippet to make sure it doesn't

src/test/ui/traits/issue-85735.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Regression test for the invalid suggestion in #85735 (the
2+
// underlying issue #21974 still exists here).
3+
4+
trait Foo {}
5+
impl<'a, 'b, T> Foo for T
6+
where
7+
T: FnMut(&'a ()),
8+
//~^ ERROR: type annotations needed [E0283]
9+
T: FnMut(&'b ()),
10+
{
11+
}
12+
13+
fn main() {}

src/test/ui/traits/issue-85735.stderr

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0283]: type annotations needed
2+
--> $DIR/issue-85735.rs:7:8
3+
|
4+
LL | T: FnMut(&'a ()),
5+
| ^^^^^^^^^^^^^ cannot infer type for type parameter `T`
6+
|
7+
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
8+
|
9+
LL | pub trait FnMut<Args>: FnOnce<Args> {
10+
| ----------------------------------- required by this bound in `FnMut`
11+
|
12+
= note: cannot satisfy `T: FnMut<(&'a (),)>`
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)