-
Notifications
You must be signed in to change notification settings - Fork 13.4k
consider switching from manual indirect passing to byval #10030
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
Comments
I don't understand what this ticket is asking for. Is it about the code being generated by trans for LLVM to process, or is it actually proposing a deep change to the language itself? |
Just a codegen change (tagged properly now). We currently generate a copy in the caller ourselves for non-immediate values, and pass by-pointer. LLVM has a |
Makes sense, though I think we may also have more information than LLVM -- I've been wanting to optimize trans by passing in information about when a "by value" parameter can be used "in place". Though the ability to declare parameters as |
Still I tend to agree we should generate the most "semantically correct" LLVM bitcode that we can. |
Isn't a parameter declared as fn foo(mut x: Type) {
...
}
fn bar(x: Type) {
let mut x = x;
...
} |
Equivalent from the language POV, yes, but not necessarily the |
I don't think we should do this now that we have |
Add `impl_trait_in_params` lint As this is a lint about style, and using `impl Trait` is purely cosmetical (even with downsides), a lot of unrelated files needed to allow this lint. --- Resolves rust-lang#10030 changelog: New lint: [`impl_trait_in_params`] [10197](rust-lang/rust-clippy#10197) <!-- changelog_checked -->
If we did this, LLVM would generate the copy for us, but only if needed (not a
readonly
parameter). It also conveys more information to the body of the function, by letting it know the pointer is valid.The text was updated successfully, but these errors were encountered: