-
Notifications
You must be signed in to change notification settings - Fork 724
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 FieldInfo::field_type_name
#2863
Merged
pvdrz
merged 2 commits into
rust-lang:main
from
workingjubilee:add-field-type-name-to-fieldinfo
Dec 2, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IT seems we should probably include c++ namespaces and so on here? So, use the same name as all the blocklists etc use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhhh can I be counseled on how that should be done because I am not very familiar with this codebase, much less C++
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also should note that I specifically want
None
instead of theunnamed at file...
output that currently is given in certain other cases, because I think that output is pointless, even harmful: it requires me to filter-by-string for anonymous types, which is much more error-prone and dependent on the vagaries of bindgen's output instead of using a type encoding.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilio do we include c++ namespaces for the type name as well? otherwise it would be a bit inconsistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pvdrz type_name currently uses
canonical_name
, so yes, I think so.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really need the canonical name, though, because I don't need
ExprEvalStep__bindgen_ty_1
, because what's important to me is that it is an anonymous structure, and I don't necessarily want to reason about anonymous structures by their name. Maybe their other attributes, but the real answer for their name is the empty string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, sure, but my point is, if you have:
You want to be able to differentiate between one and the other right? btw, it's unclear to me what this does for pointer fields, templates, and so on. I assume the answer is reasonable, but still it'd be worth having some tests.
You might still can make the anonymous / non-anonymous distinction (
if thing.name().is_some() { Some(thing.canonical_name()) } else { None }
or same usingmap
or what not)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My answer is that I don't really care about whatever the answer is to that because I don't use C++, not personally, nor in a work context, and in the one case where I've tried to use bindgen against it in anger, its insistence on qualifying namespaces was actually a disadvantage as the namespaces were effectively meaningless and I would have been better off if the Rust code did not know about them (they were used as a crude implementation of parameterized modules, instead of using something sensible for this facility, like e.g. template parameters).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I'd rather see this working in C and sort of working in C++ that not seeing it working at all. I think it wouldn't be unreasonable to take this as it is and see if someone else actually ends up using this and requiring the
canonical_name
as we could either add it as a new field or use it instead of the regular name if a flag is enabled.@workingjubilee @emilio does that works for both of you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
And I'd be happy to do the
.map
-based solution, but my main point of confusion at this juncture is in this code:rust-bindgen/bindgen/ir/item.rs
Lines 40 to 68 in 2fb25e3
With "namespace-aware canonical paths" being a thing, this suggests it's more complicated than just calling
canonical_name()
, so I feel, basically, not qualified to evaluate what "canonical name" means in bindgen because it conflates C++ namespaces with generated symbols.