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

typeck: Do not pass the field check on field error #51146

Merged
merged 1 commit into from
May 31, 2018

Conversation

dlrobertson
Copy link
Contributor

If a struct pattern has a field error return an error.

Fixes: #51102

@rust-highfive
Copy link
Collaborator

r? @estebank

(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 May 29, 2018
@estebank
Copy link
Contributor

LGTM. I'll r+ once travis is happy.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (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.
[00:43:28] ....................................................................................................
[00:43:31] ....................................................................................................
[00:43:36] ....................................................................................................
[00:43:40] ....................................................................................................
[00:43:44] ......................................................F.............................................
[00:43:55] .................................................................i..................................
[00:43:59] ....................................................................................................
[00:44:05] ....................................................................................................
[00:44:11] ..............................................................................................i.....
[00:44:11] ..............................................................................................i.....
[00:44:14] ............iiiiiiiii...................................................
[00:44:14] 
[00:44:14] ---- [ui] ui/issue-51102.rs stdout ----
[00:44:14] diff of stderr:
[00:44:14] 
[00:44:14] 
[00:44:14] 1 error[E0026]: struct `SimpleStruct` does not have a field named `state`
[00:44:14] -   --> $DIR/issue-51102.rs:13:17
[00:44:14] +   --> $DIR/issue-51102.rs:23:17
[00:44:14] 3    |
[00:44:14] 4 LL |                 state: 0,
[00:44:14] 5    |                 ^^^^^^^^ struct `SimpleStruct` does not have this field
[00:44:14] 6 
[00:44:14] 6 
[00:44:14] 7 error[E0025]: field `no_state_here` bound multiple times in the pattern
[00:44:14] -   --> $DIR/issue-51102.rs:24:17
[00:44:14] +   --> $DIR/issue-51102.rs:34:17
[00:44:14] 9    |
[00:44:14] 10 LL |                 no_state_here: 0,
[00:44:14] 11    |                 -ll,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0025]: field `no_state_here` bound multiple times in the pattern\n  --> /checkout/src/test/ui/issue-51102.rs:34:17\n   |\nLL |                 no_state_here: 0,\n   |                 ---------------- first use of `no_state_here`\nLL |                 no_state_here: 1\n   |                 ^^^^^^^^^^^^^^^^ multiple uses of `no_state_here` in pattern\n\n"}
[00:44:14] {"message":"variant `SimpleEnum::NoState` does not have a field named `state`","code":{"code":"E0026","explanation":"\nThis error indicates that a struct pattern attempted to extract a non-existent\nfield from a struct. Struct fields are identified by the name used before the\ncolon `:` so struct patterns should resemble the declaration of the struct type\nbeing matched.\n\n```\n// Correct matching.\nstruct Thing {\n    x: u32,\n    y: u32\n}\n\nlet thing = Thing { x: 1, y: 2 };\n\nmatch thing {\n    Thing { x: xfield, y: yfield } => {}\n}\n```\n\nIf you are using shorthand field patterns but want to refer to the struct field\nby a different name, you should rename it explicitly.\n\nChange this:\n\n```compile_fail,E0026\nstruct Thing {\n    x: u32,\n    y: u32\n}\n\nlet thing = Thing { x: 0, y: 0 };\n\nmatch thing {\n    Thing { x, z } => {}\n}\n```\n\nTo this:\n\n```\nstruct Thing {\n    x: u32,\n    y: u32\n}\n\nlet thing = Thing { x: 0, y: 0 };\n\nmatch thing {\n    Thing { x, y: z } => {}\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issue-51102.rs","byte_start":1174,"byte_end":1182,"line_start":43,"line_end":43,"column_start":17,"column_end":25,"is_primary":true,"text":[{"text":"                state: 0","highlight_start":17,"highlight_end":25}],"label":"variant `SimpleEnum::NoState` does not have this field","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0026]: variant `SimpleEnum::NoState` does not have a field named `state`\n  --> /checkout/src/test/ui/issue-51102.rs:43:17\n   |\nLL |                 state: 0\n   |                 ^^^^^^^^ variant `SimpleEnum::NoState` does not have this field\n\n"}
[00:44:14] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:44:14] {"message":"Some errors occurred: E0025, E0026.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0025, E0026.\n"}
[00:44:14] {"message":"For more information about an error, try `rustc --explain E0025`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about an error, try `rustc --explain E0025`.\n"}
[00:44:14] ------------------------------------------
[00:44:14] 
[00:44:14] thread '[ui] ui/issue-51102.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3053:9
[00:44:14] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:44:14] 
[00:44:14] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:44:14] 
[00:44:14] 
[00:44:14] command did not execute successfully: "/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-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -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" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:44:14] 
[00:44:14] 
[00:44:14] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:44:14] Build completed unsuccessfully in 0:02:29
[00:44:14] Build completed unsuccessfully in 0:02:29
[00:44:14] make: *** [check] Error 1
[00:44:14] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1d221112
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@dlrobertson
Copy link
Contributor Author

