]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/simplify_try_if_let.rs
Add extended error message for E0523
[rust.git] / tests / mir-opt / simplify_try_if_let.rs
1 // compile-flags: -Zmir-opt-level=1 -Zunsound-mir-opts
2 // ignore-test
3 // FIXME: the pass is unsound and causes ICEs in the MIR validator
4
5 // EMIT_MIR simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff
6
7 use std::ptr::NonNull;
8
9 pub struct LinkedList {
10     head: Option<NonNull<Node>>,
11     tail: Option<NonNull<Node>>,
12 }
13
14 pub struct Node {
15     next: Option<NonNull<Node>>,
16 }
17
18 impl LinkedList {
19     pub fn new() -> Self {
20         Self { head: None, tail: None }
21     }
22
23     pub fn append(&mut self, other: &mut Self) {
24         match self.tail {
25             None => {}
26             Some(mut tail) => {
27                 // `as_mut` is okay here because we have exclusive access to the entirety
28                 // of both lists.
29                 if let Some(other_head) = other.head.take() {
30                     unsafe {
31                         tail.as_mut().next = Some(other_head);
32                     }
33                 }
34             }
35         }
36     }
37 }
38
39 fn main() {
40     let mut one = LinkedList::new();
41     let mut two = LinkedList::new();
42     one.append(&mut two);
43 }