Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5. println!("{:?}", {
  6. struct S; impl std::cmp::PartialEq<S> for usize { fn eq(self, _: usize) -> Option<bool> { Some(true) } } S == 5_usize
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (/playground)
  13. error[E0053]: method `eq` has an incompatible type for trait
  14. --> src/main.rs:6:59
  15. |
  16. 6 | struct S; impl std::cmp::PartialEq<S> for usize { fn eq(self, _: usize) -> Option<bool> { Some(true) } } S == 5_usize
  17. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &usize, found usize
  18. |
  19. = note: expected type `fn(&usize, &main::S) -> bool`
  20. found type `fn(usize, usize) -> std::option::Option<bool>`
  21.  
  22. error[E0369]: binary operation `==` cannot be applied to type `main::S`
  23. --> src/main.rs:6:116
  24. |
  25. 6 | struct S; impl std::cmp::PartialEq<S> for usize { fn eq(self, _: usize) -> Option<bool> { Some(true) } } S == 5_usize
  26. | - ^^ ------- usize
  27. | |
  28. | main::S
  29. |
  30. = note: an implementation of `std::cmp::PartialEq` might be missing for `main::S`
  31.  
  32. error: aborting due to 2 previous errors
  33.  
  34. Some errors have detailed explanations: E0053, E0369.
  35. For more information about an error, try `rustc --explain E0053`.
  36. error: Could not compile `playground`.
  37.  
  38. To learn more, run the command again with --verbose.
  39.  
  40. */
  41.  
  42. /* ~~~~=== stdout ===~~~~
  43.  
  44. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement