Skip to content

add auto-impl for primitive type #50533

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

Merged
merged 1 commit into from
May 18, 2018

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented May 8, 2018

Part of #50431.

I have no clue how to test this though with the rustdoc test suite...

r? @QuietMisdreavus

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 8, 2018
@QuietMisdreavus
Copy link
Member

If it's because you don't know how to force a primitive page to appear, you can do that by creating an empty module in a crate root and tagging it with #[doc(primitive = "i32")] (or some other primitive name). That will cause rustdoc to replace that mod with the corresponding primitive page. Then you can add your desired tests.

@GuillaumeGomez
Copy link
Member Author

Seems more complicated than just doing this. I'll need to investigate further...

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2018
@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented May 14, 2018

Some investigation today:

Only having a module tagged with #[doc(primitive = "i16")] will produce a page with nothing but whatever docs you tagged onto the module. Forcing rustdoc to include all_trait_implementations by re-exporting something from another crate (say, by pub use std::fs::File or the like) will pull in the necessary impls from core/std, which makes it load the auto-trait impls as well.

Strangely, this works for i16 but not bool. One thing i noticed between them is that bool has no inherent methods, only trait implementations. I wonder if that has something to do with it...

(EDIT: That "re-export something to pull in the traits" trick feels like a huge hack, but then again, pulling in primitives like this is also a bit of a hack, so i guess it balances out? 🤷‍♀️)

@QuietMisdreavus
Copy link
Member

More discussion has uncovered that the "impl inlining" code uses this table to reference the list of primitives, which does not include an entry for bool. It does, however, include two entries for str, which means that there are two sets of auto-trait entries on that page. There's probably another set of lang-items we can use to pull the primitives we need out.

@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

[00:04:51] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:51] tidy error: /checkout/src/test/rustdoc/auto-impl-primitive.rs:14: line longer than 100 chars
[00:04:51] tidy error: /checkout/src/test/rustdoc/auto-impl-primitive.rs: missing trailing newline
[00:04:52] some tidy checks failed
[00:04:52] 
[00:04:52] 
[00:04:52] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:52] 
[00:04:52] 
[00:04:52] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:52] Build completed unsuccessfully in 0:01:46
[00:04:52] Build completed unsuccessfully in 0:01:46
[00:04:52] make: *** [tidy] Error 1
[00:04:52] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:03f49506
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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 @TimNN. (Feature Requests)

@QuietMisdreavus
Copy link
Member

The last rebase only includes a test, it does not address the "no bool with two str" problem mentioned up-thread. I'm willing to land this with just tidy fixed (and if travis passes with the new test), but if that's the case i want to keep #50431 open to track that.

@GuillaumeGomez
Copy link
Member Author

I'll fix tidy this evening.

@QuietMisdreavus
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented May 17, 2018

📌 Commit 564511e has been approved by QuietMisdreavus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 17, 2018
@bors
Copy link
Collaborator

bors commented May 18, 2018

⌛ Testing commit 564511e with merge ba64edb...

bors added a commit that referenced this pull request May 18, 2018
…eavus

add auto-impl for primitive type

Part of #50431.

I have no clue how to test this though with the rustdoc test suite...

r? @QuietMisdreavus
@bors
Copy link
Collaborator

bors commented May 18, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: QuietMisdreavus
Pushing ba64edb to master...

@bors bors merged commit 564511e into rust-lang:master May 18, 2018
@GuillaumeGomez GuillaumeGomez deleted the rustdoc-prim-auto branch May 21, 2018 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants