@@ -1337,9 +1337,24 @@ pub fn anyref_heap_live_count() -> u32 {
1337
1337
pub trait UnwrapThrowExt < T > : Sized {
1338
1338
/// Unwrap this `Option` or `Result`, but instead of panicking on failure,
1339
1339
/// throw an exception to JavaScript.
1340
- #[ cfg_attr( debug_assertions, track_caller) ]
1340
+ #[ cfg_attr(
1341
+ any(
1342
+ debug_assertions,
1343
+ not( all(
1344
+ target_arch = "wasm32" ,
1345
+ not( any( target_os = "emscripten" , target_os = "wasi" ) )
1346
+ ) )
1347
+ ) ,
1348
+ track_caller
1349
+ ) ]
1341
1350
fn unwrap_throw ( self ) -> T {
1342
- if cfg ! ( all( debug_assertions, feature = "std" ) ) {
1351
+ if cfg ! ( all(
1352
+ debug_assertions,
1353
+ all(
1354
+ target_arch = "wasm32" ,
1355
+ not( any( target_os = "emscripten" , target_os = "wasi" ) )
1356
+ )
1357
+ ) ) {
1343
1358
let loc = core:: panic:: Location :: caller ( ) ;
1344
1359
let msg = alloc:: format!(
1345
1360
"`unwrap_throw` failed ({}:{}:{})" ,
@@ -1356,12 +1371,20 @@ pub trait UnwrapThrowExt<T>: Sized {
1356
1371
/// Unwrap this container's `T` value, or throw an error to JS with the
1357
1372
/// given message if the `T` value is unavailable (e.g. an `Option<T>` is
1358
1373
/// `None`).
1359
- #[ cfg_attr( debug_assertions, track_caller) ]
1374
+ #[ cfg_attr(
1375
+ any(
1376
+ debug_assertions,
1377
+ not( all(
1378
+ target_arch = "wasm32" ,
1379
+ not( any( target_os = "emscripten" , target_os = "wasi" ) )
1380
+ ) )
1381
+ ) ,
1382
+ track_caller
1383
+ ) ]
1360
1384
fn expect_throw ( self , message : & str ) -> T ;
1361
1385
}
1362
1386
1363
1387
impl < T > UnwrapThrowExt < T > for Option < T > {
1364
- #[ cfg_attr( debug_assertions, track_caller) ]
1365
1388
fn expect_throw ( self , message : & str ) -> T {
1366
1389
if cfg ! ( all(
1367
1390
target_arch = "wasm32" ,
@@ -1381,9 +1404,9 @@ impl<T, E> UnwrapThrowExt<T> for Result<T, E>
1381
1404
where
1382
1405
E : core:: fmt:: Debug ,
1383
1406
{
1384
- #[ cfg_attr( debug_assertions, track_caller) ]
1385
1407
fn unwrap_throw ( self ) -> T {
1386
1408
if cfg ! ( all(
1409
+ debug_assertions,
1387
1410
target_arch = "wasm32" ,
1388
1411
not( any( target_os = "emscripten" , target_os = "wasi" ) )
1389
1412
) ) {
@@ -1403,11 +1426,10 @@ where
1403
1426
}
1404
1427
}
1405
1428
} else {
1406
- self . unwrap ( )
1429
+ self . expect ( "`unwrap_throw` failed" )
1407
1430
}
1408
1431
}
1409
1432
1410
- #[ cfg_attr( debug_assertions, track_caller) ]
1411
1433
fn expect_throw ( self , message : & str ) -> T {
1412
1434
if cfg ! ( all(
1413
1435
target_arch = "wasm32" ,
0 commit comments