-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 field@
and variant@
doc-link disambiguators
#130587
Add field@
and variant@
doc-link disambiguators
#130587
Conversation
r? @notriddle rustbot has assigned @notriddle. Use |
cc #80283 |
// for purposes of link resolution, fields are in the value namespace. | ||
Self::Kind(DefKind::Field) => ValueNS, |
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'm confused, i thought you were going to remove this? is the problem that DefKind::ns
is defined in rustc so you can't modify it?
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 was, but it turns out it didn't make sense to move the disambiguator == Field
so far up and out - that would mean putting it in resolve_disambiguator()
, while it makes much more sense (and is easier to keep existing field-last resolution behavior) if it just gets considered to be in the value ns and fails to resolve to anything before getting picked up in the special-case in resolve_associated_item()
.
this would also need to consider the story around |
In general, this PR's feature design seems fine. If it passes a crater run, I wouldn't mind making it insta-stable.
Thanks to this choice, I don't think this should break anything, and I don't think it makes the |
oh tbc this pr doesn't break anything, i would be shocked if crater turned up anything, |
This comment has been minimized.
This comment has been minimized.
Ah, oops, blessed the ui tests before finishing the implementation lol |
ah wait nevermind. i just |
9fd4eaf
to
e91e015
Compare
Rustdoc already has field-last resolution behavior. This PR doesn't make that one any worse than it already is, either. If we want to make the disambiguator required later, this PR doesn't seem to prevent that. |
Bump on this review? |
Good catch. I wanted to know if anyone else objected, and it doesn't seem they do. @bors r=notriddle,jyn514 |
☀️ Test successful - checks-actions |
Finished benchmarking commit (f79ef02): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -1.5%, secondary -3.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 3.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 770.872s -> 771.378s (0.07%) |
I'm not sure if this is big enough to need an fcp or not, but this is something I found missing when trying to refer to a field in macro-generated docs, not knowing if a method might be defined as well. Obviously, there are definitely other uses.
In the case where it's not disambiguated, methods (and I suppose other associated items in the value namespace) still take priority, which @jyn514 said was an oversight but I think is probably the desired behavior 99% of the time anyway - shadowing a field with an accessor method is a very common pattern. If fields and methods with the same name started conflicting, it would be a breaking change. Though, to quote them:
That'd be out of scope of this PR, though.
Fixes #80283