Skip to content

Commit 4f919e4

Browse files
authored
Rollup merge of #105349 - compiler-errors:point-at-assoc-ct-fn-ptr-arg, r=cjgillot
Point at args in associated const fn pointers Tiny follow-up to #105201, not so sure it's worth it but 🤷 The UI test example is a bit more compelling when it's `GlUniformScalar::FACTORY` r? `@cjgillot`
2 parents dc07e1b + 9c9c476 commit 4f919e4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1918,15 +1918,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19181918
receiver: Option<&'tcx hir::Expr<'tcx>>,
19191919
args: &'tcx [hir::Expr<'tcx>],
19201920
) -> bool {
1921-
// Do not call `fn_sig` on non-functions.
1922-
if !matches!(
1923-
self.tcx.def_kind(def_id),
1924-
DefKind::Fn | DefKind::AssocFn | DefKind::Variant | DefKind::Ctor(..)
1925-
) {
1921+
let ty = self.tcx.type_of(def_id);
1922+
if !ty.is_fn() {
19261923
return false;
19271924
}
1928-
1929-
let sig = self.tcx.fn_sig(def_id).skip_binder();
1925+
let sig = ty.fn_sig(self.tcx).skip_binder();
19301926
let args_referencing_param: Vec<_> = sig
19311927
.inputs()
19321928
.iter()

src/test/ui/suggestions/assoc-const-as-fn.stderr

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied
2-
--> $DIR/assoc-const-as-fn.rs:14:5
2+
--> $DIR/assoc-const-as-fn.rs:14:40
33
|
44
LL | <T as GlUniformScalar>::FACTORY(1, value);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `GlUniformScalar` is not implemented for `T`
5+
| ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
help: consider further restricting this bound
810
|

0 commit comments

Comments
 (0)