-
Notifications
You must be signed in to change notification settings - Fork 53
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
rustc-demangle does not allow encoding version in symbol name #58
Comments
If I understand correctly, |
I mean rustc-demangle and RFC 2603 should be consistent. In theory, a third-party library could generate a symbol according to RFC 2603, but it can not be recognized by |
Just to be perfectly clear, But I think the actual confusion here is a bit weirder - technically the So it's more like the grammar is this (different syntax so I can illustrate things): SymbolName = "_R" version:DecimalNumber? SymbolContents(version)
SymbolContents("") = Path InstantiatingCrate?
SymbolContents("0") = # not defined yet
SymbolContents("1") = # not defined yet
# ... That is, something like The only reason the RFC specifies that part is to make it clear that:
cc @michaelwoerister (for extra confirmation in case I'm misremembering something) |
Yes, I agree with @eddyb's assessment. The version tag is supposed to allow for evolving the symbol mangling grammar. At minimum it should quickly tell a demangler if it can handle the symbol. We shouldn't have made it optional though. Instead, we should have required a hard-coded In practice v0 requires there to be no version number. The presence of a version number means that it's some newer grammar version. In retrospect I'm not sure how useful the whole "versioning scheme" is 😅 |
I've suggested using it to specify compressed encodings, where there might be a small risk of the compressed form accidentally overlapping with a valid (but likely nonsensical) mangling, though that's just as easily accomplished by leaving the But yeah, nothing on the immediate horizon, for now we can keep extending v0 as long as we don't cause overlaps. |
True, for compressed schemes we could use it pretty soon. E.g. define About extending v0, I'm not so sure. If we add new grammar productions, e.g. for const generics, demanglers have no way of gracefully failing there (e.g. by skipping just the part they don't understand). That question came up in rust-lang/rust#97571 and I don't have a good answer for it. |
To be clear, I was talking about reversible compression, not hashing. E.g. Such ideas came up during the RFC (as a way to get smaller symbols but keep all the information), but were postponed - with that context, my suggestion was merely to still do something like that, but take advantage of the version field to distinguish it from uncompressed v0 symbols.
I mean, I hope we don't have to, but IMO it's less of an annoyance to work around a few symbols (the ones using the newer features) not getting demangled (by passing them through e.g. up-to-date OTOH, once you have unsigned integers and (path) constructor application you can represent pretty much any constant, like if we didn't have the |
The RFC 2603 says that
But it seem that rustc-demangle forces an upper case letter after
_R
:rustc-demangle/src/v0.rs
Lines 56 to 59 in 2811a1a
But I am not sure whether this issue belongs to RFC 2603 or rust-demangle.
The text was updated successfully, but these errors were encountered: