-
Notifications
You must be signed in to change notification settings - Fork 13.4k
nocapture
attribute is missing on function arguments
#25759
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 briefly discussed this with @eddyb on irc the other day, and the way we used to set fn foo(x: &i32) -> *const i32 {
x as *const i32
} Since we based the attribute purely on the fact that the pointer has an anonymous lifetime, I assume we don't want to have UB in safe code, right? That would mean that we need to perform some analysis on the function body to determine which attributes we can emit and that we need to emit those attributes in the metadata, because other crates can't necessarilly perform this analysis, because they don't have access to the function body at all. |
What are the benefits of applying the |
LLVM seems to be inferring the |
@ranma LLVM can't do that for external functions though. We'd still have to store the information in the crate metadata, even if we don't perform the analysis ourselves and just inspect what LLVM could infer. |
In the absence of clearer unsafe code guidelines, it is not clear when we should add this attribute anyhow. |
Wishlist. If somebody ever figures it out, great. |
In a function like
fn foo(x: &i32)
, the pointer is known not to be captured by the function because its lifetime doesn't allow it. We used to emit thenocapture
attribute for such function arguments but don't do so anymore.The text was updated successfully, but these errors were encountered: