{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/comments/132983550","pull_request_review_id":56115257,"id":132983550,"diff_hunk":"@@ -531,6 +553,17 @@ fn span_precision_loss_lint(cx: &LateContext, expr: &Expr, cast_from: Ty, cast_t\n     );\n }\n \n+fn span_lossless_lint(cx: &LateContext, expr: &Expr, op: &Expr, cast_from: Ty, cast_to: Ty) {\n+    span_lint_and_sugg(cx,\n+                       CAST_LOSSLESS,\n+                       expr.span,\n+                       &format!(\"casting {} to {} may become silently lossy if types change\",","path":"clippy_lints/src/types.rs","position":37,"original_position":37,"commit_id":"0a3435d22e74e66fb906c79a54514b980cdc3efd","original_commit_id":"0a3435d22e74e66fb906c79a54514b980cdc3efd","user":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars2.githubusercontent.com/u/1617736?v=4","gravatar_id":"","url":"https://api.github.com/users/Manishearth","html_url":"https://github.com/Manishearth","followers_url":"https://api.github.com/users/Manishearth/followers","following_url":"https://api.github.com/users/Manishearth/following{/other_user}","gists_url":"https://api.github.com/users/Manishearth/gists{/gist_id}","starred_url":"https://api.github.com/users/Manishearth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Manishearth/subscriptions","organizations_url":"https://api.github.com/users/Manishearth/orgs","repos_url":"https://api.github.com/users/Manishearth/repos","events_url":"https://api.github.com/users/Manishearth/events{/privacy}","received_events_url":"https://api.github.com/users/Manishearth/received_events","type":"User","site_admin":false},"body":"Perhaps we should add a `note: from() functions can only be lossless, but as conversions are lossy`","created_at":"2017-08-14T15:35:42Z","updated_at":"2017-08-14T15:35:42Z","html_url":"https://github.com/rust-lang-nursery/rust-clippy/pull/1956#discussion_r132983550","pull_request_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956","_links":{"self":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/comments/132983550"},"html":{"href":"https://github.com/rust-lang-nursery/rust-clippy/pull/1956#discussion_r132983550"},"pull_request":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956","id":135511372,"html_url":"https://github.com/rust-lang-nursery/rust-clippy/pull/1956","diff_url":"https://github.com/rust-lang-nursery/rust-clippy/pull/1956.diff","patch_url":"https://github.com/rust-lang-nursery/rust-clippy/pull/1956.patch","issue_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues/1956","number":1956,"state":"open","locked":false,"title":"Add a lint for lossless casts.","user":{"login":"sunfishcode","id":4503403,"avatar_url":"https://avatars1.githubusercontent.com/u/4503403?v=4","gravatar_id":"","url":"https://api.github.com/users/sunfishcode","html_url":"https://github.com/sunfishcode","followers_url":"https://api.github.com/users/sunfishcode/followers","following_url":"https://api.github.com/users/sunfishcode/following{/other_user}","gists_url":"https://api.github.com/users/sunfishcode/gists{/gist_id}","starred_url":"https://api.github.com/users/sunfishcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunfishcode/subscriptions","organizations_url":"https://api.github.com/users/sunfishcode/orgs","repos_url":"https://api.github.com/users/sunfishcode/repos","events_url":"https://api.github.com/users/sunfishcode/events{/privacy}","received_events_url":"https://api.github.com/users/sunfishcode/received_events","type":"User","site_admin":false},"body":"This patch adds a lint for numeric casts that are always lossless. Such casts can be replaced by safe conversion functions.\r\n\r\nRust's ~~`at`~~`as` keyword will perform many kinds of conversions, including silently lossy conversions. Conversion functions such as `i32::from` will only perform lossless conversions. Using the conversion functions prevents conversions from turning into silent lossy conversions if the types of the input expressions ever change, and make it easier for people reading the code to know that the conversion is lossless.\r\n\r\nI'm new to Rust, and would also be interested in other approaches.","created_at":"2017-08-13T22:55:34Z","updated_at":"2017-08-14T15:35:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8696e0214630881d332d4a1e65259bd1d2e47e06","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956/commits","review_comments_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956/comments","review_comment_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues/1956/comments","statuses_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/statuses/0a3435d22e74e66fb906c79a54514b980cdc3efd","head":{"label":"sunfishcode:master","ref":"master","sha":"0a3435d22e74e66fb906c79a54514b980cdc3efd","user":{"login":"sunfishcode","id":4503403,"avatar_url":"https://avatars1.githubusercontent.com/u/4503403?v=4","gravatar_id":"","url":"https://api.github.com/users/sunfishcode","html_url":"https://github.com/sunfishcode","followers_url":"https://api.github.com/users/sunfishcode/followers","following_url":"https://api.github.com/users/sunfishcode/following{/other_user}","gists_url":"https://api.github.com/users/sunfishcode/gists{/gist_id}","starred_url":"https://api.github.com/users/sunfishcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunfishcode/subscriptions","organizations_url":"https://api.github.com/users/sunfishcode/orgs","repos_url":"https://api.github.com/users/sunfishcode/repos","events_url":"https://api.github.com/users/sunfishcode/events{/privacy}","received_events_url":"https://api.github.com/users/sunfishcode/received_events","type":"User","site_admin":false},"repo":{"id":100206655,"name":"rust-clippy","full_name":"sunfishcode/rust-clippy","owner":{"login":"sunfishcode","id":4503403,"avatar_url":"https://avatars1.githubusercontent.com/u/4503403?v=4","gravatar_id":"","url":"https://api.github.com/users/sunfishcode","html_url":"https://github.com/sunfishcode","followers_url":"https://api.github.com/users/sunfishcode/followers","following_url":"https://api.github.com/users/sunfishcode/following{/other_user}","gists_url":"https://api.github.com/users/sunfishcode/gists{/gist_id}","starred_url":"https://api.github.com/users/sunfishcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunfishcode/subscriptions","organizations_url":"https://api.github.com/users/sunfishcode/orgs","repos_url":"https://api.github.com/users/sunfishcode/repos","events_url":"https://api.github.com/users/sunfishcode/events{/privacy}","received_events_url":"https://api.github.com/users/sunfishcode/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sunfishcode/rust-clippy","description":"A bunch of lints to catch common mistakes and improve your Rust code","fork":true,"url":"https://api.github.com/repos/sunfishcode/rust-clippy","forks_url":"https://api.github.com/repos/sunfishcode/rust-clippy/forks","keys_url":"https://api.github.com/repos/sunfishcode/rust-clippy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sunfishcode/rust-clippy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sunfishcode/rust-clippy/teams","hooks_url":"https://api.github.com/repos/sunfishcode/rust-clippy/hooks","issue_events_url":"https://api.github.com/repos/sunfishcode/rust-clippy/issues/events{/number}","events_url":"https://api.github.com/repos/sunfishcode/rust-clippy/events","assignees_url":"https://api.github.com/repos/sunfishcode/rust-clippy/assignees{/user}","branches_url":"https://api.github.com/repos/sunfishcode/rust-clippy/branches{/branch}","tags_url":"https://api.github.com/repos/sunfishcode/rust-clippy/tags","blobs_url":"https://api.github.com/repos/sunfishcode/rust-clippy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sunfishcode/rust-clippy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sunfishcode/rust-clippy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sunfishcode/rust-clippy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sunfishcode/rust-clippy/statuses/{sha}","languages_url":"https://api.github.com/repos/sunfishcode/rust-clippy/languages","stargazers_url":"https://api.github.com/repos/sunfishcode/rust-clippy/stargazers","contributors_url":"https://api.github.com/repos/sunfishcode/rust-clippy/contributors","subscribers_url":"https://api.github.com/repos/sunfishcode/rust-clippy/subscribers","subscription_url":"https://api.github.com/repos/sunfishcode/rust-clippy/subscription","commits_url":"https://api.github.com/repos/sunfishcode/rust-clippy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sunfishcode/rust-clippy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sunfishcode/rust-clippy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sunfishcode/rust-clippy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sunfishcode/rust-clippy/contents/{+path}","compare_url":"https://api.github.com/repos/sunfishcode/rust-clippy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sunfishcode/rust-clippy/merges","archive_url":"https://api.github.com/repos/sunfishcode/rust-clippy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sunfishcode/rust-clippy/downloads","issues_url":"https://api.github.com/repos/sunfishcode/rust-clippy/issues{/number}","pulls_url":"https://api.github.com/repos/sunfishcode/rust-clippy/pulls{/number}","milestones_url":"https://api.github.com/repos/sunfishcode/rust-clippy/milestones{/number}","notifications_url":"https://api.github.com/repos/sunfishcode/rust-clippy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sunfishcode/rust-clippy/labels{/name}","releases_url":"https://api.github.com/repos/sunfishcode/rust-clippy/releases{/id}","deployments_url":"https://api.github.com/repos/sunfishcode/rust-clippy/deployments","created_at":"2017-08-13T21:49:58Z","updated_at":"2017-08-13T21:50:01Z","pushed_at":"2017-08-14T13:42:45Z","git_url":"git://github.com/sunfishcode/rust-clippy.git","ssh_url":"git@github.com:sunfishcode/rust-clippy.git","clone_url":"https://github.com/sunfishcode/rust-clippy.git","svn_url":"https://github.com/sunfishcode/rust-clippy","homepage":"","size":5634,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang-nursery:master","ref":"master","sha":"d6fc34fd080bccc81e16b82ab01da3e1bc7e5820","user":{"login":"rust-lang-nursery","id":14631425,"avatar_url":"https://avatars1.githubusercontent.com/u/14631425?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang-nursery","html_url":"https://github.com/rust-lang-nursery","followers_url":"https://api.github.com/users/rust-lang-nursery/followers","following_url":"https://api.github.com/users/rust-lang-nursery/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang-nursery/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang-nursery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang-nursery/subscriptions","organizations_url":"https://api.github.com/users/rust-lang-nursery/orgs","repos_url":"https://api.github.com/users/rust-lang-nursery/repos","events_url":"https://api.github.com/users/rust-lang-nursery/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang-nursery/received_events","type":"Organization","site_admin":false},"repo":{"id":26850443,"name":"rust-clippy","full_name":"rust-lang-nursery/rust-clippy","owner":{"login":"rust-lang-nursery","id":14631425,"avatar_url":"https://avatars1.githubusercontent.com/u/14631425?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang-nursery","html_url":"https://github.com/rust-lang-nursery","followers_url":"https://api.github.com/users/rust-lang-nursery/followers","following_url":"https://api.github.com/users/rust-lang-nursery/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang-nursery/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang-nursery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang-nursery/subscriptions","organizations_url":"https://api.github.com/users/rust-lang-nursery/orgs","repos_url":"https://api.github.com/users/rust-lang-nursery/repos","events_url":"https://api.github.com/users/rust-lang-nursery/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang-nursery/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang-nursery/rust-clippy","description":"A bunch of lints to catch common mistakes and improve your Rust code","fork":false,"url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy","forks_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/forks","keys_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/teams","hooks_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/hooks","issue_events_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/events","assignees_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/tags","blobs_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/languages","stargazers_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/stargazers","contributors_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/contributors","subscribers_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/subscribers","subscription_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/subscription","commits_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/merges","archive_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/downloads","issues_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/deployments","created_at":"2014-11-19T07:49:21Z","updated_at":"2017-08-14T13:19:00Z","pushed_at":"2017-08-14T15:12:06Z","git_url":"git://github.com/rust-lang-nursery/rust-clippy.git","ssh_url":"git@github.com:rust-lang-nursery/rust-clippy.git","clone_url":"https://github.com/rust-lang-nursery/rust-clippy.git","svn_url":"https://github.com/rust-lang-nursery/rust-clippy","homepage":"","size":5635,"stargazers_count":1501,"watchers_count":1501,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":173,"mirror_url":null,"open_issues_count":529,"forks":173,"open_issues":529,"watchers":1501,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956"},"html":{"href":"https://github.com/rust-lang-nursery/rust-clippy/pull/1956"},"issue":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues/1956"},"comments":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/issues/1956/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/pulls/1956/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang-nursery/rust-clippy/statuses/0a3435d22e74e66fb906c79a54514b980cdc3efd"}}}}
{"actor":{"display_login":"Manishearth"}}