Skip to content
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

Add a new attr indicates pub struct with private fields could be contructed externally #126456

Closed
wants to merge 1 commit into from

Conversation

mu001999
Copy link
Contributor

Fixes #126169

@rustbot
Copy link
Collaborator

rustbot commented Jun 14, 2024

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 14, 2024
@compiler-errors
Copy link
Member

#126169 (comment) notes #126289. Please add a test and/or support for that.

@mu001999
Copy link
Contributor Author

@compiler-errors updated the test

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@compiler-errors
Copy link
Member

@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.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 18, 2024
@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu added the F-externally_constructed_attr `#![feature(externally_constructed_attr)]` label Jun 18, 2024
@mu001999
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 19, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@mu001999
Copy link
Contributor Author

mu001999 commented Jun 19, 2024

I also wonder if we should bikeshed this a bit first before adding it, like on i-rl-o.

@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

}
field.vis.is_public()
})
tcx.has_attr(id, sym::externally_constructed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@compiler-errors
Copy link
Member

I believe the other approach to this is #127104? If so, I'm gonna close this.

@mu001999 mu001999 deleted the fix/126169 branch July 10, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-externally_constructed_attr `#![feature(externally_constructed_attr)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dead_code lint wrongly warns about public repr(C) structs with private fields but no constructors
6 participants