Closed
Description
Inspired by #76914. Currently, we have a lint in rustc
for types that should always be passed by value. Usually, these types are thin wrappers around references, so there is no benefit to an extra layer of indirection. However, this lint uses a hard-coded list of (diagnostic) names (currently Ty
and TyCtxt
). We should use an attribute (e.g. #[rustc_pass_by_value]
) to control this. Note that Ty
is a type alias, not a struct
.
This is worthwhile because there are more widely used types that are merely a wrapper around a reference (e.g. ty::Predicate
). One could also imagine crates in the ecosystem that also do a lot of interning might take advantage of this.
cc @lcnr