@@ -1354,6 +1354,92 @@ list of substrings of `STR' each followed by its face."
1354
1354
" mut" font-lock-keyword-face
1355
1355
" bar" font-lock-variable-name-face )))
1356
1356
1357
+ (ert-deftest font-lock-ampersand ()
1358
+ (rust-test-font-lock
1359
+ " f(&a)"
1360
+ '(" &" rust-ampersand-face))
1361
+ (rust-test-font-lock
1362
+ " a && b &&& c"
1363
+ nil )
1364
+ (rust-test-font-lock
1365
+ " &'a v"
1366
+ '(" &" rust-ampersand-face
1367
+ " a" font-lock-variable-name-face ))
1368
+ (rust-test-font-lock
1369
+ " &'static v"
1370
+ '(" &" rust-ampersand-face
1371
+ " static" font-lock-keyword-face ))
1372
+ (rust-test-font-lock
1373
+ " &mut v"
1374
+ '(" &" rust-ampersand-face
1375
+ " mut" font-lock-keyword-face ))
1376
+ (rust-test-font-lock
1377
+ " &f(&x)"
1378
+ '(" &" rust-ampersand-face
1379
+ " &" rust-ampersand-face))
1380
+ (rust-test-font-lock
1381
+ " fn f(x: &X)"
1382
+ '(" fn" font-lock-keyword-face
1383
+ " f" font-lock-function-name-face
1384
+ " x" font-lock-variable-name-face
1385
+ " &" rust-ampersand-face
1386
+ " X" font-lock-type-face ))
1387
+ (rust-test-font-lock
1388
+ " f(&X{x})"
1389
+ '(" &" rust-ampersand-face
1390
+ " X" font-lock-type-face ))
1391
+ (rust-test-font-lock
1392
+ " let x: &'_ f64 = &1.;"
1393
+ '(" let" font-lock-keyword-face
1394
+ " x" font-lock-variable-name-face
1395
+ " &" rust-ampersand-face
1396
+ " _" font-lock-variable-name-face
1397
+ " f64" font-lock-type-face
1398
+ " &" rust-ampersand-face))
1399
+ (rust-test-font-lock
1400
+ " let x = &&1;"
1401
+ '(" let" font-lock-keyword-face
1402
+ " x" font-lock-variable-name-face
1403
+ " &&" rust-ampersand-face))
1404
+ (rust-test-font-lock
1405
+ " let x = &*y;"
1406
+ '(" let" font-lock-keyword-face
1407
+ " x" font-lock-variable-name-face
1408
+ " &" rust-ampersand-face))
1409
+ (rust-test-font-lock
1410
+ " let x = &::std::f64::consts::PI;"
1411
+ '(" let" font-lock-keyword-face
1412
+ " x" font-lock-variable-name-face
1413
+ " &" rust-ampersand-face
1414
+ " std" font-lock-constant-face
1415
+ " f64" font-lock-type-face
1416
+ " consts" font-lock-constant-face
1417
+ " PI" font-lock-type-face ))
1418
+ (rust-test-font-lock
1419
+ " let x = &(1, 2);"
1420
+ '(" let" font-lock-keyword-face
1421
+ " x" font-lock-variable-name-face
1422
+ " &" rust-ampersand-face))
1423
+ (rust-test-font-lock
1424
+ " let x = &{1};"
1425
+ '(" let" font-lock-keyword-face
1426
+ " x" font-lock-variable-name-face
1427
+ " &" rust-ampersand-face))
1428
+ (rust-test-font-lock
1429
+ " let f = &|x| {x + 1};"
1430
+ '(" let" font-lock-keyword-face
1431
+ " f" font-lock-variable-name-face
1432
+ " &" rust-ampersand-face))
1433
+ (rust-test-font-lock
1434
+ " let x: &_ = &1;"
1435
+ '(" let" font-lock-keyword-face
1436
+ " x" font-lock-variable-name-face
1437
+ " &" rust-ampersand-face
1438
+ " &" rust-ampersand-face))
1439
+ (rust-test-font-lock
1440
+ " &[1,2]"
1441
+ '(" &" rust-ampersand-face)))
1442
+
1357
1443
(ert-deftest font-lock-if-let-binding ()
1358
1444
(rust-test-font-lock
1359
1445
" if let Some(var) = some_var { /* no-op */ }"
0 commit comments