Skip to content

Remove invalid suggestion involving Fn trait bound #86400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
if generics.params.iter().any(|p| p.name != kw::SelfUpper)
&& !snippet.ends_with('>')
&& !generics.has_impl_trait()
&& !self.tcx.fn_trait_kind_from_lang_item(*def_id).is_some()
{
// FIXME: To avoid spurious suggestions in functions where type arguments
// where already supplied, we check the snippet to make sure it doesn't
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/traits/issue-85735.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Regression test for the invalid suggestion in #85735 (the
// underlying issue #21974 still exists here).

trait Foo {}
impl<'a, 'b, T> Foo for T
where
T: FnMut(&'a ()),
//~^ ERROR: type annotations needed [E0283]
T: FnMut(&'b ()),
{
}

fn main() {}
16 changes: 16 additions & 0 deletions src/test/ui/traits/issue-85735.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error[E0283]: type annotations needed
--> $DIR/issue-85735.rs:7:8
|
LL | T: FnMut(&'a ()),
| ^^^^^^^^^^^^^ cannot infer type for type parameter `T`
|
::: $SRC_DIR/core/src/ops/function.rs:LL:COL
|
LL | pub trait FnMut<Args>: FnOnce<Args> {
| ----------------------------------- required by this bound in `FnMut`
|
= note: cannot satisfy `T: FnMut<(&'a (),)>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0283`.