This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit b335ec9
Add a special case for CStr/CString in the improper_ctypes lint
Instead of saying to "consider adding a `#[repr(C)]` or
`#[repr(transparent)]` attribute to this struct", we now tell users to
"Use `*const ffi::c_char` instead, and pass the value from
`CStr::as_ptr()`" when the type involved is a `CStr` or a `CString`.
Co-authored-by: Jieyou Xu <[email protected]>1 parent 93ea767 commit b335ec9
File tree
7 files changed
+172
-21
lines changed- compiler
- rustc_lint
- src
- rustc_span/src
- library/core/src/ffi
- tests/ui
- extern
- lint
7 files changed
+172
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
364 | 369 | | |
365 | 370 | | |
366 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
987 | 995 | | |
988 | 996 | | |
989 | 997 | | |
| |||
1212 | 1220 | | |
1213 | 1221 | | |
1214 | 1222 | | |
1215 | | - | |
| 1223 | + | |
1216 | 1224 | | |
1217 | 1225 | | |
1218 | 1226 | | |
| |||
1222 | 1230 | | |
1223 | 1231 | | |
1224 | 1232 | | |
1225 | | - | |
| 1233 | + | |
1226 | 1234 | | |
1227 | 1235 | | |
1228 | 1236 | | |
1229 | 1237 | | |
1230 | 1238 | | |
1231 | | - | |
| 1239 | + | |
1232 | 1240 | | |
1233 | 1241 | | |
1234 | 1242 | | |
| |||
1238 | 1246 | | |
1239 | 1247 | | |
1240 | 1248 | | |
1241 | | - | |
| 1249 | + | |
1242 | 1250 | | |
1243 | 1251 | | |
1244 | 1252 | | |
| |||
1256 | 1264 | | |
1257 | 1265 | | |
1258 | 1266 | | |
1259 | | - | |
| 1267 | + | |
1260 | 1268 | | |
1261 | 1269 | | |
1262 | 1270 | | |
| |||
1276 | 1284 | | |
1277 | 1285 | | |
1278 | 1286 | | |
1279 | | - | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
1280 | 1292 | | |
1281 | 1293 | | |
1282 | 1294 | | |
| |||
1285 | 1297 | | |
1286 | 1298 | | |
1287 | 1299 | | |
1288 | | - | |
| 1300 | + | |
1289 | 1301 | | |
1290 | 1302 | | |
1291 | 1303 | | |
| |||
1307 | 1319 | | |
1308 | 1320 | | |
1309 | 1321 | | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1310 | 1333 | | |
1311 | 1334 | | |
1312 | 1335 | | |
| |||
1353 | 1376 | | |
1354 | 1377 | | |
1355 | 1378 | | |
1356 | | - | |
| 1379 | + | |
1357 | 1380 | | |
1358 | 1381 | | |
1359 | 1382 | | |
| |||
1377 | 1400 | | |
1378 | 1401 | | |
1379 | 1402 | | |
1380 | | - | |
| 1403 | + | |
1381 | 1404 | | |
1382 | 1405 | | |
1383 | 1406 | | |
| |||
1398 | 1421 | | |
1399 | 1422 | | |
1400 | 1423 | | |
1401 | | - | |
| 1424 | + | |
1402 | 1425 | | |
1403 | 1426 | | |
1404 | 1427 | | |
| |||
1468 | 1491 | | |
1469 | 1492 | | |
1470 | 1493 | | |
1471 | | - | |
| 1494 | + | |
1472 | 1495 | | |
1473 | | - | |
| 1496 | + | |
1474 | 1497 | | |
1475 | 1498 | | |
1476 | 1499 | | |
| |||
1483 | 1506 | | |
1484 | 1507 | | |
1485 | 1508 | | |
1486 | | - | |
| 1509 | + | |
1487 | 1510 | | |
1488 | 1511 | | |
1489 | 1512 | | |
| |||
1494 | 1517 | | |
1495 | 1518 | | |
1496 | 1519 | | |
1497 | | - | |
| 1520 | + | |
1498 | 1521 | | |
1499 | 1522 | | |
1500 | 1523 | | |
| |||
1617 | 1640 | | |
1618 | 1641 | | |
1619 | 1642 | | |
1620 | | - | |
| 1643 | + | |
| 1644 | + | |
1621 | 1645 | | |
1622 | 1646 | | |
1623 | 1647 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
| 674 | + | |
674 | 675 | | |
675 | 676 | | |
676 | 677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
0 commit comments