{"action":"created","comment":{"url":"https://api.github.com/repos/CraneStation/cranelift/pulls/comments/209986661","pull_request_review_id":146107737,"id":209986661,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTk4NjY2MQ==","diff_hunk":"@@ -82,23 +82,86 @@ pub use self::cssa::verify_cssa;\n pub use self::liveness::verify_liveness;\n pub use self::locations::verify_locations;\n \n-// Create an `Err` variant of `VerifierResult<X>` from a location and `format!` arguments.\n-macro_rules! err {\n-    ( $loc:expr, $msg:expr ) => {\n-        Err(::verifier::VerifierError {\n+/// Report an error.\n+///\n+/// The first argument must be a `&mut VerifierErrors` reference, and the following\n+/// argument defines the location of the error and must implement `Into<AnyEntity>`.\n+/// Finally, subsequent arguments will be formatted using `format!()` and set\n+/// as the error message.\n+macro_rules! report {\n+    ( $errors: expr, $loc: expr, $msg: tt ) => {\n+        $errors.0.push(::verifier::VerifierError {\n             location: $loc.into(),\n             message: String::from($msg),\n         })\n     };\n \n-    ( $loc:expr, $fmt:expr, $( $arg:expr ),+ ) => {\n-        Err(::verifier::VerifierError {\n+    ( $errors: expr, $loc: expr, $fmt: tt, $( $arg: expr ),+ ) => {\n+        $errors.0.push(::verifier::VerifierError {\n             location: $loc.into(),\n             message: format!( $fmt, $( $arg ),+ ),\n         })\n     };\n }\n \n+/// Diagnose a fatal error, and return `Err`.\n+macro_rules! fatal {\n+    ( $( $arg: expr ),+ ) => ({\n+        report!( $( $arg ),+ );\n+        Err(())\n+    });\n+}\n+\n+/// Diagnose a non-fatal error, and return `Ok`.\n+macro_rules! nonfatal {\n+    ( $( $arg: expr ),+ ) => ({\n+        report!( $( $arg ),+ );\n+        Ok(())\n+    });\n+}\n+\n+/// Faster syntax for calling `verify_*` functions.\n+///\n+/// # Example\n+/// ```rust,ignore\n+/// // Instead of doing all this manually\n+/// let mut errors = VerifierErrors::default();\n+/// let result = verify_function(func, &mut errors);","path":"lib/codegen/src/verifier/mod.rs","position":54,"original_position":54,"commit_id":"249c39a98f0bcd1a9a0a28bffeb11ad59b8c63c7","original_commit_id":"249c39a98f0bcd1a9a0a28bffeb11ad59b8c63c7","user":{"login":"6A","id":7189784,"node_id":"MDQ6VXNlcjcxODk3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/7189784?v=4","gravatar_id":"","url":"https://api.github.com/users/6A","html_url":"https://github.com/6A","followers_url":"https://api.github.com/users/6A/followers","following_url":"https://api.github.com/users/6A/following{/other_user}","gists_url":"https://api.github.com/users/6A/gists{/gist_id}","starred_url":"https://api.github.com/users/6A/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/6A/subscriptions","organizations_url":"https://api.github.com/users/6A/orgs","repos_url":"https://api.github.com/users/6A/repos","events_url":"https://api.github.com/users/6A/events{/privacy}","received_events_url":"https://api.github.com/users/6A/received_events","type":"User","site_admin":false},"body":"Good catch! I wrote the docs *before* changing the signature of `verify_function` so I went over this too quickly...","created_at":"2018-08-14T15:01:54Z","updated_at":"2018-08-14T15:01:54Z","html_url":"https://github.com/CraneStation/cranelift/pull/452#discussion_r209986661","pull_request_url":"https://api.github.com/repos/CraneStation/cranelift/pulls/452","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/CraneStation/cranelift/pulls/comments/209986661"},"html":{"href":"https://github.com/CraneStation/cranelift/pull/452#discussion_r209986661"},"pull_request":{"href":"https://api.github.com/repos/CraneStation/cranelift/pulls/452"}},"in_reply_to_id":209954601},"pull_request":{"url":"https://api.github.com/repos/CraneStation/cranelift/pulls/452","id":207637765,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NjM3NzY1","html_url":"https://github.com/CraneStation/cranelift/pull/452","diff_url":"https://github.com/CraneStation/cranelift/pull/452.diff","patch_url":"https://github.com/CraneStation/cranelift/pull/452.patch","issue_url":"https://api.github.com/repos/CraneStation/cranelift/issues/452","number":452,"state":"open","locked":false,"title":"Verifier now accepts multiple errors (fixes #387).","user":{"login":"6A","id":7189784,"node_id":"MDQ6VXNlcjcxODk3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/7189784?v=4","gravatar_id":"","url":"https://api.github.com/users/6A","html_url":"https://github.com/6A","followers_url":"https://api.github.com/users/6A/followers","following_url":"https://api.github.com/users/6A/following{/other_user}","gists_url":"https://api.github.com/users/6A/gists{/gist_id}","starred_url":"https://api.github.com/users/6A/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/6A/subscriptions","organizations_url":"https://api.github.com/users/6A/orgs","repos_url":"https://api.github.com/users/6A/repos","events_url":"https://api.github.com/users/6A/events{/privacy}","received_events_url":"https://api.github.com/users/6A/received_events","type":"User","site_admin":false},"body":"Tests all pass successfully, and have been updated accordingly.\r\n\r\nBesides the following change, everything behaves like before, meaning that every single error is reported using `return fatal!(...)`, which is equivalent to the previous `return err!(...)`.\r\n\r\nHowever, from now on we can define errors as non fatal, and keep verifying. For example, instead of reporting the first error we encounter when ensuring a function's parameters are valid, we can report all errors, and stop verifying the function after checking the parameters.\r\n\r\nThe mentioned change is that now, error reporting in `pretty_error` reports **every single** reported error, instead of the first one.\r\n\r\nI'll probably work on making most errors `nonfatal` after this.\r\n\r\n**Edit**: I did not change the version... Maybe I should have?\r\n\r\n**Edit 2**: Here are more details about the changes:\r\n\r\n1. Added `VerifierErrors` type, which is a just a wrapper around a `Vec<VerifierError>`. It can also be converted to `CodegenError` easily.\r\n2. Now, every function that returns a `VerifierResult` also takes a `&mut VerifierErrors` as parameter. Errors can be added via the macros `report!(errors, \"{}\", args)`, `fatal!(errors, \"{}\", args)` (calls `report!` and then returns `Err`), and `nonfatal!(errors, \"{}\", args)` (calls `report!` and returns `Ok`).\r\n3. `VerifierResult<T>` is now defined as `Result<T, ()>`, where `Ok` represents a lack or error or an error that does not stop the verification process, and `Err` represents an error that does stop the verification process (therefore using `?` can shortcurcuit a `verify_foo` function).\r\n4. The macro `ok_if_no_error` returns `Ok(())` if no error was reported in a `VerifierErrors`, and `Err(())` otherwise. Can be useful for methods that do not shortcircuit, but stop the verification process if they fail.\r\n5. The macro `verify!` takes a function (ie `verify_function`, `ctx.verify`), and an arbitrary number of arguments, and will take care of creating the `VerifierErrors`, passing it to the `verify` function along with the other arguments, and will either return `Ok` if no error was reported, or `Err(VerifierErrors)` otherwise.","created_at":"2018-08-10T14:57:06Z","updated_at":"2018-08-14T15:01:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8d5b4bccca508138b0f0bce077898073bc6ad8d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CraneStation/cranelift/pulls/452/commits","review_comments_url":"https://api.github.com/repos/CraneStation/cranelift/pulls/452/comments","review_comment_url":"https://api.github.com/repos/CraneStation/cranelift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CraneStation/cranelift/issues/452/comments","statuses_url":"https://api.github.com/repos/CraneStation/cranelift/statuses/249c39a98f0bcd1a9a0a28bffeb11ad59b8c63c7","head":{"label":"6A:master","ref":"master","sha":"249c39a98f0bcd1a9a0a28bffeb11ad59b8c63c7","user":{"login":"6A","id":7189784,"node_id":"MDQ6VXNlcjcxODk3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/7189784?v=4","gravatar_id":"","url":"https://api.github.com/users/6A","html_url":"https://github.com/6A","followers_url":"https://api.github.com/users/6A/followers","following_url":"https://api.github.com/users/6A/following{/other_user}","gists_url":"https://api.github.com/users/6A/gists{/gist_id}","starred_url":"https://api.github.com/users/6A/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/6A/subscriptions","organizations_url":"https://api.github.com/users/6A/orgs","repos_url":"https://api.github.com/users/6A/repos","events_url":"https://api.github.com/users/6A/events{/privacy}","received_events_url":"https://api.github.com/users/6A/received_events","type":"User","site_admin":false},"repo":{"id":139325381,"node_id":"MDEwOlJlcG9zaXRvcnkxMzkzMjUzODE=","name":"cretonne","full_name":"6A/cretonne","owner":{"login":"6A","id":7189784,"node_id":"MDQ6VXNlcjcxODk3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/7189784?v=4","gravatar_id":"","url":"https://api.github.com/users/6A","html_url":"https://github.com/6A","followers_url":"https://api.github.com/users/6A/followers","following_url":"https://api.github.com/users/6A/following{/other_user}","gists_url":"https://api.github.com/users/6A/gists{/gist_id}","starred_url":"https://api.github.com/users/6A/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/6A/subscriptions","organizations_url":"https://api.github.com/users/6A/orgs","repos_url":"https://api.github.com/users/6A/repos","events_url":"https://api.github.com/users/6A/events{/privacy}","received_events_url":"https://api.github.com/users/6A/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/6A/cretonne","description":"Cretonne code generator","fork":true,"url":"https://api.github.com/repos/6A/cretonne","forks_url":"https://api.github.com/repos/6A/cretonne/forks","keys_url":"https://api.github.com/repos/6A/cretonne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/6A/cretonne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/6A/cretonne/teams","hooks_url":"https://api.github.com/repos/6A/cretonne/hooks","issue_events_url":"https://api.github.com/repos/6A/cretonne/issues/events{/number}","events_url":"https://api.github.com/repos/6A/cretonne/events","assignees_url":"https://api.github.com/repos/6A/cretonne/assignees{/user}","branches_url":"https://api.github.com/repos/6A/cretonne/branches{/branch}","tags_url":"https://api.github.com/repos/6A/cretonne/tags","blobs_url":"https://api.github.com/repos/6A/cretonne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/6A/cretonne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/6A/cretonne/git/refs{/sha}","trees_url":"https://api.github.com/repos/6A/cretonne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/6A/cretonne/statuses/{sha}","languages_url":"https://api.github.com/repos/6A/cretonne/languages","stargazers_url":"https://api.github.com/repos/6A/cretonne/stargazers","contributors_url":"https://api.github.com/repos/6A/cretonne/contributors","subscribers_url":"https://api.github.com/repos/6A/cretonne/subscribers","subscription_url":"https://api.github.com/repos/6A/cretonne/subscription","commits_url":"https://api.github.com/repos/6A/cretonne/commits{/sha}","git_commits_url":"https://api.github.com/repos/6A/cretonne/git/commits{/sha}","comments_url":"https://api.github.com/repos/6A/cretonne/comments{/number}","issue_comment_url":"https://api.github.com/repos/6A/cretonne/issues/comments{/number}","contents_url":"https://api.github.com/repos/6A/cretonne/contents/{+path}","compare_url":"https://api.github.com/repos/6A/cretonne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/6A/cretonne/merges","archive_url":"https://api.github.com/repos/6A/cretonne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/6A/cretonne/downloads","issues_url":"https://api.github.com/repos/6A/cretonne/issues{/number}","pulls_url":"https://api.github.com/repos/6A/cretonne/pulls{/number}","milestones_url":"https://api.github.com/repos/6A/cretonne/milestones{/number}","notifications_url":"https://api.github.com/repos/6A/cretonne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/6A/cretonne/labels{/name}","releases_url":"https://api.github.com/repos/6A/cretonne/releases{/id}","deployments_url":"https://api.github.com/repos/6A/cretonne/deployments","created_at":"2018-07-01T11:58:33Z","updated_at":"2018-08-14T09:21:02Z","pushed_at":"2018-08-14T09:20:59Z","git_url":"git://github.com/6A/cretonne.git","ssh_url":"git@github.com:6A/cretonne.git","clone_url":"https://github.com/6A/cretonne.git","svn_url":"https://github.com/6A/cretonne","homepage":"https://cretonne.readthedocs.io/","size":6012,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CraneStation:master","ref":"master","sha":"12f6ab0f93eaa74fbe6e81f51d79c2c35cab0297","user":{"login":"CraneStation","id":11573910,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTczOTEw","avatar_url":"https://avatars3.githubusercontent.com/u/11573910?v=4","gravatar_id":"","url":"https://api.github.com/users/CraneStation","html_url":"https://github.com/CraneStation","followers_url":"https://api.github.com/users/CraneStation/followers","following_url":"https://api.github.com/users/CraneStation/following{/other_user}","gists_url":"https://api.github.com/users/CraneStation/gists{/gist_id}","starred_url":"https://api.github.com/users/CraneStation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CraneStation/subscriptions","organizations_url":"https://api.github.com/users/CraneStation/orgs","repos_url":"https://api.github.com/users/CraneStation/repos","events_url":"https://api.github.com/users/CraneStation/events{/privacy}","received_events_url":"https://api.github.com/users/CraneStation/received_events","type":"Organization","site_admin":false},"repo":{"id":50268165,"node_id":"MDEwOlJlcG9zaXRvcnk1MDI2ODE2NQ==","name":"cranelift","full_name":"CraneStation/cranelift","owner":{"login":"CraneStation","id":11573910,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTczOTEw","avatar_url":"https://avatars3.githubusercontent.com/u/11573910?v=4","gravatar_id":"","url":"https://api.github.com/users/CraneStation","html_url":"https://github.com/CraneStation","followers_url":"https://api.github.com/users/CraneStation/followers","following_url":"https://api.github.com/users/CraneStation/following{/other_user}","gists_url":"https://api.github.com/users/CraneStation/gists{/gist_id}","starred_url":"https://api.github.com/users/CraneStation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CraneStation/subscriptions","organizations_url":"https://api.github.com/users/CraneStation/orgs","repos_url":"https://api.github.com/users/CraneStation/repos","events_url":"https://api.github.com/users/CraneStation/events{/privacy}","received_events_url":"https://api.github.com/users/CraneStation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CraneStation/cranelift","description":"Cranelift code generator (formerly, Cretonne)","fork":false,"url":"https://api.github.com/repos/CraneStation/cranelift","forks_url":"https://api.github.com/repos/CraneStation/cranelift/forks","keys_url":"https://api.github.com/repos/CraneStation/cranelift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CraneStation/cranelift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CraneStation/cranelift/teams","hooks_url":"https://api.github.com/repos/CraneStation/cranelift/hooks","issue_events_url":"https://api.github.com/repos/CraneStation/cranelift/issues/events{/number}","events_url":"https://api.github.com/repos/CraneStation/cranelift/events","assignees_url":"https://api.github.com/repos/CraneStation/cranelift/assignees{/user}","branches_url":"https://api.github.com/repos/CraneStation/cranelift/branches{/branch}","tags_url":"https://api.github.com/repos/CraneStation/cranelift/tags","blobs_url":"https://api.github.com/repos/CraneStation/cranelift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CraneStation/cranelift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CraneStation/cranelift/git/refs{/sha}","trees_url":"https://api.github.com/repos/CraneStation/cranelift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CraneStation/cranelift/statuses/{sha}","languages_url":"https://api.github.com/repos/CraneStation/cranelift/languages","stargazers_url":"https://api.github.com/repos/CraneStation/cranelift/stargazers","contributors_url":"https://api.github.com/repos/CraneStation/cranelift/contributors","subscribers_url":"https://api.github.com/repos/CraneStation/cranelift/subscribers","subscription_url":"https://api.github.com/repos/CraneStation/cranelift/subscription","commits_url":"https://api.github.com/repos/CraneStation/cranelift/commits{/sha}","git_commits_url":"https://api.github.com/repos/CraneStation/cranelift/git/commits{/sha}","comments_url":"https://api.github.com/repos/CraneStation/cranelift/comments{/number}","issue_comment_url":"https://api.github.com/repos/CraneStation/cranelift/issues/comments{/number}","contents_url":"https://api.github.com/repos/CraneStation/cranelift/contents/{+path}","compare_url":"https://api.github.com/repos/CraneStation/cranelift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CraneStation/cranelift/merges","archive_url":"https://api.github.com/repos/CraneStation/cranelift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CraneStation/cranelift/downloads","issues_url":"https://api.github.com/repos/CraneStation/cranelift/issues{/number}","pulls_url":"https://api.github.com/repos/CraneStation/cranelift/pulls{/number}","milestones_url":"https://api.github.com/repos/CraneStation/cranelift/milestones{/number}","notifications_url":"https://api.github.com/repos/CraneStation/cranelift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CraneStation/cranelift/labels{/name}","releases_url":"https://api.github.com/repos/CraneStation/cranelift/releases{/id}","deployments_url":"https://api.github.com/repos/CraneStation/cranelift/deployments","created_at":"2016-01-24T02:04:11Z","updated_at":"2018-08-14T01:31:42Z","pushed_at":"2018-08-14T14:43:46Z","git_url":"git://github.com/CraneStation/cranelift.git","ssh_url":"git@github.com:CraneStation/cranelift.git","clone_url":"https://github.com/CraneStation/cranelift.git","svn_url":"https://github.com/CraneStation/cranelift","homepage":"https://cranelift.readthedocs.io/","size":6061,"stargazers_count":887,"watchers_count":887,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":85,"mirror_url":null,"archived":false,"open_issues_count":66,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":85,"open_issues":66,"watchers":887,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CraneStation/cranelift/pulls/452"},"html":{"href":"https://github.com/CraneStation/cranelift/pull/452"},"issue":{"href":"https://api.github.com/repos/CraneStation/cranelift/issues/452"},"comments":{"href":"https://api.github.com/repos/CraneStation/cranelift/issues/452/comments"},"review_comments":{"href":"https://api.github.com/repos/CraneStation/cranelift/pulls/452/comments"},"review_comment":{"href":"https://api.github.com/repos/CraneStation/cranelift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CraneStation/cranelift/pulls/452/commits"},"statuses":{"href":"https://api.github.com/repos/CraneStation/cranelift/statuses/249c39a98f0bcd1a9a0a28bffeb11ad59b8c63c7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"6A"}}