Add a new attr indicates pub struct with private fields could be contructed externally#126456
Add a new attr indicates pub struct with private fields could be contructed externally#126456mu001999 wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
rustbot has assigned @compiler-errors. Use |
|
#126169 (comment) notes #126289. Please add a test and/or support for that. |
|
@compiler-errors updated the test |
compiler-errors
left a comment
There was a problem hiding this comment.
Also, this doesn't follow the usual process for adding new attributes to the compiler.
This either needs to be FCP'd by T-lang as an insta-stable attribute, or it needs to be feature gated appropriately.
|
@rustbot author Please add feature gating. I also wonder if we should bikeshed this a bit first before adding it, like on i-rl-o. |
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@compiler-errors Sorry for the delay, I opened one on i-rl-o ;). link: https://internals.rust-lang.org/t/externally-constructed-or-anything-else/21049 |
compiler/rustc_passes/src/dead.rs
Outdated
| } | ||
| field.vis.is_public() | ||
| }) | ||
| tcx.has_attr(id, sym::externally_constructed) |
There was a problem hiding this comment.
Is this a good place for this check? In function check_item, around line 838 you have a variable may_construct_self and in visit_node there is unconditionally_treats_fields_as_live
There was a problem hiding this comment.
Oh, seems checking it in create_and_seed_worklist is good enough. And I opened another PR which just checks the repr(c) or repr(transparent), see #127104.
…lds could be constructed externally
|
I believe the other approach to this is #127104? If so, I'm gonna close this. |
Fixes #126169