{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/30499","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/30499/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/30499/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/30499/events","html_url":"https://github.com/rust-lang/rust/pull/30499","id":123169427,"number":30499,"title":"improper_ctypes: also check extern fn's","user":{"login":"TimNN","id":1178249,"avatar_url":"https://avatars.githubusercontent.com/u/1178249?v=3","gravatar_id":"","url":"https://api.github.com/users/TimNN","html_url":"https://github.com/TimNN","followers_url":"https://api.github.com/users/TimNN/followers","following_url":"https://api.github.com/users/TimNN/following{/other_user}","gists_url":"https://api.github.com/users/TimNN/gists{/gist_id}","starred_url":"https://api.github.com/users/TimNN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimNN/subscriptions","organizations_url":"https://api.github.com/users/TimNN/orgs","repos_url":"https://api.github.com/users/TimNN/repos","events_url":"https://api.github.com/users/TimNN/events{/privacy}","received_events_url":"https://api.github.com/users/TimNN/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-12-20T16:07:28Z","updated_at":"2015-12-20T19:22:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/30499","html_url":"https://github.com/rust-lang/rust/pull/30499","diff_url":"https://github.com/rust-lang/rust/pull/30499.diff","patch_url":"https://github.com/rust-lang/rust/pull/30499.patch"},"body":"The improper ctypes lint currently only checks functions inside of `extern` blocks. This changes the lint so that it also checks all functions with an `extern` calling convention.\r\n\r\nCloses #19834.\r\n\r\nThis probably need a crater run.\r\n\r\n**Edit:** I just realised that there's still some stuff to be tested: generics and methods, I will add those soon."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/166148425","html_url":"https://github.com/rust-lang/rust/pull/30499#issuecomment-166148425","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/30499","id":166148425,"user":{"login":"TimNN","id":1178249,"avatar_url":"https://avatars.githubusercontent.com/u/1178249?v=3","gravatar_id":"","url":"https://api.github.com/users/TimNN","html_url":"https://github.com/TimNN","followers_url":"https://api.github.com/users/TimNN/followers","following_url":"https://api.github.com/users/TimNN/following{/other_user}","gists_url":"https://api.github.com/users/TimNN/gists{/gist_id}","starred_url":"https://api.github.com/users/TimNN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimNN/subscriptions","organizations_url":"https://api.github.com/users/TimNN/orgs","repos_url":"https://api.github.com/users/TimNN/repos","events_url":"https://api.github.com/users/TimNN/events{/privacy}","received_events_url":"https://api.github.com/users/TimNN/received_events","type":"User","site_admin":false},"created_at":"2015-12-20T19:22:06Z","updated_at":"2015-12-20T19:22:06Z","body":"I understand your argument and it is the same reason why structs with `#[repr(C)]` do not trigger a warning by themselves as far as I know.\r\n\r\nOn the other hand we have people unfamiliar with rust who would have benefited from such a lint (see https://github.com/rust-lang/rust/issues/19834#issuecomment-143642665) and I personally would like for rust to check that I did not make a mistake in my c api.\r\n\r\nI have rarely seen a use for functions with a custom calling convention which were not meant to be used from c, so in my mind warning about them is preferable, especially since you can opt-out of these checks but not opt-in.\r\n\r\nI see now that the situation is more controversial than I though so I'm going to leave this open for a few days, to wait for some more comments, and then, depending on the response, write a RFC first.\r\n\r\nMaybe the best solution would be to have three separate lints, one for checking extern blocks (the current `improper_ctypes`, one for checking all functions with a non-rust calling convention and one for all types with `#[repr(C)]`.\r\n\r\n\r\n\r\n"}}