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

Warn for bindings named same as variants when matching against a borrow #67783

Merged
merged 5 commits into from
Jan 3, 2020

Conversation

LeSeulArtichaut
Copy link
Contributor

Fixes #67776

@rust-highfive
Copy link
Collaborator

r? @cramertj

(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 Jan 1, 2020
@LeSeulArtichaut
Copy link
Contributor Author

r? @csmoe

@rust-highfive rust-highfive assigned csmoe and unassigned cramertj Jan 1, 2020
@Centril
Copy link
Contributor

Centril commented Jan 1, 2020

Please also add a regression test for the diff you've introduced.

r? @Centril

@rust-highfive rust-highfive assigned Centril and unassigned csmoe Jan 1, 2020
@LeSeulArtichaut
Copy link
Contributor Author

Please also add a regression test for the diff you've introduced.

I was going to ask if this was necessairy, thanks for answering

@LeSeulArtichaut
Copy link
Contributor Author

@rustbot modify labels to +S-waiting-on-author -S-waiting-on-review

@rustbot rustbot 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 Jan 1, 2020
@LeSeulArtichaut
Copy link
Contributor Author

@Centril added the test. Please tell me if it is correctly named and placed in the test directories.

@rustbot modify labels to -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 1, 2020
src/test/ui/match/match-same-name-enum-variant.rs Outdated Show resolved Hide resolved
src/test/ui/match/match-same-name-enum-variant.rs Outdated Show resolved Hide resolved
src/test/ui/match/match-same-name-enum-variant.rs Outdated Show resolved Hide resolved
src/test/ui/match/match-same-name-enum-variant.rs Outdated Show resolved Hide resolved
@Centril Centril 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 Jan 2, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-01T23:51:42.8996566Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-01T23:51:42.9213514Z ##[command]git config gc.auto 0
2020-01-01T23:51:42.9680327Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-01T23:51:42.9737376Z ##[command]git config --get-all http.proxy
2020-01-01T23:51:42.9898189Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67783/merge:refs/remotes/pull/67783/merge
---
2020-01-02T00:50:37.6901846Z .................................................................................................... 1500/9468
2020-01-02T00:50:43.4884252Z .................................................................................................... 1600/9468
2020-01-02T00:50:48.2441235Z .................................................................................................... 1700/9468
2020-01-02T00:50:57.4797880Z .................................................................................................... 1800/9468
2020-01-02T00:51:05.5873875Z i................................................................................................... 1900/9468
2020-01-02T00:51:12.2441853Z ......................................................................................iiiii......... 2000/9468
2020-01-02T00:51:33.5824060Z .................................................................................................... 2200/9468
2020-01-02T00:51:35.9908826Z .................................................................................................... 2300/9468
2020-01-02T00:51:38.4208216Z .................................................................................................... 2400/9468
2020-01-02T00:51:44.3676859Z .................................................................................................... 2500/9468
---
2020-01-02T00:54:39.6264184Z .................i...............i.................................................................. 4900/9468
2020-01-02T00:54:49.3518705Z .................................................................................................... 5000/9468
2020-01-02T00:54:54.8400870Z ..............................................................i..................................... 5100/9468
2020-01-02T00:55:02.7549773Z .................................................................................................... 5200/9468
2020-01-02T00:55:10.2506682Z .............................ii.ii...........i...................................................... 5300/9468
2020-01-02T00:55:19.4809688Z .................................................................................................... 5500/9468
2020-01-02T00:55:29.3763114Z .................................................................................................... 5600/9468
2020-01-02T00:55:36.3387408Z ............i....................................................................................... 5700/9468
2020-01-02T00:55:42.4082621Z ........................................................F........................................... 5800/9468
2020-01-02T00:55:42.4082621Z ........................................................F........................................... 5800/9468
2020-01-02T00:55:52.8578426Z .................................................................................................... 5900/9468
2020-01-02T00:56:04.3997544Z .ii...i..ii...........i............................................................................. 6000/9468
2020-01-02T00:56:21.6271915Z .................................................................................................... 6200/9468
2020-01-02T00:56:28.8551753Z .................................................................................................... 6300/9468
2020-01-02T00:56:28.8551753Z .................................................................................................... 6300/9468
2020-01-02T00:56:55.1356682Z ............................i..ii................................................................... 6400/9468
2020-01-02T00:57:13.9451048Z .................................................................................................... 6600/9468
2020-01-02T00:57:16.0705521Z ...i................................................................................................ 6700/9468
2020-01-02T00:57:18.4327117Z .................................................................................................... 6800/9468
2020-01-02T00:57:20.9647376Z ...i................................................................................................ 6900/9468
---
2020-01-02T00:58:56.6369650Z .................................................................................................... 7500/9468
2020-01-02T00:59:01.4406485Z .................................................................................................... 7600/9468
2020-01-02T00:59:06.7357915Z .................................................................................................... 7700/9468
2020-01-02T00:59:17.5360308Z .................................................................................................... 7800/9468
2020-01-02T00:59:25.3707716Z .....................................iiii........................................................... 7900/9468
2020-01-02T00:59:40.7684245Z .................................................................................................... 8100/9468
2020-01-02T00:59:49.9405733Z .................................................................................................... 8200/9468
2020-01-02T01:00:04.7348795Z .................................................................................................... 8300/9468
2020-01-02T01:00:12.9476728Z .................................................................................................... 8400/9468
---
2020-01-02T01:02:09.7140743Z 
2020-01-02T01:02:09.7141485Z ---- [ui] ui/match/match-same-name-enum-variant.rs stdout ----
2020-01-02T01:02:09.7141758Z diff of stderr:
2020-01-02T01:02:09.7141903Z 
2020-01-02T01:02:09.7142080Z 1 warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7142508Z -   --> $DIR/match-same-name-enum-variant.rs:14:9
2020-01-02T01:02:09.7142971Z +   --> $DIR/match-same-name-enum-variant.rs:17:9
2020-01-02T01:02:09.7143313Z 4 LL |         Bar => println!("A"),
2020-01-02T01:02:09.7143313Z 4 LL |         Bar => println!("A"),
2020-01-02T01:02:09.7143482Z 5    |         ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
2020-01-02T01:02:09.7143773Z 6 
2020-01-02T01:02:09.7143773Z 6 
2020-01-02T01:02:09.7143937Z 7 warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7144338Z -   --> $DIR/match-same-name-enum-variant.rs:16:9
2020-01-02T01:02:09.7144768Z +   --> $DIR/match-same-name-enum-variant.rs:19:9
2020-01-02T01:02:09.7144991Z 9    |
2020-01-02T01:02:09.7145137Z 10 LL |         Baz => println!("B"),
2020-01-02T01:02:09.7145289Z 11    |         ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
2020-01-02T01:02:09.7145572Z 12 
2020-01-02T01:02:09.7145572Z 12 
2020-01-02T01:02:09.7145723Z 13 warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7146125Z -   --> $DIR/match-same-name-enum-variant.rs:23:9
2020-01-02T01:02:09.7146535Z +   --> $DIR/match-same-name-enum-variant.rs:26:9
2020-01-02T01:02:09.7146910Z 16 LL |         Bar => println!("A"),
2020-01-02T01:02:09.7146910Z 16 LL |         Bar => println!("A"),
2020-01-02T01:02:09.7147058Z 17    |         ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
2020-01-02T01:02:09.7147341Z 18 
2020-01-02T01:02:09.7147341Z 18 
2020-01-02T01:02:09.7147499Z 19 warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7147906Z -   --> $DIR/match-same-name-enum-variant.rs:25:9
2020-01-02T01:02:09.7148329Z +   --> $DIR/match-same-name-enum-variant.rs:28:9
2020-01-02T01:02:09.7148521Z 21    |
2020-01-02T01:02:09.7148685Z 22 LL |         Baz => println!("B"),
2020-01-02T01:02:09.7148837Z 23    |         ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
2020-01-02T01:02:09.7149083Z 
2020-01-02T01:02:09.7149244Z The actual stderr differed from the expected stderr.
2020-01-02T01:02:09.7149244Z The actual stderr differed from the expected stderr.
2020-01-02T01:02:09.7149722Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-same-name-enum-variant/match-same-name-enum-variant.stderr
2020-01-02T01:02:09.7150541Z To update references, rerun the tests and pass the `--bless` flag
2020-01-02T01:02:09.7151081Z To only update this specific test, also pass `--test-args match/match-same-name-enum-variant.rs`
2020-01-02T01:02:09.7151617Z error: 1 errors occurred comparing output.
2020-01-02T01:02:09.7151833Z status: exit code: 0
2020-01-02T01:02:09.7151833Z status: exit code: 0
2020-01-02T01:02:09.7152982Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/match/match-same-name-enum-variant.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-same-name-enum-variant" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/match/match-same-name-enum-variant/auxiliary" "-A" "unused"
2020-01-02T01:02:09.7153697Z ------------------------------------------
2020-01-02T01:02:09.7153881Z 
2020-01-02T01:02:09.7154295Z ------------------------------------------
2020-01-02T01:02:09.7154519Z stderr:
2020-01-02T01:02:09.7154519Z stderr:
2020-01-02T01:02:09.7154910Z ------------------------------------------
2020-01-02T01:02:09.7155152Z warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7155592Z   --> /checkout/src/test/ui/match/match-same-name-enum-variant.rs:17:9
2020-01-02T01:02:09.7155976Z LL |         Bar => println!("A"),
2020-01-02T01:02:09.7155976Z LL |         Bar => println!("A"),
2020-01-02T01:02:09.7156132Z    |         ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
2020-01-02T01:02:09.7156265Z 
2020-01-02T01:02:09.7156442Z warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7156894Z   --> /checkout/src/test/ui/match/match-same-name-enum-variant.rs:19:9
2020-01-02T01:02:09.7157093Z    |
2020-01-02T01:02:09.7157270Z LL |         Baz => println!("B"),
2020-01-02T01:02:09.7158093Z    |         ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
2020-01-02T01:02:09.7158282Z 
2020-01-02T01:02:09.7158473Z warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7158963Z   --> /checkout/src/test/ui/match/match-same-name-enum-variant.rs:26:9
2020-01-02T01:02:09.7159336Z LL |         Bar => println!("A"),
2020-01-02T01:02:09.7159336Z LL |         Bar => println!("A"),
2020-01-02T01:02:09.7159481Z    |         ^^^ help: to match on the variant, qualify the path: `Foo::Bar`
2020-01-02T01:02:09.7159606Z 
2020-01-02T01:02:09.7159774Z warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
2020-01-02T01:02:09.7160184Z   --> /checkout/src/test/ui/match/match-same-name-enum-variant.rs:28:9
2020-01-02T01:02:09.7160467Z    |
2020-01-02T01:02:09.7160971Z LL |         Baz => println!("B"),
2020-01-02T01:02:09.7161209Z    |         ^^^ help: to match on the variant, qualify the path: `Foo::Baz`
2020-01-02T01:02:09.7161905Z 
2020-01-02T01:02:09.7162643Z ------------------------------------------
2020-01-02T01:02:09.7163395Z 
2020-01-02T01:02:09.7163463Z 
---
2020-01-02T01:02:09.7171719Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2020-01-02T01:02:09.7171827Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2020-01-02T01:02:09.7198923Z 
2020-01-02T01:02:09.7203406Z 
2020-01-02T01:02:09.7207367Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-01-02T01:02:09.7208492Z 
2020-01-02T01:02:09.7208566Z 
2020-01-02T01:02:09.7216914Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2020-01-02T01:02:09.7217052Z Build completed unsuccessfully in 1:03:54
2020-01-02T01:02:09.7217052Z Build completed unsuccessfully in 1:03:54
2020-01-02T01:02:09.7285986Z == clock drift check ==
2020-01-02T01:02:09.7307414Z   local time: Thu Jan  2 01:02:09 UTC 2020
2020-01-02T01:02:10.0055025Z   network time: Thu, 02 Jan 2020 01:02:10 GMT
2020-01-02T01:02:10.0058339Z == end clock drift check ==
2020-01-02T01:02:10.8593949Z 
2020-01-02T01:02:10.8701204Z ##[error]Bash exited with code '1'.
2020-01-02T01:02:10.8737532Z ##[section]Starting: Checkout
2020-01-02T01:02:10.8739420Z ==============================================================================
2020-01-02T01:02:10.8739477Z Task         : Get sources
2020-01-02T01:02:10.8739539Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@csmoe
Copy link
Member

csmoe commented Jan 2, 2020

append --bless to the x.py ... command, ui err file will be updated automatically.

LeSeulArtichaut and others added 3 commits January 2, 2020 20:16
Co-authored-by: Centril <twingoow@gmail.com>
Co-authored-by: Centril <twingoow@gmail.com>
Co-authored-by: Centril <twingoow@gmail.com>
@LeSeulArtichaut
Copy link
Contributor Author

@Centril Updated according to review

@rustbot modify labels to -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 2, 2020
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2020
@Centril
Copy link
Contributor

Centril commented Jan 2, 2020

Thanks! @bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 2, 2020

📌 Commit 5cc9f6b has been approved by Centril

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 3, 2020
…, r=Centril

Warn for bindings named same as variants when matching against a borrow

Fixes rust-lang#67776
bors added a commit that referenced this pull request Jan 3, 2020
Rollup of 10 pull requests

Successful merges:

 - #67450 (Allow for setting a ThinLTO import limit during bootstrap)
 - #67595 (Suggest adding a lifetime constraint for opaque type)
 - #67636 (allow rustfmt key in [build] section)
 - #67736 (Less-than is asymmetric, not antisymmetric)
 - #67762 (Add missing links for insecure_time)
 - #67783 (Warn for bindings named same as variants when matching against a borrow)
 - #67796 (Ensure that we process projections during MIR inlining)
 - #67807 (Use drop instead of the toilet closure `|_| ()`)
 - #67816 (Clean up err codes)
 - #67825 (Minor: change take() docs grammar to match other docs)

Failed merges:

r? @ghost
@bors bors merged commit 5cc9f6b into rust-lang:master Jan 3, 2020
@LeSeulArtichaut LeSeulArtichaut deleted the pattern-ref-warning branch January 3, 2020 12:35
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
7 participants