-
Notifications
You must be signed in to change notification settings - Fork 13.4k
non_local_definitions
lint is unhappy with multiple nested anonymous constants
#131474
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
cc @Urgau as you might know more about this. |
Considering cc @traviscross (since this is a lang issue) |
I'd expect these to be recursively transparent, yes. That is, I would not expect the lint to fire here. |
Yeah, I think that it would be extremely confusing to only consider a single layer of these, even though I understand why the code currently does this. To me, it should either be all recursively or none. I think it's fair to say that the presence of recursive nesting makes it worth reconsidering whether they should be added as an exception to the lint, but I don't think that the one-layer option should be considered, especially considering how as the lint is worded, that isn't apparent. |
Consider outermost const-anon in `non_local_def` lint This PR change the logic for finding the parent of the `impl` definition in the `non_local_definitions` lint to consider multiple level of const-anon items, instead of only one currently. I also took the opportunity to cleanup the related code. cc `@traviscross` Fixes rust-lang#131474
Rollup merge of rust-lang#131498 - Urgau:transparent-const-anons, r=lcnr Consider outermost const-anon in `non_local_def` lint This PR change the logic for finding the parent of the `impl` definition in the `non_local_definitions` lint to consider multiple level of const-anon items, instead of only one currently. I also took the opportunity to cleanup the related code. cc ``@traviscross`` Fixes rust-lang#131474
I tried this code:
This should be completely okay, since the impl is only nested within anonymous constant blocks.
Instead, you get this backwards-compatibility warning:
Meta
rustc --version --verbose
:This is currently affecting the
bevy_reflect
crate, which has a few instances of doubly-nested anonymous constants generated by macros. Particularly, theimpl_type_path!
macro nests its result in an anonymous constant, and theimpl_reflect_for_atomic!
calls this macro inside an anonymous constant. The anonymous constants exist to allow local imports without affecting the larger scope.The text was updated successfully, but these errors were encountered: