-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fix invalid bounds string generation in rustdoc #58894
Conversation
The bug seems to be introduced when re-exporting the struct ( I was able to reproduce the error with the following code: use std::marker::PhantomData;
pub struct Scope<'env> {
_marker: PhantomData<&'env mut &'env ()>,
} A downstream crate that re-exports the |
774fb17
to
869ab87
Compare
Your test doesn't properly exercise the bug, since it primarily appears when the struct is re-exported. However, i would still like to see input from @rust-lang/compiler in case it can be fixed on their end. |
Well... they must be, mustn't they? Otherwise how do you rely on them cross-crate? It may be possible that in rustdoc you're using rust/src/librustc/ty/query/mod.rs Lines 136 to 142 in 0f88167
|
I was under the assumption that they could be re-calculated from the definition, but i guess not.
It looks like we are using |
JFYI we could probably screen out |
Ping from triage, @GuillaumeGomez :) |
Well, it panics when I tried to switch so not sure about that... Investigating. |
869ab87
to
ddd034a
Compare
I changed a few things around but we now have a new issue: for non local elements, it just doesn't work. Any idea on this @eddyb? |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Yeah, the problem is that the definition is sort of lost (part of why rustdoc needs two codepaths for everything...), and only some information of note is kept. Although specifically in this case, enough information might be there, but it would be a bit of waste to recompute it each time. |
Fixed the issue! |
I also added the test from #59033. |
cc @rust-lang/compiler |
📌 Commit c966c45 has been approved by |
…nds, r=estebank Fix invalid bounds string generation in rustdoc Fixes rust-lang#58737. Very weird and I'm not sure this is the best fix around. However, trying to fix it beforehand seems overly complicated compared to the gain (in `clean`, it wouldn't change anything since we **have to** return something so that wouldn't work, and in `hir`, I'm afraid I'd break something else for very little gain). Also, I wasn't able to make a small code to reproduce the issue. The only way to test is to document `crossbeam` directly and check the `Scope` struct... r? @QuietMisdreavus
Rollup of 6 pull requests Successful merges: - #58894 (Fix invalid bounds string generation in rustdoc) - #59599 (Updated RELEASES.md for 1.34.0) - #59624 (SGX target: Use linker option to avoid code CGU assignment kludge) - #59696 (Remove invalid assertion back::link::from add_upstream_rust_crates().) - #59707 (Add missing tryfrom example) - #59727 (wasi: Use shared API for preopened fds) Failed merges: r? @ghost
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap(); | ||
let hir_id = match tcx.hir().as_local_hir_id(def_id) { | ||
Some(hir_id) => hir_id, | ||
None => return tcx.predicates_of(def_id), |
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.
This is another change to rustc_typeck
that wasn't explicitly approved (the comment thread doesn't make it clear that a hack was added outside of rustdoc), can we please not do this? I'll create a PR reverting these, but I feel like we have a larger process break issue...
Yes, I didn't see this notification until now, but please ping me elsewhere instead of merging typeck hacks like this.
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.
Not to mention this is wrong for cross-crate items, my expectation was that explicit_predicates_of
was available cross-crate.
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.
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 did ping the compiler team so I thought you'd see the notification, my bad.
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.
Talked with Eddy on chat. My bad as the previous seemed to make sense on isolation. I'll defer to Eddy's assessment on typeck code in the future.
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.
@GuillaumeGomez Being notified isn't enough, we need to acknowledge it too.
With @nikomatsakis less active lately (and also on PTO more recently), a bit more care should be taken.
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.
Opened #59789.
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 didn't approved the PR nor asked anyone (except the compiler team) to review it. I approve for more care to be taken but I feel like taking the blame for an error I didn't make. :-/
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.
This is a process failure, not your failure! We'll figure out how to prevent such things happening in the future.
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.
@GuillaumeGomez The one at fault here was me, not you, as I approved this change thinking it looked reasonable without being my main area of expertise, I should have deferred to @eddyb's or @nikomatsakis' judgement on this case.
Revert two unapproved changes to rustc_typeck. There was a breakdown in process (#59004 (comment), #58894 (comment)) and two changes were made to `rustc_typeck`'s "collect" queries, for rustdoc, that were neither needed *nor* correct. I'm reverting them here, and will fix up rustdoc *somehow*, if necessary. cc @rust-lang/compiler How do we ensure this doesn't happen again? r? @nikomatsakis or @oli-obk
Revert two unapproved changes to rustc_typeck. There was a breakdown in process (rust-lang#59004 (comment), rust-lang#58894 (comment)) and two changes were made to `rustc_typeck`'s "collect" queries, for rustdoc, that were neither needed *nor* correct. I'm reverting them here, and will fix up rustdoc *somehow*, if necessary. cc @rust-lang/compiler How do we ensure this doesn't happen again? r? @nikomatsakis or @oli-obk
Fixes #58737.
Very weird and I'm not sure this is the best fix around. However, trying to fix it beforehand seems overly complicated compared to the gain (in
clean
, it wouldn't change anything since we have to return something so that wouldn't work, and inhir
, I'm afraid I'd break something else for very little gain).Also, I wasn't able to make a small code to reproduce the issue. The only way to test is to document
crossbeam
directly and check theScope
struct...r? @QuietMisdreavus