My bad. Forgot to update the line numbers when I updated the test. Updated.

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 29, 2018

📌 Commit 18ff09d 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-review Status: Awaiting review from the assignee but also interested parties. labels May 29, 2018
@bors
Copy link
Contributor

bors commented May 30, 2018

🔒 Merge conflict

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2018
kennytm added a commit to kennytm/rust that referenced this pull request May 30, 2018
typeck: Do not pass the field check on field error

If a struct pattern has a field error return an error.

Fixes: rust-lang#51102
bors added a commit that referenced this pull request May 30, 2018
Rollup of 12 pull requests

Successful merges:

 - #51050 (std::fs::DirEntry.metadata(): use fstatat instead of lstat when possible)
 - #51123 (Update build instructions)
 - #51127 (Add doc link from discriminant struct to function.)
 - #51146 (typeck: Do not pass the field check on field error)
 - #51147 (Stabilize SliceIndex trait.)
 - #51151 (Move slice::exact_chunks directly above exact_chunks_mut for more con…)
 - #51152 (Replace `if` with `if and only if` in the definition dox of `Sync`)
 - #51153 (Link panic and compile_error docs)
 - #51158 (Mention spec and indented blocks in doctest docs)
 - #51186 (Remove two redundant .nll.stderr files)
 - #51203 (Two minor `obligation_forest` tweaks.)
 - #51213 (fs: copy: Use File::set_permissions instead of fs::set_permissions)

Failed merges:
@dlrobertson
Copy link
Contributor Author

Do I need to rebase this? Or is bors complaining about the rollup?

@pnkfelix
Copy link
Member

@dlrobertson I think you need to rebase. homu's complaining about your commit here.

@nagisa nagisa added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 31, 2018
If a struct pattern has a field error return an error.
@dlrobertson
Copy link
Contributor Author

Updated

@Mark-Simulacrum
Copy link
Member

@bors r=estebank p=1

@rust-lang/compiler -- Could we get someone to beta-approve this? We'll want to prepare a backport, too.

@bors
Copy link
Contributor

bors commented May 31, 2018

📌 Commit 8f64415 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 May 31, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 31, 2018
typeck: Do not pass the field check on field error

If a struct pattern has a field error return an error.

Fixes: rust-lang#51102
bors added a commit that referenced this pull request May 31, 2018
Rollup of 7 pull requests

Successful merges:

 - #49546 (Stabilize short error format)
 - #51123 (Update build instructions)
 - #51146 (typeck: Do not pass the field check on field error)
 - #51193 (Fixes some style issues in rustdoc "implementations on Foreign types")
 - #51213 (fs: copy: Use File::set_permissions instead of fs::set_permissions)
 - #51227 (mod.rs isn't beautiful)
 - #51240 (Two minor parsing tweaks)

Failed merges:
@bors bors merged commit 8f64415 into rust-lang:master May 31, 2018
@oli-obk oli-obk added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Jun 1, 2018
bors added a commit that referenced this pull request Jun 1, 2018
[beta] Process backports

Merged and approved:

* #50812: Fix issue #50811 (`NaN > NaN` was true).
* #50827: Update LLVM to `56c931901cfb85cd6f7ed44c7d7520a8de1edf97`
* #50879: Fix naming conventions for new lints
* #51011: rustdoc: hide macro export statements from docs
* #51051: prohibit turbofish in `impl Trait` methods
* #51052: restore emplacement syntax (obsolete)
* #51146: typeck: Do not pass the field check on field error
* #51235: remove notion of Implicit derefs from mem-cat

r? @ghost
@pietroalbini pietroalbini added beta-nominated Nominated for backporting to the compiler in the beta channel. and removed beta-nominated Nominated for backporting to the compiler in the beta channel. labels Jun 3, 2018
bors added a commit that referenced this pull request Jun 3, 2018
[beta] Process backports

Merged and approved:

* #50812: Fix issue #50811 (`NaN > NaN` was true).
* #50879: Fix naming conventions for new lints
* #51011: rustdoc: hide macro export statements from docs
* #51051: prohibit turbofish in impl Trait methods
* #51052: restore emplacement syntax (obsolete)
* #51146: typeck: Do not pass the field check on field error
* #51235: remove notion of Implicit derefs from mem-cat

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants