@@ -28,42 +28,152 @@ pub fn test_fn_attrs() {
2828 // static __attribute__((always_inline)) void always_inline_static(void) {}
2929 // static __attribute__((__noinline__)) void noinline_static(void) {}
3030 // static void inline inline_static(void) {}
31- assert ! ( src. contains( "#[inline(always)]\n unsafe extern \" C\" fn rust_always_inline_static" ) ) ;
32- assert ! ( src. contains( "#[inline(never)]\n unsafe extern \" C\" fn rust_noinline_static" ) ) ;
33- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_inline_static" ) ) ;
34- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_alt_kw_inline_static" ) ) ;
35- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_gnu_inline_static" ) ) ;
36- assert ! ( src. contains( "#[cold]\n unsafe extern \" C\" fn rust_cold_used_attrs" ) ) ;
31+ assert ! ( src. contains(
32+ r#"
33+ #[inline(always)]
34+ unsafe extern "C" fn rust_always_inline_static
35+ "#
36+ . trim( ) ,
37+ ) ) ;
38+ assert ! ( src. contains(
39+ r#"
40+ #[inline(never)]
41+ unsafe extern "C" fn rust_noinline_static
42+ "#
43+ . trim( ) ,
44+ ) ) ;
45+ assert ! ( src. contains(
46+ r#"
47+ #[inline]
48+ unsafe extern "C" fn rust_inline_static
49+ "#
50+ . trim( ) ,
51+ ) ) ;
52+ assert ! ( src. contains(
53+ r#"
54+ #[inline]
55+ unsafe extern "C" fn rust_alt_kw_inline_static
56+ "#
57+ . trim( ) ,
58+ ) ) ;
59+ assert ! ( src. contains(
60+ r#"
61+ #[inline]
62+ unsafe extern "C" fn rust_gnu_inline_static
63+ "#
64+ . trim( ) ,
65+ ) ) ;
66+ assert ! ( src. contains(
67+ r#"
68+ #[cold]
69+ unsafe extern "C" fn rust_cold_used_attrs
70+ "#
71+ . trim( ) ,
72+ ) ) ;
3773
3874 // __attribute__((__always_inline__)) void always_inline_nonstatic(void) {}
3975 // __attribute__((noinline)) void noinline_nonstatic(void) {}
4076 // void inline inline_nonstatic(void) {}
41- assert ! ( src. contains( "#[inline(always)]\n unsafe extern \" C\" fn rust_always_inline_nonstatic" ) ) ;
42- assert ! ( src. contains( "#[inline(never)]\n pub unsafe extern \" C\" fn rust_noinline_nonstatic" ) ) ;
43- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_inline_nonstatic" ) ) ;
44- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_alt_kw_inline_nonstatic" ) ) ;
45- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_gnu_inline_nonstatic" ) ) ;
77+ assert ! ( src. contains(
78+ r#"
79+ #[inline(always)]
80+ unsafe extern "C" fn rust_always_inline_nonstatic
81+ "#
82+ . trim( ) ,
83+ ) ) ;
84+ assert ! ( src. contains(
85+ r#"
86+ #[inline(never)]
87+ pub unsafe extern "C" fn rust_noinline_nonstatic
88+ "#
89+ . trim( ) ,
90+ ) ) ;
91+ assert ! ( src. contains(
92+ r#"
93+ #[inline]
94+ unsafe extern "C" fn rust_inline_nonstatic
95+ "#
96+ . trim( ) ,
97+ ) ) ;
98+ assert ! ( src. contains(
99+ r#"
100+ #[inline]
101+ unsafe extern "C" fn rust_alt_kw_inline_nonstatic
102+ "#
103+ . trim( ) ,
104+ ) ) ;
105+ assert ! ( src. contains(
106+ r#"
107+ #[inline]
108+ unsafe extern "C" fn rust_gnu_inline_nonstatic
109+ "#
110+ . trim( ) ,
111+ ) ) ;
46112
47113 // extern void inline inline_extern(void) {}
48114 // extern void inline __attribute__((always_inline)) always_inline_extern(void) {}
49115 // extern void inline __attribute__((__gnu_inline__)) gnu_inline_extern(void) {}
50116 // extern void inline __attribute__((gnu_inline, always_inline)) always_inline_gnu_inline_extern(void) {}
51117 assert ! ( src. contains(
52- "#[inline]\n #[linkage = \" external\" ]\n pub unsafe extern \" C\" fn rust_inline_extern"
118+ r#"
119+ #[inline]
120+ #[linkage = "external"]
121+ pub unsafe extern "C" fn rust_inline_extern
122+ "#
123+ . trim( ) ,
124+ ) ) ;
125+ assert ! ( src. contains(
126+ r#"
127+ #[inline]
128+ #[linkage = "external"]
129+ pub unsafe extern "C" fn rust_alt_kw_inline_extern
130+ "#
131+ . trim( ) ,
132+ ) ) ;
133+ assert ! ( src. contains(
134+ r#"
135+ #[inline(always)]
136+ pub unsafe extern "C" fn rust_always_inline_extern
137+ "#
138+ . trim( ) ,
139+ ) ) ;
140+ assert ! ( src. contains(
141+ r#"
142+ #[inline]
143+ unsafe extern "C" fn rust_gnu_inline_extern
144+ "#
145+ . trim( ) ,
53146 ) ) ;
54- assert ! ( src. contains( "#[inline]\n #[linkage = \" external\" ]\n pub unsafe extern \" C\" fn rust_alt_kw_inline_extern" ) ) ;
55- assert ! ( src. contains( "#[inline(always)]\n pub unsafe extern \" C\" fn rust_always_inline_extern" ) ) ;
56- assert ! ( src. contains( "#[inline]\n unsafe extern \" C\" fn rust_gnu_inline_extern" ) ) ;
57147 assert ! ( src. contains(
58- "#[inline(always)]\n unsafe extern \" C\" fn rust_always_inline_gnu_inline_extern"
148+ r#"
149+ #[inline(always)]
150+ unsafe extern "C" fn rust_always_inline_gnu_inline_extern
151+ "#
152+ . trim( ) ,
59153 ) ) ;
60154 assert ! ( src. contains(
61- "#[inline]\n unsafe extern \" C\" fn rust_gnu_inline_non_canonical_definition_extern"
155+ r#"
156+ #[inline]
157+ unsafe extern "C" fn rust_gnu_inline_non_canonical_definition_extern
158+ "#
159+ . trim( ) ,
62160 ) ) ;
63161
64162 if cfg ! ( not( target_os = "macos" ) ) {
65163 // aliased_fn is aliased to the inline_extern function
66- let aliased_fn_syntax = |public| format ! ( "extern \" C\" {{\n #[link_name = \" inline_extern\" ]\n {}fn aliased_fn();" , public) ;
67- assert ! ( src. contains( & aliased_fn_syntax( "" ) ) || src. contains( & aliased_fn_syntax( "pub " ) ) ) ;
164+ let aliased_fn_syntax = |public| {
165+ format ! (
166+ r#"
167+ extern "C" {{
168+ #[link_name = "inline_extern"]
169+ {}fn aliased_fn();
170+ "# ,
171+ public
172+ )
173+ } ;
174+ assert ! (
175+ src. contains( aliased_fn_syntax( "" ) . trim( ) )
176+ || src. contains( aliased_fn_syntax( "pub " ) . trim( ) )
177+ ) ;
68178 }
69179}
0 commit comments