-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Use rustc
attrs in dangling_pointers_from_temporaries
lint
#132281
Comments
Steps
More context in #128985 (comment) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@rustbot claim |
@GrigorenkoPV sorry, didn't realize this your follow up issue. Apologies. |
I, most likely, won't have a chance to work on it in the next few weeks, so you can claim it in the meantime if you want to. |
Alright, I'll give it a shot. @rustbot claim |
I think the actual place where the attribute checking will have to go is this: rust/compiler/rustc_lint/src/dangling.rs Line 136 in 2dece5b
so that we trigger on methods not based on their name but rather based on them having this attribute. The Ideally this should probably be unified with In the meantime I see 3 options for
In conclusion,
If you have any questions, feel free to reach out to me or Urgau (I guess they will not mind either, considering they've marked this issue with
E-mentor
|
Thanks for all the helpful resources! I've created a new trait to track functions that implement I'll list the commit from my personal fork here, which I did mostly with inspiration from the two commits posted for reference by Urgau. Thanks again for the help! |
You need to put them behind the Like this, Btw, I would highly recommend, keeping the stage0 std (as to not recompile everything) with |
I think I know what the problem might be. Currently a new version of rustc is built as follows:
The problem is that the preexisting bootstrap has no idea about this new attribute. Only the new compiler will. Solution? Effectively #[cfg_attr(not(bootstrap), rustc_as_ptr)] As for the IDE problems, https://rustc-dev-guide.rust-lang.org/building/suggested.html#suggested-workflows might help. Damn, Urgau was faster. |
I believe I've finished up with the primary objectives, which are:
I've decided to postpone the fifth step mentioned in this comment further up in the thread, as this is my first contribution here and I'd like to make sure I'm not making any mistakes before bundling that many edits into a single PR. If everything sounds good, I'll go ahead and make a PR for review. My branch is linked here if you'd like to take a look for any reason. Again, thank you @Urgau and @GrigorenkoPV for being so wonderfully helpful! |
The changes in your branch looks good. Feel free to create a PR (and assign it to me). As for !matches!(ty.kind, hir::TyKind::Ref(_, _)) which checks if a type isn't a reference. |
I think then the lint will fire on things like |
Ah, right, forgot about that. I think that should handled with |
Just made my PR. Also, would like to mention the few abnormalities I found about the types listed in the following snippet: rust/compiler/rustc_lint/src/dangling.rs Lines 202 to 219 in 2dece5b
Firstly, the Second, |
#132732 (mentioning it explicitly so that GitHub cross-links it with this issue)
I think it comes from slices and arrays just deref to those.
I don't think the attribute has any transitive effect. And the lint itself will only be matched against the code in the linted crate, so it won't peek into standard library's source code.
Well, this function/method should probably be accounted for as well, but it is not a method on temporary (i.e. it is not |
Originally posted by @Urgau in #128985 (comment)
The text was updated successfully, but these errors were encountered: