]> git.lizzy.rs Git - rust.git/blob - src/test/ui/asm/naked-functions-unused.rs
Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyup
[rust.git] / src / test / ui / asm / naked-functions-unused.rs
1 // revisions: x86_64 aarch64
2 //[x86_64] only-x86_64
3 //[aarch64] only-aarch64
4 #![deny(unused)]
5 #![feature(naked_functions)]
6 #![crate_type = "lib"]
7
8 pub trait Trait {
9     extern "C" fn trait_associated(a: usize, b: usize) -> usize;
10     extern "C" fn trait_method(&self, a: usize, b: usize) -> usize;
11 }
12
13 pub mod normal {
14     use std::arch::asm;
15
16     pub extern "C" fn function(a: usize, b: usize) -> usize {
17         //~^ ERROR unused variable: `a`
18         //~| ERROR unused variable: `b`
19         unsafe { asm!("", options(noreturn)); }
20     }
21
22     pub struct Normal;
23
24     impl Normal {
25         pub extern "C" fn associated(a: usize, b: usize) -> usize {
26             //~^ ERROR unused variable: `a`
27             //~| ERROR unused variable: `b`
28             unsafe { asm!("", options(noreturn)); }
29         }
30
31         pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
32             //~^ ERROR unused variable: `a`
33             //~| ERROR unused variable: `b`
34             unsafe { asm!("", options(noreturn)); }
35         }
36     }
37
38     impl super::Trait for Normal {
39         extern "C" fn trait_associated(a: usize, b: usize) -> usize {
40             //~^ ERROR unused variable: `a`
41             //~| ERROR unused variable: `b`
42             unsafe { asm!("", options(noreturn)); }
43         }
44
45         extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
46             //~^ ERROR unused variable: `a`
47             //~| ERROR unused variable: `b`
48             unsafe { asm!("", options(noreturn)); }
49         }
50     }
51 }
52
53 pub mod naked {
54     use std::arch::asm;
55
56     #[naked]
57     pub extern "C" fn function(a: usize, b: usize) -> usize {
58         unsafe { asm!("", options(noreturn)); }
59     }
60
61     pub struct Naked;
62
63     impl Naked {
64         #[naked]
65         pub extern "C" fn associated(a: usize, b: usize) -> usize {
66             unsafe { asm!("", options(noreturn)); }
67         }
68
69         #[naked]
70         pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
71             unsafe { asm!("", options(noreturn)); }
72         }
73     }
74
75     impl super::Trait for Naked {
76         #[naked]
77         extern "C" fn trait_associated(a: usize, b: usize) -> usize {
78             unsafe { asm!("", options(noreturn)); }
79         }
80
81         #[naked]
82         extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
83             unsafe { asm!("", options(noreturn)); }
84         }
85     }
86 }