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