From 9c9c47677487af4f9a9810a0171b077789ddd63b Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 6 Dec 2022 03:50:48 +0000 Subject: [PATCH] Point at args in associated const fn pointers --- compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs | 10 +++------- src/test/ui/suggestions/assoc-const-as-fn.stderr | 6 ++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 3078e0cbeda59..8a875e05b19b7 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1918,15 +1918,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { receiver: Option<&'tcx hir::Expr<'tcx>>, args: &'tcx [hir::Expr<'tcx>], ) -> bool { - // Do not call `fn_sig` on non-functions. - if !matches!( - self.tcx.def_kind(def_id), - DefKind::Fn | DefKind::AssocFn | DefKind::Variant | DefKind::Ctor(..) - ) { + let ty = self.tcx.type_of(def_id); + if !ty.is_fn() { return false; } - - let sig = self.tcx.fn_sig(def_id).skip_binder(); + let sig = ty.fn_sig(self.tcx).skip_binder(); let args_referencing_param: Vec<_> = sig .inputs() .iter() diff --git a/src/test/ui/suggestions/assoc-const-as-fn.stderr b/src/test/ui/suggestions/assoc-const-as-fn.stderr index fa74068785827..3b6e947c59f76 100644 --- a/src/test/ui/suggestions/assoc-const-as-fn.stderr +++ b/src/test/ui/suggestions/assoc-const-as-fn.stderr @@ -1,8 +1,10 @@ error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied - --> $DIR/assoc-const-as-fn.rs:14:5 + --> $DIR/assoc-const-as-fn.rs:14:40 | LL | ::FACTORY(1, value); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `GlUniformScalar` is not implemented for `T` + | ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T` + | | + | required by a bound introduced by this call | help: consider further restricting this bound |