-
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
Rustdoc: where bounds order in synthetic impls is not deterministic #49123
Comments
I don't think the issue comes from rustdoc. I tried to get this issue and wasn't able to... Last example: use std::fmt::Debug;
struct Foo<T>(T);
unsafe impl<T> Send for Foo<T>
where T: Copy + Send + Clone + Debug {} The generated docs have the correct output. No clue where it could come from... |
The generated output sometimes changes when the standard library changes. This has happened that I know of in:
|
I suspect it may be something in #47833. I'm investigating, since one of the affected PR's is mine, so I can reproduce it. |
This test is running the "synthetic impls" functionality of rustdoc, where it will create an impl of Send/Sync if there is not an explicit one. This is entirely defined in |
If i understand it correctly, the generics are handled in this section in that file. Sorting the collections in the resulting rust/src/librustdoc/clean/auto_trait.rs Lines 135 to 167 in a04b88d
The key would be figuring out a proper sort, because with where clauses you can get arbitrary types in there, so we'd effectively need to be able to sort those somehow. I'm building something right now to test a hunch. |
@QuietMisdreavus I was under the impression that all impls are sorted, after the auto-generated ones are added to the list. That's why I mentioned #47833, which is the commit that added sorting of the impls for deterministic outputs. Specifically, the first commit in that PR. If more stuff is being added to the list after that sort, that is our bug. Otherwise, it should already be handled, and therefore the bug is within the sorting function. |
@Phlosioneer Looking at that PR again, it looks like it does sort the where predicates. However, it looks like the issue is about sorting the conditions within a single predicate, which the last commit in that PR doesn't address. That should help the implementation some. (Also, thanks for pointing that out; i didn't realize that was there |
Ah, okay then, I think I found the error: rust/src/librustdoc/clean/auto_trait.rs Lines 1017 to 1025 in ddfbf2b
rust/src/librustdoc/clean/auto_trait.rs Lines 1097 to 1099 in ddfbf2b
I'll make a PR that adds a sort to that method. |
I don't think that will affect it. Like i said, it's not a matter of sorting between |
Oh, so really we need to sort the rust/src/librustdoc/clean/auto_trait.rs Lines 1084 to 1096 in ddfbf2b
Because |
Yes, that's what i think the culprit is. Now that #49058 is merged, re-enabling the test should make it fail, so whatever you add to librustdoc should either make it pass or make it stop toggling whenever a new type or impl is added to libstd. |
While the order of the where clauses was deterministic, the ordering of bounds and lifetimes was not. This made the order flip- flop randomly when new traits and impls were added to libstd. This PR makes the ordering of bounds and lifetimes deterministic, and re-enables the test that was causing the issue. Fixes rust-lang#49123
…etMisdreavus Fix ordering of auto-generated trait bounds in rustdoc output While the order of the where clauses was deterministic, the ordering of bounds and lifetimes was not. This made the order flip- flop randomly when new traits and impls were added to libstd. This PR makes the ordering of bounds and lifetimes deterministic, and re-enables the test that was causing the issue. Fixes #49123
…ions, r=QuietMisdreavus Fix ordering of auto-generated trait bounds in rustdoc output While the order of the where clauses was deterministic, the ordering of bounds and lifetimes was not. This made the order flip- flop randomly when new traits and impls were added to libstd. This PR makes the ordering of bounds and lifetimes deterministic, and re-enables the test that was causing the issue. Fixes rust-lang#49123
Unrelated changes to the standard library can cause
src/test/rustdoc
to fail until a change like this is applied:CC @GuillaumeGomez
The text was updated successfully, but these errors were encountered: