1- #![ cfg_attr( target_arch = "wasm32" , allow( unused) ) ]
1+ #![ cfg_attr(
2+ all( target_arch = "wasm32" , any( target_os = "unknown" , target_os = "none" ) ) ,
3+ allow( unused)
4+ ) ]
25use std:: error:: Error as StdError ;
36use std:: fmt;
47use std:: io;
@@ -102,11 +105,11 @@ impl Error {
102105
103106 /// Returns true if the error is from `Response::error_for_status`.
104107 pub fn is_status ( & self ) -> bool {
105- #[ cfg( not( target_arch = "wasm32" ) ) ]
108+ #[ cfg( not( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ) ]
106109 {
107110 matches ! ( self . inner. kind, Kind :: Status ( _, _) )
108111 }
109- #[ cfg( target_arch = "wasm32" ) ]
112+ #[ cfg( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ]
110113 {
111114 matches ! ( self . inner. kind, Kind :: Status ( _) )
112115 }
@@ -120,7 +123,10 @@ impl Error {
120123 if err. is :: < TimedOut > ( ) {
121124 return true ;
122125 }
123- #[ cfg( not( target_arch = "wasm32" ) ) ]
126+ #[ cfg( not( all(
127+ target_arch = "wasm32" ,
128+ any( target_os = "unknown" , target_os = "none" )
129+ ) ) ) ]
124130 if let Some ( hyper_err) = err. downcast_ref :: < hyper:: Error > ( ) {
125131 if hyper_err. is_timeout ( ) {
126132 return true ;
@@ -142,7 +148,7 @@ impl Error {
142148 matches ! ( self . inner. kind, Kind :: Request )
143149 }
144150
145- #[ cfg( not( target_arch = "wasm32" ) ) ]
151+ #[ cfg( not( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ) ]
146152 /// Returns true if the error is related to connect
147153 pub fn is_connect ( & self ) -> bool {
148154 let mut source = self . source ( ) ;
@@ -173,9 +179,12 @@ impl Error {
173179 /// Returns the status code, if the error was generated from a response.
174180 pub fn status ( & self ) -> Option < StatusCode > {
175181 match self . inner . kind {
176- #[ cfg( target_arch = "wasm32" ) ]
182+ #[ cfg( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ]
177183 Kind :: Status ( code) => Some ( code) ,
178- #[ cfg( not( target_arch = "wasm32" ) ) ]
184+ #[ cfg( not( all(
185+ target_arch = "wasm32" ,
186+ any( target_os = "unknown" , target_os = "none" )
187+ ) ) ) ]
179188 Kind :: Status ( code, _) => Some ( code) ,
180189 _ => None ,
181190 }
@@ -198,7 +207,7 @@ impl Error {
198207/// internal equivalents.
199208///
200209/// Currently only is used for `tower::timeout::error::Elapsed`.
201- #[ cfg( not( target_arch = "wasm32" ) ) ]
210+ #[ cfg( not( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ) ]
202211pub ( crate ) fn cast_to_internal_error ( error : BoxError ) -> BoxError {
203212 if error. is :: < tower:: timeout:: error:: Elapsed > ( ) {
204213 Box :: new ( crate :: error:: TimedOut ) as BoxError
@@ -233,7 +242,7 @@ impl fmt::Display for Error {
233242 Kind :: Decode => f. write_str ( "error decoding response body" ) ?,
234243 Kind :: Redirect => f. write_str ( "error following redirect" ) ?,
235244 Kind :: Upgrade => f. write_str ( "error upgrading connection" ) ?,
236- #[ cfg( target_arch = "wasm32" ) ]
245+ #[ cfg( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ]
237246 Kind :: Status ( ref code) => {
238247 let prefix = if code. is_client_error ( ) {
239248 "HTTP status client error"
@@ -243,7 +252,10 @@ impl fmt::Display for Error {
243252 } ;
244253 write ! ( f, "{prefix} ({code})" ) ?;
245254 }
246- #[ cfg( not( target_arch = "wasm32" ) ) ]
255+ #[ cfg( not( all(
256+ target_arch = "wasm32" ,
257+ any( target_os = "unknown" , target_os = "none" )
258+ ) ) ) ]
247259 Kind :: Status ( ref code, ref reason) => {
248260 let prefix = if code. is_client_error ( ) {
249261 "HTTP status client error"
@@ -278,14 +290,14 @@ impl StdError for Error {
278290 }
279291}
280292
281- #[ cfg( target_arch = "wasm32" ) ]
293+ #[ cfg( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ]
282294impl From < crate :: error:: Error > for wasm_bindgen:: JsValue {
283295 fn from ( err : Error ) -> wasm_bindgen:: JsValue {
284296 js_sys:: Error :: from ( err) . into ( )
285297 }
286298}
287299
288- #[ cfg( target_arch = "wasm32" ) ]
300+ #[ cfg( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ]
289301impl From < crate :: error:: Error > for js_sys:: Error {
290302 fn from ( err : Error ) -> js_sys:: Error {
291303 js_sys:: Error :: new ( & format ! ( "{err}" ) )
@@ -297,9 +309,9 @@ pub(crate) enum Kind {
297309 Builder ,
298310 Request ,
299311 Redirect ,
300- #[ cfg( not( target_arch = "wasm32" ) ) ]
312+ #[ cfg( not( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ) ]
301313 Status ( StatusCode , Option < hyper:: ext:: ReasonPhrase > ) ,
302- #[ cfg( target_arch = "wasm32" ) ]
314+ #[ cfg( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ]
303315 Status ( StatusCode ) ,
304316 Body ,
305317 Decode ,
@@ -331,12 +343,15 @@ pub(crate) fn redirect<E: Into<BoxError>>(e: E, url: Url) -> Error {
331343pub ( crate ) fn status_code (
332344 url : Url ,
333345 status : StatusCode ,
334- #[ cfg( not( target_arch = "wasm32" ) ) ] reason : Option < hyper:: ext:: ReasonPhrase > ,
346+ #[ cfg( not( all ( target_arch = "wasm32" , any ( target_os = "unknown" , target_os = "none" ) ) ) ) ] reason : Option < hyper:: ext:: ReasonPhrase > ,
335347) -> Error {
336348 Error :: new (
337349 Kind :: Status (
338350 status,
339- #[ cfg( not( target_arch = "wasm32" ) ) ]
351+ #[ cfg( not( all(
352+ target_arch = "wasm32" ,
353+ any( target_os = "unknown" , target_os = "none" )
354+ ) ) ) ]
340355 reason,
341356 ) ,
342357 None :: < Error > ,
0 commit comments