-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
estebank, workingjubilee and mdibaiee
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.