@@ -158,75 +158,85 @@ cfg_if! {
158158mod error;
159159pub use crate :: error:: Error ;
160160
161- #[ allow( dead_code) ]
162161mod util;
163162
164- #[ cfg( target_os = "vxworks" ) ]
165- #[ allow( dead_code) ]
166- mod util_libc;
167-
168- cfg_if ! {
169- // Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls.
170- if #[ cfg( any( target_os = "android" , target_os = "dragonfly" , target_os = "emscripten" ,
171- target_os = "freebsd" , target_os = "haiku" , target_os = "illumos" ,
172- target_os = "linux" , target_os = "macos" , target_os = "netbsd" ,
173- target_os = "openbsd" , target_os = "redox" , target_os = "solaris" ) ) ] {
174- #[ allow( dead_code) ]
175- mod util_libc;
176- // Keep std-only trait definitions for backwards compatibility
177- mod error_impls;
178- } else if #[ cfg( feature = "std" ) ] {
179- mod error_impls;
180- }
181- }
182-
183- // These targets read from a file as a fallback method.
163+ // For backwards compatibility, we provide the std-only trait implementations
164+ // for some platforms, even if they don't enable the "std" feature.
184165#[ cfg( any(
166+ feature = "std" ,
167+ all( windows, not( getrandom_uwp) ) ,
185168 target_os = "android" ,
169+ target_os = "dragonfly" ,
170+ target_os = "emscripten" ,
171+ target_os = "freebsd" ,
172+ target_os = "fuchsia" ,
173+ target_os = "haiku" ,
174+ target_os = "illumos" ,
175+ target_os = "ios" ,
186176 target_os = "linux" ,
187177 target_os = "macos" ,
178+ target_os = "netbsd" ,
179+ target_os = "openbsd" ,
180+ target_os = "redox" ,
188181 target_os = "solaris" ,
189- target_os = "illumos" ,
190182) ) ]
191- mod use_file ;
183+ mod error_impls ;
192184
193185// System-specific implementations.
194186//
195187// These should all provide getrandom_inner with the same signature as getrandom.
196188cfg_if ! {
197189 if #[ cfg( target_os = "android" ) ] {
190+ mod util_libc;
191+ mod use_file;
198192 #[ path = "linux_android.rs" ] mod imp;
199193 } else if #[ cfg( target_os = "cloudabi" ) ] {
200194 #[ path = "cloudabi.rs" ] mod imp;
201195 } else if #[ cfg( target_os = "dragonfly" ) ] {
196+ mod util_libc;
202197 #[ path = "use_file.rs" ] mod imp;
203198 } else if #[ cfg( target_os = "emscripten" ) ] {
199+ mod util_libc;
204200 #[ path = "use_file.rs" ] mod imp;
205201 } else if #[ cfg( target_os = "freebsd" ) ] {
202+ mod util_libc;
206203 #[ path = "bsd_arandom.rs" ] mod imp;
207204 } else if #[ cfg( target_os = "fuchsia" ) ] {
208205 #[ path = "fuchsia.rs" ] mod imp;
209206 } else if #[ cfg( target_os = "haiku" ) ] {
207+ mod util_libc;
210208 #[ path = "use_file.rs" ] mod imp;
211209 } else if #[ cfg( target_os = "illumos" ) ] {
210+ mod util_libc;
211+ mod use_file;
212212 #[ path = "solaris_illumos.rs" ] mod imp;
213213 } else if #[ cfg( target_os = "ios" ) ] {
214214 #[ path = "ios.rs" ] mod imp;
215215 } else if #[ cfg( target_os = "linux" ) ] {
216+ mod util_libc;
217+ mod use_file;
216218 #[ path = "linux_android.rs" ] mod imp;
217219 } else if #[ cfg( target_os = "macos" ) ] {
220+ mod util_libc;
221+ mod use_file;
218222 #[ path = "macos.rs" ] mod imp;
219223 } else if #[ cfg( target_os = "netbsd" ) ] {
224+ mod util_libc;
220225 #[ path = "bsd_arandom.rs" ] mod imp;
221226 } else if #[ cfg( target_os = "openbsd" ) ] {
227+ mod util_libc;
222228 #[ path = "openbsd.rs" ] mod imp;
223229 } else if #[ cfg( target_os = "redox" ) ] {
230+ mod util_libc;
224231 #[ path = "use_file.rs" ] mod imp;
225232 } else if #[ cfg( target_os = "solaris" ) ] {
233+ mod util_libc;
234+ mod use_file;
226235 #[ path = "solaris_illumos.rs" ] mod imp;
227236 } else if #[ cfg( target_os = "wasi" ) ] {
228237 #[ path = "wasi.rs" ] mod imp;
229238 } else if #[ cfg( target_os = "vxworks" ) ] {
239+ mod util_libc;
230240 #[ path = "vxworks.rs" ] mod imp;
231241 } else if #[ cfg( all( windows, getrandom_uwp) ) ] {
232242 #[ path = "windows_uwp.rs" ] mod imp;
0 commit comments