Post #1366725
2026-04-15 00:22 UTC
@blp I believe this mostly comes down to variance and drop checking. Rust infers variance and "dropck" based on the usage of `T` in data structures. This doesn't apply to `fn`s, since they cannot interact with or "store" `T` directly but only via parameters.
See https://doc.rust-lang.org/nomicon/subtyping.html
Replies (1)
-
@blp@framapiaf.org 2026-04-15 00:28
@olsonseank I can understand why `struct S` is an error. My question is more about why `fn f()` doesn't cause a warning, since most uses of it will. Even the following: fn f() {} fn g() { f(); } produces a compiler warning saying that `T` can't be inferred, but no warning about the useless `T` parameter. It's occasionally taken me a minute to realize that the correct solution is to remove `T`, not to provide a type for it.