This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 4ea52f1
committed
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`.
Inspired by a conversation on the #beginners Discord channel.1 parent c3b05c6 commit 4ea52f1
File tree
6 files changed
+165
-14
lines changed- compiler
- rustc_lint
- src
- rustc_span/src
- library/core/src/ffi
- tests/ui/lint
6 files changed
+165
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
286 | 291 | | |
287 | 292 | | |
288 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
957 | 957 | | |
958 | 958 | | |
959 | 959 | | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
960 | 968 | | |
961 | 969 | | |
962 | 970 | | |
| |||
1143 | 1151 | | |
1144 | 1152 | | |
1145 | 1153 | | |
1146 | | - | |
| 1154 | + | |
1147 | 1155 | | |
1148 | 1156 | | |
1149 | 1157 | | |
| |||
1153 | 1161 | | |
1154 | 1162 | | |
1155 | 1163 | | |
1156 | | - | |
| 1164 | + | |
1157 | 1165 | | |
1158 | 1166 | | |
1159 | 1167 | | |
1160 | 1168 | | |
1161 | 1169 | | |
1162 | | - | |
| 1170 | + | |
1163 | 1171 | | |
1164 | 1172 | | |
1165 | 1173 | | |
| |||
1170 | 1178 | | |
1171 | 1179 | | |
1172 | 1180 | | |
1173 | | - | |
| 1181 | + | |
1174 | 1182 | | |
1175 | 1183 | | |
1176 | 1184 | | |
| |||
1188 | 1196 | | |
1189 | 1197 | | |
1190 | 1198 | | |
1191 | | - | |
| 1199 | + | |
1192 | 1200 | | |
1193 | 1201 | | |
1194 | 1202 | | |
| |||
1208 | 1216 | | |
1209 | 1217 | | |
1210 | 1218 | | |
1211 | | - | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
1212 | 1224 | | |
1213 | 1225 | | |
1214 | 1226 | | |
| |||
1217 | 1229 | | |
1218 | 1230 | | |
1219 | 1231 | | |
1220 | | - | |
| 1232 | + | |
1221 | 1233 | | |
1222 | 1234 | | |
1223 | 1235 | | |
| |||
1239 | 1251 | | |
1240 | 1252 | | |
1241 | 1253 | | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
1242 | 1265 | | |
1243 | 1266 | | |
1244 | 1267 | | |
| |||
1285 | 1308 | | |
1286 | 1309 | | |
1287 | 1310 | | |
1288 | | - | |
| 1311 | + | |
1289 | 1312 | | |
1290 | 1313 | | |
1291 | 1314 | | |
| |||
1328 | 1351 | | |
1329 | 1352 | | |
1330 | 1353 | | |
1331 | | - | |
| 1354 | + | |
1332 | 1355 | | |
1333 | 1356 | | |
1334 | 1357 | | |
| |||
1392 | 1415 | | |
1393 | 1416 | | |
1394 | 1417 | | |
1395 | | - | |
| 1418 | + | |
1396 | 1419 | | |
1397 | | - | |
| 1420 | + | |
1398 | 1421 | | |
1399 | 1422 | | |
1400 | 1423 | | |
| |||
1407 | 1430 | | |
1408 | 1431 | | |
1409 | 1432 | | |
1410 | | - | |
| 1433 | + | |
1411 | 1434 | | |
1412 | 1435 | | |
1413 | 1436 | | |
| |||
1418 | 1441 | | |
1419 | 1442 | | |
1420 | 1443 | | |
1421 | | - | |
| 1444 | + | |
1422 | 1445 | | |
1423 | 1446 | | |
1424 | 1447 | | |
| |||
1541 | 1564 | | |
1542 | 1565 | | |
1543 | 1566 | | |
1544 | | - | |
| 1567 | + | |
| 1568 | + | |
1545 | 1569 | | |
1546 | 1570 | | |
1547 | 1571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| 633 | + | |
633 | 634 | | |
634 | 635 | | |
635 | 636 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
| 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