Uh oh!
There was an error while loading. Please reload this page.
Add info about ! and impl Trait - #76099
Conversation
rust-highfive
commented
Aug 30, 2020
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
camelid
commented
Aug 30, 2020
Note that this is still very work-in-progress, I just wanted to write something down to see if it's roughly correct. |
camelid
commented
Aug 30, 2020
Cc @jyn514 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /// | ||
| /// [#36375]: https://github.com/rust-lang/rust/issues/36375 | ||
| /// | ||
| /// As it turns out, though, most traits can have an `impl` for `!`. Take [`Debug`] |
There was a problem hiding this comment.
Most -> all? Not sure if that's true but it seems like it should be.
There was a problem hiding this comment.
That's what I thought too; I would think you would be able to impl any trait for ! since it can never :) exist. The body of it could just be panic!("This shouldn't happen!").
There was a problem hiding this comment.
You mean because it can be coerced to any concrete type, so it can just return itself?
There was a problem hiding this comment.
-> impl Trait is not allowed in trait methods. So any trait it implemented would require returning some concrete type. Since ! can be coerced to any type, it would be coerced to the required type.
Uh oh!
There was an error while loading. Please reload this page.
| /// # trait Debug { | ||
| /// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result; | ||
| /// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result; | ||
| /// # } |
There was a problem hiding this comment.
Why is Debug defined here instead of imported?
There was a problem hiding this comment.
I'm going to delete this redefinition and import it instead.
There was a problem hiding this comment.
Looks like it's because of the orphan rule or something, so I had to revert my change :(
I no longer say "polymorphic" since it's a bit ambiguous here.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This reverts commit 7e2548f. Now I know why it was redefined: it seems like it's potentially because of the orphan rule. Here are the error messages: error[E0119]: conflicting implementations of trait `std::fmt::Debug` for type `!`: --> src/primitive_docs.rs:236:1 | 6 | impl Debug for ! { | ^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - impl std::fmt::Debug for !; error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> src/primitive_docs.rs:236:1 | 6 | impl Debug for ! { | ^^^^^^^^^^^^^^^- | | | | | `!` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
jyn514
commented
Sep 1, 2020
@bors r+ rollup Thanks for the PR! |
bors
commented
Sep 1, 2020
📌 Commit 913354b has been approved by |
camelid
commented
Sep 1, 2020
Oh well, it looks like the line break commit didn't get through in time ;) |
jyn514
commented
Sep 1, 2020
@bors r+ rollup |
bors
commented
Sep 1, 2020
📌 Commit 55637f5 has been approved by |
jyn514
commented
Sep 1, 2020
Bors will automatically abort the merge if you push new commits. It will not however remove the S-waiting-on-bors tag :( |
bors
commented
Sep 1, 2020
⌛ Testing commit 55637f5 with merge c79747195683ac4842eaacf65e8e4cddac6f7e69... |
bors
commented
Sep 1, 2020
💔 Test failed - checks-azure |
rust-log-analyzer
commented
Sep 1, 2020
Your PR failed (pretty log, 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.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 |
jyn514
commented
Sep 1, 2020
What a strange error ... Looks network related? @bors retry |
Rollup of 14 pull requests Successful merges: - rust-lang#74880 (Add trailing comma support to matches macro) - rust-lang#76074 (Add new `-Z dump-mir-spanview` option) - rust-lang#76088 (Add more examples to lexicographic cmp on Iterators.) - rust-lang#76099 (Add info about `!` and `impl Trait`) - rust-lang#76126 (Use "Fira Sans" for crate list font) - rust-lang#76132 (Factor out StmtKind::MacCall fields into `MacCallStmt` struct) - rust-lang#76143 (Give a better error message for duplicate built-in macros) - rust-lang#76158 (Stabilise link-self-contained option) - rust-lang#76201 (Move to intra-doc links for library/core/src/panic.rs) - rust-lang#76206 (Make all methods of `std::net::Ipv6Addr` const) - rust-lang#76207 (# Move to intra-doc links for library/core/src/clone.rs) - rust-lang#76212 (Document lint missing_doc_code_examples is nightly-only) - rust-lang#76218 (lexer: Tiny improvement to shebang detection) - rust-lang#76221 (Clean up header in `iter` docs for `for` loops) Failed merges: r? @ghost
Fixes#76094.
@rustbot modify labels: T-doc C-enhancement