Guest User

Untitled

a guest
Aug 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5. println!("{:?}", {
  6. let mut x = Some(1); match x { Some(ref y) => x = None, _ => () }; x
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (file:///playground)
  13. warning: unused variable: `y`
  14. --> src/main.rs:6:49
  15. |
  16. 6 | let mut x = Some(1); match x { Some(ref y) => x = None, _ => () }; x
  17. | ^ help: consider using `_y` instead
  18. |
  19. = note: #[warn(unused_variables)] on by default
  20.  
  21. error[E0506]: cannot assign to `x` because it is borrowed
  22. --> src/main.rs:6:55
  23. |
  24. 6 | let mut x = Some(1); match x { Some(ref y) => x = None, _ => () }; x
  25. | ----- ^^^^^^^^ assignment to borrowed `x` occurs here
  26. | |
  27. | borrow of `x` occurs here
  28.  
  29. error: aborting due to previous error
  30.  
  31. For more information about this error, try `rustc --explain E0506`.
  32. error: Could not compile `playground`.
  33.  
  34. To learn more, run the command again with --verbose.
  35.  
  36. */
  37.  
  38. /* ~~~~=== stdout ===~~~~
  39.  
  40. */
Add Comment
Please, Sign In to add comment