]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-14936.rs
Add test for promotability in `let`
[rust.git] / src / test / ui / issues / issue-14936.rs
1 // build-pass (FIXME(62277): could be check-pass?)
2 #![allow(unused_macros)]
3 #![allow(dead_code)]
4 #![feature(asm)]
5
6 type History = Vec<&'static str>;
7
8 fn wrap<A>(x:A, which: &'static str, history: &mut History) -> A {
9     history.push(which);
10     x
11 }
12
13 macro_rules! demo {
14     ( $output_constraint:tt ) => {
15         {
16             let mut x: isize = 0;
17             let y: isize = 1;
18
19             let mut history: History = vec![];
20             unsafe {
21                 asm!("mov ($1), $0"
22                      : $output_constraint (*wrap(&mut x, "out", &mut history))
23                      : "r"(&wrap(y, "in", &mut history))
24                      :: "volatile");
25             }
26             assert_eq!((x,y), (1,1));
27             let b: &[_] = &["out", "in"];
28             assert_eq!(history, b);
29         }
30     }
31 }
32
33 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
34 fn main() {
35     fn out_write_only_expr_then_in_expr() {
36         demo!("=r")
37     }
38
39     fn out_read_write_expr_then_in_expr() {
40         demo!("+r")
41     }
42
43     out_write_only_expr_then_in_expr();
44     out_read_write_expr_then_in_expr();
45 }
46
47 #[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
48 pub fn main() {}