$ rustc lifetime1_bad.rs 
error[E0597]: `val` does not live long enough
 --> lifetime1_bad.rs:5:16
  |
5 |         ptr = &val;
  |                ^^^ borrowed value does not live long enough
6 |     }
  |     - `val` dropped here while still borrowed
7 |     println!("*ptr = {}", *ptr);
8 | }
  | - borrowed value needs to live until here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.