-
Notifications
You must be signed in to change notification settings - Fork 13.6k
rustdoc: turn is_unnamable into a compiler query #145021
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
base: master
Are you sure you want to change the base?
rustdoc: turn is_unnamable into a compiler query #145021
Conversation
@@ -107,3 +107,25 @@ impl Linker { | |||
codegen_backend.link(sess, codegen_results, self.metadata, &self.output_filenames) | |||
} | |||
} | |||
|
|||
/// Checks if the given defid refers to an item that is unnamable, such as one defined in a const block. |
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.
What do you think about:
/// Checks if the given defid refers to an item that is unnamable, such as one defined in a const block. | |
/// Checks if the given `DefId` refers to an unnamable item like: | |
/// | |
/// ``` | |
/// pub fn f() { | |
/// // In here, `X` is not reachable outside of `f`, making it unnamable. | |
/// pub struct X; | |
/// } | |
/// ``` |
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.
The problem is that the rustdoc module view and possibly some IDEs will just show "Checks if the given DefId
refers to an unnamable item like:" as the summary.
In any case, this is the private query implementation, so any in-depth doc comment should probably go on the query itself so it can easily be found.
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'd advise to put the doc comment in both places then. :)
Also, I don't have an IDE providing doc comments for an item (which sounds really nice) but I don't think it's an argument in favor of having shorter doc comments. More like a bug to report on the IDE.
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 not advising for shorter docs, I'm just trying to follow the official style guide for docs.
The point is the first sentence needs to make sense on its own.
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 not advising for shorter docs, I'm just trying to follow the official style guide for docs.
Which I co-wrote. I'm ashamed. You're absolutely right.
What about:
/// Checks if the given defid refers to an item that is unnamable, such as one defined in a const block. | |
/// Checks if the given `DefId` refers to an unnamable item, such as one defined in a function. | |
/// | |
/// Example: | |
/// | |
/// ``` | |
/// pub fn f() { | |
/// // In here, `X` is not reachable outside of `f`, making it unnamable. | |
/// pub struct X; | |
/// } | |
/// ``` |
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.
That's incredibly similar to what I just pushed, curious if you think that's good enough.
Might be better to have someone more used to compiler queries to ensure it's all good. r? oli-obk |
|
4933a06
to
497d2c4
Compare
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
rustdoc: turn is_unnamable into a compiler query
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (787c9d7): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -2.8%, secondary 2.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 5.7%, secondary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 464.98s -> 464.656s (-0.07%) |
The perf gain is much smaller than I hoped though. :-/ |
I think it might be possible to return to the idea of running |
} | ||
} | ||
return false; | ||
} |
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.
Could you put this in compiler/rustc_interface/src/passes.rs
? compiler/rustc_interface/src/queries.rs
refers to a completely different kind of queries, that were eventually extinguished.
/// // In here, `X` is not reachable outside of `f`, making it unnamable. | ||
/// pub struct X; | ||
/// } | ||
/// ``` |
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.
Do we need docs here when we have the query's?
as discussed in #143849 (comment)
first time adding a compiler query, so i'm not sure if i have all the options and caching strategies configured right.
need someone to run a perf job for me on this.
once this is merged i may send a followup to also use this query to inhibit normalization into unnamable types.
as discussed in #143849 (comment)
r? @GuillaumeGomez