Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#53840: Consolidate pattern check errors #54269

Merged
merged 1 commit into from
Oct 3, 2018

Conversation

PramodBisht
Copy link
Contributor

@PramodBisht PramodBisht commented Sep 16, 2018

#53840 on this PR we are aggregating cannot bind by-move and by-ref in the same pattern message present on the different lines into one diagnostic message. Here we are first gathering those spans on vector then we are throwing them with the help of MultiSpan
r? @estebank

Addresses: #53480

@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2018
@PramodBisht
Copy link
Contributor Author

r? @estebank

@PramodBisht PramodBisht changed the title solved #53840 #53840: Consolidate pattern check errors Sep 16, 2018
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, no need to change: I prefer to include a description in git commits that can be understood without having to check the issue tracker, something along the lines of the PR description you used is good. Then in the description of the commit or at least the PR add a mention of the issue being fixed.

Other than me not knowing why a new block is being added, pretty cool change.

Please add to the test a case using pattern destructuring with a struct variant (Bar { a, b, ref c}).

r=me after addressing comments.

@@ -527,53 +527,61 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
}
})
}
let span_vec = &mut Vec::new();
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I get why you need a new scope here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above point regarding commit, I will ensure I follow that in future :) Agreed, its best practice to mention everything in the commit, so, if someone backtracks and checks those commit should get the idea of what is being done without going to issue tracker :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@estebank now instead of creating a new scope, I am passing span_vec to check_move closure, this is a much clearer approach. Thanks for your feedback :)

@estebank estebank added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2018
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you've extended test to include a struct variant too, r=me.

span,
E0009,
"cannot bind by-move and by-ref in the same pattern",
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the appropriate indentation for this macro call is:

        let mut err = struct_span_err!(
            cx.tcx.sess,
            span,
            E0009,
            "cannot bind by-move and by-ref in the same pattern",
        );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@bors

This comment has been minimized.

@TimNN
Copy link
Contributor

TimNN commented Sep 25, 2018

Ping from triage @PramodBisht: It looks like some changes have been requested to your PR and it also needs to be rebased.

we are consolidating `cannot bind by-move and by-ref in the same
pattern` message present on the different lines into single diagnostic
message.

To do this, we are first gathering those spans into the vector
after that we are throwing them with the help of MultiSpan in
a separate block.

Addresses: rust-lang#53840
@PramodBisht
Copy link
Contributor Author

r? @estebank again

@estebank
Copy link
Contributor

estebank commented Oct 2, 2018

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 2, 2018

📌 Commit e536e64 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 2, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 2, 2018
rust-lang#53840: Consolidate pattern check errors

rust-lang#53840  on this PR we are aggregating `cannot bind by-move and by-ref in the same pattern` message present on the different lines into one diagnostic message. Here we are first gathering those `spans` on `vector` then we are throwing them with the help of `MultiSpan`
r? @estebank

Addresses: rust-lang#53480
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 2, 2018
rust-lang#53840: Consolidate pattern check errors

rust-lang#53840  on this PR we are aggregating `cannot bind by-move and by-ref in the same pattern` message present on the different lines into one diagnostic message. Here we are first gathering those `spans` on `vector` then we are throwing them with the help of `MultiSpan`
r? @estebank

Addresses: rust-lang#53480
bors added a commit that referenced this pull request Oct 2, 2018
Rollup of 10 pull requests

Successful merges:

 - #54269 (#53840: Consolidate pattern check errors)
 - #54458 (Allow both explicit and elided lifetimes in the same impl header)
 - #54603 (Add `crate::` to trait suggestions in Rust 2018.)
 - #54648 (Update Cargo's submodule)
 - #54680 (make run-pass tests with empty main just compile-pass tests)
 - #54687 (Use impl_header_lifetime_elision in libcore)
 - #54699 (Re-export `getopts` so custom drivers can reference it.)
 - #54702 (do not promote comparing function pointers)
 - #54728 (Renumber `proc_macro` tracking issues)
 - #54745 (make `CStr::from_bytes_with_nul_unchecked()` a const fn)

Failed merges:

r? @ghost
@bors bors merged commit e536e64 into rust-lang:master Oct 3, 2018
@PramodBisht PramodBisht deleted the issue/53840 branch October 9, 2018 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants