{"action":"created","comment":{"url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/comments/62304772","id":62304772,"diff_hunk":"@@ -9,11 +9,151 @@\n #![allow(indexing_slicing, shadow_reuse, unknown_lints)]\n #![allow(float_arithmetic, integer_arithmetic)]\n \n-// this only exists to allow the \"dogfood\" integration test to work\n-#[allow(dead_code)]\n-#[allow(print_stdout)]\n-fn main() {\n-    println!(\"What are you doing? Don't run clippy as an executable\");\n+extern crate rustc_driver;\n+extern crate getopts;\n+\n+use rustc_driver::{driver, CompilerCalls, RustcDefaultCalls, Compilation};\n+use rustc::session::{config, Session};\n+use rustc::session::config::{Input, ErrorOutputType};\n+use syntax::diagnostics;\n+use std::path::PathBuf;\n+\n+struct ClippyCompilerCalls(RustcDefaultCalls);\n+\n+impl std::default::Default for ClippyCompilerCalls {\n+    fn default() -> Self {\n+        Self::new()\n+    }\n+}\n+\n+impl ClippyCompilerCalls {\n+    fn new() -> Self {\n+        ClippyCompilerCalls(RustcDefaultCalls)\n+    }\n+}\n+\n+impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {\n+    fn early_callback(&mut self,\n+                      matches: &getopts::Matches,\n+                      sopts: &config::Options,\n+                      descriptions: &diagnostics::registry::Registry,\n+                      output: ErrorOutputType)\n+                      -> Compilation {\n+        self.0.early_callback(matches, sopts, descriptions, output)\n+    }\n+    fn no_input(&mut self,\n+                matches: &getopts::Matches,\n+                sopts: &config::Options,\n+                odir: &Option<PathBuf>,\n+                ofile: &Option<PathBuf>,\n+                descriptions: &diagnostics::registry::Registry)\n+                -> Option<(Input, Option<PathBuf>)> {\n+        self.0.no_input(matches, sopts, odir, ofile, descriptions)\n+    }\n+    fn late_callback(&mut self,\n+                     matches: &getopts::Matches,\n+                     sess: &Session,\n+                     input: &Input,\n+                     odir: &Option<PathBuf>,\n+                     ofile: &Option<PathBuf>)\n+                     -> Compilation {\n+        self.0.late_callback(matches, sess, input, odir, ofile)\n+    }\n+    fn build_controller(&mut self, sess: &Session) -> driver::CompileController<'a> {\n+        let mut control = self.0.build_controller(sess);\n+\n+        let old = std::mem::replace(&mut control.after_parse.callback, box |_| {});\n+        control.after_parse.callback = Box::new(move |state| {\n+            {\n+                let mut registry = rustc_plugin::registry::Registry::new(state.session, state.krate.expect(\"at this compilation stage the krate must be parsed\"));\n+                registry.args_hidden = Some(Vec::new());\n+                plugin_registrar(&mut registry);\n+\n+                let rustc_plugin::registry::Registry { early_lint_passes, late_lint_passes, lint_groups, llvm_passes, attributes, mir_passes, .. } = registry;\n+                let sess = &state.session;\n+                let mut ls = sess.lint_store.borrow_mut();\n+                for pass in early_lint_passes {\n+                    ls.register_early_pass(Some(sess), true, pass);\n+                }\n+                for pass in late_lint_passes {\n+                    ls.register_late_pass(Some(sess), true, pass);\n+                }\n+\n+                for (name, to) in lint_groups {\n+                    ls.register_group(Some(sess), true, name, to);\n+                }\n+\n+                sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes);\n+                sess.mir_passes.borrow_mut().extend(mir_passes);\n+                sess.plugin_attributes.borrow_mut().extend(attributes);\n+            }\n+            old(state);\n+        });\n+\n+        control\n+    }\n+}\n+\n+use std::path::Path;\n+\n+pub fn main() {\n+    use std::env;\n+\n+    if env::var(\"DOGFOOD\").map(|_| true).unwrap_or(false) {\n+        return;\n+    }\n+\n+    let dep_path = env::current_dir().expect(\"current dir is not readable\").join(\"target\").join(\"debug\").join(\"deps\");\n+    let sys_root = match (option_env!(\"MULTIRUST_HOME\"), option_env!(\"MULTIRUST_TOOLCHAIN\")) {\n+        (Some(home), Some(toolchain)) => format!(\"{}/toolchains/{}\", home, toolchain),\n+        _ => option_env!(\"SYSROOT\").expect(\"need to specify SYSROOT env var during clippy compilation\").to_owned(),\n+    };\n+\n+    if env::var(\"AUTOBOTS\").map(|s| s == \"ROLLOUT\").unwrap_or(false) {\n+        let args: Vec<String> = if env::args().any(|s| s == \"--sysroot\") {\n+            env::args().collect()\n+        } else {\n+            env::args().chain(Some(\"--sysroot\".to_owned())).chain(Some(sys_root)).collect()\n+        };\n+        rustc_driver::run_compiler(&args, &mut ClippyCompilerCalls::new());\n+    } else {\n+        let args = wrap_args(env::args(), dep_path, sys_root);\n+        let path = std::env::current_exe().expect(\"current executable path invalid\");\n+        let run = std::process::Command::new(\"cargo\")\n+            .args(&args)\n+            .env(\"RUSTC\", path)\n+            .env(\"AUTOBOTS\", \"ROLLOUT\")\n+            .spawn().expect(\"could not run cargo\")\n+            .wait().expect(\"failed to wait for cargo?\")\n+            .success();\n+        assert!(run, \"cargo rustc failed\");\n+    }\n+}\n+\n+fn wrap_args<T, I, P>(it: I, dep_path: P, sysroot: String) -> Vec<String>\n+    where T: AsRef<str>,\n+          I: IntoIterator<Item=T>,\n+          P: AsRef<Path> {\n+\n+    let old_args = it.into_iter();\n+    let mut args = vec![\"rustc\".to_owned()];\n+\n+    let mut found_dashes = false;\n+    for arg in old_args.skip(2) {\n+        let arg = arg.as_ref().to_owned();\n+        found_dashes |= arg == \"--\";\n+        args.push(arg);\n+    }\n+    if !found_dashes {\n+        args.push(\"--\".to_owned());\n+    }\n+    args.push(\"-L\".to_owned());\n+    args.push(dep_path.as_ref().to_string_lossy().into_owned());\n+    args.push(String::from(\"--sysroot\"));\n+    args.push(sysroot);\n+    args.push(\"-Zno-trans\".to_owned());\n+    args.push(\"-Dclippy\".to_owned());\n+    args\n }","path":"src/lib.rs","position":154,"original_position":154,"commit_id":"0007d121c9adbe0c33a0ec38ea3e58c3c2b9512a","original_commit_id":"0007d121c9adbe0c33a0ec38ea3e58c3c2b9512a","user":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars.githubusercontent.com/u/1617736?v=3","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":"cargo install installs the binary which is different from the lib anyway?","created_at":"2016-05-06T09:03:28Z","updated_at":"2016-05-06T09:03:28Z","html_url":"https://github.com/Manishearth/rust-clippy/pull/681#discussion_r62304772","pull_request_url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681","_links":{"self":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/comments/62304772"},"html":{"href":"https://github.com/Manishearth/rust-clippy/pull/681#discussion_r62304772"},"pull_request":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681"}}},"pull_request":{"url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681","id":59672956,"html_url":"https://github.com/Manishearth/rust-clippy/pull/681","diff_url":"https://github.com/Manishearth/rust-clippy/pull/681.diff","patch_url":"https://github.com/Manishearth/rust-clippy/pull/681.patch","issue_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/681","number":681,"state":"open","locked":false,"title":"cargo clippy","user":{"login":"oli-obk","id":332036,"avatar_url":"https://avatars.githubusercontent.com/u/332036?v=3","gravatar_id":"","url":"https://api.github.com/users/oli-obk","html_url":"https://github.com/oli-obk","followers_url":"https://api.github.com/users/oli-obk/followers","following_url":"https://api.github.com/users/oli-obk/following{/other_user}","gists_url":"https://api.github.com/users/oli-obk/gists{/gist_id}","starred_url":"https://api.github.com/users/oli-obk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oli-obk/subscriptions","organizations_url":"https://api.github.com/users/oli-obk/orgs","repos_url":"https://api.github.com/users/oli-obk/repos","events_url":"https://api.github.com/users/oli-obk/events{/privacy}","received_events_url":"https://api.github.com/users/oli-obk/received_events","type":"User","site_admin":false},"body":"cc https://github.com/arcnmx/cargo-clippy/pull/16\r\n\r\n@arcnmx are you ok with moving this here?","created_at":"2016-02-17T16:49:06Z","updated_at":"2016-05-06T09:03:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9618f7a39bcf2d2e2b8e8aefae909b474a03bacd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681/commits","review_comments_url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681/comments","review_comment_url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/681/comments","statuses_url":"https://api.github.com/repos/Manishearth/rust-clippy/statuses/0007d121c9adbe0c33a0ec38ea3e58c3c2b9512a","head":{"label":"oli-obk:split","ref":"split","sha":"0007d121c9adbe0c33a0ec38ea3e58c3c2b9512a","user":{"login":"oli-obk","id":332036,"avatar_url":"https://avatars.githubusercontent.com/u/332036?v=3","gravatar_id":"","url":"https://api.github.com/users/oli-obk","html_url":"https://github.com/oli-obk","followers_url":"https://api.github.com/users/oli-obk/followers","following_url":"https://api.github.com/users/oli-obk/following{/other_user}","gists_url":"https://api.github.com/users/oli-obk/gists{/gist_id}","starred_url":"https://api.github.com/users/oli-obk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oli-obk/subscriptions","organizations_url":"https://api.github.com/users/oli-obk/orgs","repos_url":"https://api.github.com/users/oli-obk/repos","events_url":"https://api.github.com/users/oli-obk/events{/privacy}","received_events_url":"https://api.github.com/users/oli-obk/received_events","type":"User","site_admin":false},"repo":{"id":40174083,"name":"rust-clippy","full_name":"oli-obk/rust-clippy","owner":{"login":"oli-obk","id":332036,"avatar_url":"https://avatars.githubusercontent.com/u/332036?v=3","gravatar_id":"","url":"https://api.github.com/users/oli-obk","html_url":"https://github.com/oli-obk","followers_url":"https://api.github.com/users/oli-obk/followers","following_url":"https://api.github.com/users/oli-obk/following{/other_user}","gists_url":"https://api.github.com/users/oli-obk/gists{/gist_id}","starred_url":"https://api.github.com/users/oli-obk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oli-obk/subscriptions","organizations_url":"https://api.github.com/users/oli-obk/orgs","repos_url":"https://api.github.com/users/oli-obk/repos","events_url":"https://api.github.com/users/oli-obk/events{/privacy}","received_events_url":"https://api.github.com/users/oli-obk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oli-obk/rust-clippy","description":"A bunch of lints to help avoid newbie pitfalls.","fork":true,"url":"https://api.github.com/repos/oli-obk/rust-clippy","forks_url":"https://api.github.com/repos/oli-obk/rust-clippy/forks","keys_url":"https://api.github.com/repos/oli-obk/rust-clippy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oli-obk/rust-clippy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oli-obk/rust-clippy/teams","hooks_url":"https://api.github.com/repos/oli-obk/rust-clippy/hooks","issue_events_url":"https://api.github.com/repos/oli-obk/rust-clippy/issues/events{/number}","events_url":"https://api.github.com/repos/oli-obk/rust-clippy/events","assignees_url":"https://api.github.com/repos/oli-obk/rust-clippy/assignees{/user}","branches_url":"https://api.github.com/repos/oli-obk/rust-clippy/branches{/branch}","tags_url":"https://api.github.com/repos/oli-obk/rust-clippy/tags","blobs_url":"https://api.github.com/repos/oli-obk/rust-clippy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oli-obk/rust-clippy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oli-obk/rust-clippy/git/refs{/sha}","trees_url":"https://api.github.com/repos/oli-obk/rust-clippy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oli-obk/rust-clippy/statuses/{sha}","languages_url":"https://api.github.com/repos/oli-obk/rust-clippy/languages","stargazers_url":"https://api.github.com/repos/oli-obk/rust-clippy/stargazers","contributors_url":"https://api.github.com/repos/oli-obk/rust-clippy/contributors","subscribers_url":"https://api.github.com/repos/oli-obk/rust-clippy/subscribers","subscription_url":"https://api.github.com/repos/oli-obk/rust-clippy/subscription","commits_url":"https://api.github.com/repos/oli-obk/rust-clippy/commits{/sha}","git_commits_url":"https://api.github.com/repos/oli-obk/rust-clippy/git/commits{/sha}","comments_url":"https://api.github.com/repos/oli-obk/rust-clippy/comments{/number}","issue_comment_url":"https://api.github.com/repos/oli-obk/rust-clippy/issues/comments{/number}","contents_url":"https://api.github.com/repos/oli-obk/rust-clippy/contents/{+path}","compare_url":"https://api.github.com/repos/oli-obk/rust-clippy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oli-obk/rust-clippy/merges","archive_url":"https://api.github.com/repos/oli-obk/rust-clippy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oli-obk/rust-clippy/downloads","issues_url":"https://api.github.com/repos/oli-obk/rust-clippy/issues{/number}","pulls_url":"https://api.github.com/repos/oli-obk/rust-clippy/pulls{/number}","milestones_url":"https://api.github.com/repos/oli-obk/rust-clippy/milestones{/number}","notifications_url":"https://api.github.com/repos/oli-obk/rust-clippy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oli-obk/rust-clippy/labels{/name}","releases_url":"https://api.github.com/repos/oli-obk/rust-clippy/releases{/id}","deployments_url":"https://api.github.com/repos/oli-obk/rust-clippy/deployments","created_at":"2015-08-04T08:59:03Z","updated_at":"2016-01-24T11:25:10Z","pushed_at":"2016-05-04T16:02:46Z","git_url":"git://github.com/oli-obk/rust-clippy.git","ssh_url":"git@github.com:oli-obk/rust-clippy.git","clone_url":"https://github.com/oli-obk/rust-clippy.git","svn_url":"https://github.com/oli-obk/rust-clippy","homepage":"","size":2097,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"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":"Manishearth:master","ref":"master","sha":"397b940225d71a90b77438e56d6b1ccc6a29e890","user":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars.githubusercontent.com/u/1617736?v=3","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},"repo":{"id":26850443,"name":"rust-clippy","full_name":"Manishearth/rust-clippy","owner":{"login":"Manishearth","id":1617736,"avatar_url":"https://avatars.githubusercontent.com/u/1617736?v=3","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},"private":false,"html_url":"https://github.com/Manishearth/rust-clippy","description":"A bunch of lints to catch common mistakes and improve your Rust code","fork":false,"url":"https://api.github.com/repos/Manishearth/rust-clippy","forks_url":"https://api.github.com/repos/Manishearth/rust-clippy/forks","keys_url":"https://api.github.com/repos/Manishearth/rust-clippy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Manishearth/rust-clippy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Manishearth/rust-clippy/teams","hooks_url":"https://api.github.com/repos/Manishearth/rust-clippy/hooks","issue_events_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/events{/number}","events_url":"https://api.github.com/repos/Manishearth/rust-clippy/events","assignees_url":"https://api.github.com/repos/Manishearth/rust-clippy/assignees{/user}","branches_url":"https://api.github.com/repos/Manishearth/rust-clippy/branches{/branch}","tags_url":"https://api.github.com/repos/Manishearth/rust-clippy/tags","blobs_url":"https://api.github.com/repos/Manishearth/rust-clippy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Manishearth/rust-clippy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Manishearth/rust-clippy/git/refs{/sha}","trees_url":"https://api.github.com/repos/Manishearth/rust-clippy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Manishearth/rust-clippy/statuses/{sha}","languages_url":"https://api.github.com/repos/Manishearth/rust-clippy/languages","stargazers_url":"https://api.github.com/repos/Manishearth/rust-clippy/stargazers","contributors_url":"https://api.github.com/repos/Manishearth/rust-clippy/contributors","subscribers_url":"https://api.github.com/repos/Manishearth/rust-clippy/subscribers","subscription_url":"https://api.github.com/repos/Manishearth/rust-clippy/subscription","commits_url":"https://api.github.com/repos/Manishearth/rust-clippy/commits{/sha}","git_commits_url":"https://api.github.com/repos/Manishearth/rust-clippy/git/commits{/sha}","comments_url":"https://api.github.com/repos/Manishearth/rust-clippy/comments{/number}","issue_comment_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/comments{/number}","contents_url":"https://api.github.com/repos/Manishearth/rust-clippy/contents/{+path}","compare_url":"https://api.github.com/repos/Manishearth/rust-clippy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Manishearth/rust-clippy/merges","archive_url":"https://api.github.com/repos/Manishearth/rust-clippy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Manishearth/rust-clippy/downloads","issues_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues{/number}","pulls_url":"https://api.github.com/repos/Manishearth/rust-clippy/pulls{/number}","milestones_url":"https://api.github.com/repos/Manishearth/rust-clippy/milestones{/number}","notifications_url":"https://api.github.com/repos/Manishearth/rust-clippy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Manishearth/rust-clippy/labels{/name}","releases_url":"https://api.github.com/repos/Manishearth/rust-clippy/releases{/id}","deployments_url":"https://api.github.com/repos/Manishearth/rust-clippy/deployments","created_at":"2014-11-19T07:49:21Z","updated_at":"2016-05-05T21:16:56Z","pushed_at":"2016-05-05T20:45:43Z","git_url":"git://github.com/Manishearth/rust-clippy.git","ssh_url":"git@github.com:Manishearth/rust-clippy.git","clone_url":"https://github.com/Manishearth/rust-clippy.git","svn_url":"https://github.com/Manishearth/rust-clippy","homepage":"","size":2266,"stargazers_count":630,"watchers_count":630,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":71,"mirror_url":null,"open_issues_count":186,"forks":71,"open_issues":186,"watchers":630,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681"},"html":{"href":"https://github.com/Manishearth/rust-clippy/pull/681"},"issue":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/issues/681"},"comments":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/issues/681/comments"},"review_comments":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681/comments"},"review_comment":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/pulls/681/commits"},"statuses":{"href":"https://api.github.com/repos/Manishearth/rust-clippy/statuses/0007d121c9adbe0c33a0ec38ea3e58c3c2b9512a"}}}}