-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attribute for types that should always be passed by value #76935
Comments
Clippy has a more expansive, allow-by-default version of this BTW. |
@rustbot claim |
@ecstatic-morse I just tinkered around with this today a little bit. I wasn't clear on one part: Do we want this lint to be internal to rustc, or just a builtin for everyone? I was confused because at some point you say:
|
@mdibaiee Internal to rustc for now. For the broader ecosystem, a clippy lint is probably more appropriate. |
feat: rustc_pass_by_value lint attribute Useful for thin wrapper attributes that are best passed as value instead of reference. Fixes rust-lang#76935
feat: rustc_pass_by_value lint attribute Useful for thin wrapper attributes that are best passed as value instead of reference. Fixes rust-lang#76935
feat: rustc_pass_by_value lint attribute Useful for thin wrapper attributes that are best passed as value instead of reference. Fixes rust-lang#76935
feat: rustc_pass_by_value lint attribute Useful for thin wrapper attributes that are best passed as value instead of reference. Fixes rust-lang#76935
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 (currentlyTy
andTyCtxt
). We should use an attribute (e.g.#[rustc_pass_by_value]
) to control this. Note thatTy
is a type alias, not astruct
.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
The text was updated successfully, but these errors were encountered: