-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
feat: rustc_pass_by_value lint attribute #92646
Conversation
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
My PR is not fully functional yet: For some reason when I try to compile code with (Trying to enable this on
I will try to take another look a bit later, but any help is appreciated. Thank you! P.S. this PR is subject to change as I'm trying to understand the scope better, see my question here: #76935 (comment) |
This comment has been minimized.
This comment has been minimized.
f48caf7
to
96bba75
Compare
7b3c4ca
to
73367ad
Compare
@rustbot label -T-rustdoc |
73367ad
to
ddd8237
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl looks good to me
considering that PASS_BY_VALUE is an internal lint i would prefer #[rustc_pass_by_value]
as the attribute for now.
Before merging this I would like to see some tests, both testing the Ty
, TyCtxt
interactions, there are some existing ui-fulldeps
tests for the old TY_PASS_BY_REFERENCE
lint. And probably some ordinary ui
tests using custom types
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2ec2bd2
to
589e66c
Compare
I tried to write tests for custom types, but for some reason I didn't get any errors from those custom types in my test file. I am not sure if I understand it correctly, but is that because the lint is internal, and the tests might not be considered rustc internal, and so the lint doesn't apply to them? I did this in
Is there any way to enable those internal lints in this test file? I'll take another look tomorrow and might find some solution but would appreciate any help in the meantime. |
589e66c
to
f402026
Compare
This comment has been minimized.
This comment has been minimized.
f402026
to
172550f
Compare
This comment has been minimized.
This comment has been minimized.
172550f
to
db5a4e1
Compare
This comment has been minimized.
This comment has been minimized.
db5a4e1
to
ee6bbca
Compare
This comment has been minimized.
This comment has been minimized.
ee6bbca
to
0f3d29e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some final nits, then r=me
includes minor refactorings
} | ||
GenericArg::Const(c) => { | ||
let snippet = | ||
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_default(); | |
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_else(|_| String::from("_")); |
🤔 don't want empty strings in case the span is broken. Don't know how to even get broken strings here, so i don't think this matters too much :p
r=me after this last nit, thanks for your patience @bors delegate+ |
✌️ @mdibaiee can now approve this pull request |
@lcnr thanks a million for your reviews! I will mark this with r=lcnr when CI passes 🚀 |
@bors r=lcnr |
📌 Commit 2728af7 has been approved by |
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
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#92487 (Fix unclosed boxes in pretty printing of TraitAlias) - rust-lang#92581 (ARMv6K Horizon - Enable default libraries) - rust-lang#92619 (Add diagnostic items for macros) - rust-lang#92635 (rustdoc: Yet more intra-doc links cleanup) - rust-lang#92646 (feat: rustc_pass_by_value lint attribute) - rust-lang#92706 (Clarify explicitly that BTree{Map,Set} are ordered.) - rust-lang#92710 (Include Projections when elaborating TypeOutlives) - rust-lang#92746 (Parse `Ty?` as `Option<Ty>` and provide structured suggestion) - rust-lang#92792 (rustdoc: fix intra-link for generic trait impls) - rust-lang#92814 (remove unused FIXME) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Useful for thin wrapper attributes that are best passed as value instead
of reference.
Fixes #76935