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

trait-based structural match implementation #65519

Merged

Conversation

pnkfelix
Copy link
Member

Moves from using a #[structural_match] attribute to using a marker trait (or pair of such traits, really) instead.

Fix #63438.

(This however does not remove the hacks that I believe were put into place to support the previous approach of injecting the attribute based on the presence of both derives... I have left that for follow-on work.)

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(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 Oct 17, 2019
@pnkfelix
Copy link
Member Author

cc @petrochenkov

@pnkfelix
Copy link
Member Author

(I do have other experimental work that goes further in fixing bugs in our structural-match system. However, I decided this piece of the puzzle was worth landing on its own, since it is both broad in the amount of code it touches, but very narrow in its actual user-visible effects...)

@petrochenkov petrochenkov self-assigned this Oct 17, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 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.
2019-10-17T20:53:09.3936745Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-17T20:53:09.4118890Z ##[command]git config gc.auto 0
2019-10-17T20:53:09.4189325Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-17T20:53:09.4235098Z ##[command]git config --get-all http.proxy
2019-10-17T20:53:09.4382832Z ##[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/65519/merge:refs/remotes/pull/65519/merge
---
2019-10-17T21:55:44.9735571Z .................................................................................................... 1600/9196
2019-10-17T21:55:50.0880043Z .................................................................................................... 1700/9196
2019-10-17T21:56:02.8739558Z .............................i...............i...................................................... 1800/9196
2019-10-17T21:56:10.3215943Z .................................................................................................... 1900/9196
2019-10-17T21:56:24.7380449Z ...................iiiii............................................................................ 2000/9196
2019-10-17T21:56:35.2990946Z .................................................................................................... 2200/9196
2019-10-17T21:56:37.8007099Z .................................................................................................... 2300/9196
2019-10-17T21:56:43.3229498Z .................................................................................................... 2400/9196
2019-10-17T21:57:05.3391607Z .................................................................................................... 2500/9196
---
2019-10-17T22:00:00.1564326Z ......................i...............i............................................................. 4800/9196
2019-10-17T22:00:12.1733373Z .................................................................................................... 4900/9196
2019-10-17T22:00:18.6536209Z .................................................................................................... 5000/9196
2019-10-17T22:00:29.5013693Z .................................................................................................... 5100/9196
2019-10-17T22:00:35.9426960Z ......................ii.ii......................................................................... 5200/9196
2019-10-17T22:00:46.6859528Z .................................................................................................... 5400/9196
2019-10-17T22:00:56.9830679Z ........................................................................................i........... 5500/9196
2019-10-17T22:01:05.4166852Z .................................................................................................... 5600/9196
2019-10-17T22:01:10.6488741Z .................................................................................................... 5700/9196
2019-10-17T22:01:10.6488741Z .................................................................................................... 5700/9196
2019-10-17T22:01:21.4013435Z .....................................................................................ii...i..ii..... 5800/9196
2019-10-17T22:01:47.7361213Z .................................................................................................... 6000/9196
2019-10-17T22:01:57.4208188Z .................................................................................................... 6100/9196
2019-10-17T22:02:03.0616510Z .................................................................................................... 6200/9196
2019-10-17T22:02:03.0616510Z .................................................................................................... 6200/9196
2019-10-17T22:02:17.8911453Z .......i..ii........................................................................................ 6300/9196
2019-10-17T22:02:38.5694635Z ...................................................................i................................ 6500/9196
2019-10-17T22:02:40.8148626Z .................................................................................................... 6600/9196
2019-10-17T22:02:43.4150826Z .........................................i.......................................................... 6700/9196
2019-10-17T22:02:47.4252969Z .................................................................................................... 6800/9196
---
2019-10-17T22:07:23.8990723Z  finished in 5.451
2019-10-17T22:07:23.9180028Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-17T22:07:24.1144226Z 
2019-10-17T22:07:24.1144478Z running 153 tests
2019-10-17T22:07:27.3335756Z i....iii......iii..iiii...i.............................i..i..................i....i...........ii.i. 100/153
2019-10-17T22:07:29.3531008Z i..iiii..............i.........iii.i.........ii......
2019-10-17T22:07:29.3532767Z 
2019-10-17T22:07:29.3536235Z  finished in 5.435
2019-10-17T22:07:29.3719958Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-17T22:07:29.5399995Z 
---
2019-10-17T22:07:31.5831345Z ---- [codegen-units] codegen-units/item-collection/overloaded-operators.rs stdout ----
2019-10-17T22:07:31.5831396Z 
2019-10-17T22:07:31.5831480Z These items should have been contained but were not:
2019-10-17T22:07:31.5831512Z 
2019-10-17T22:07:31.5831556Z MONO_ITEM fn overloaded_operators::{{impl}}[4]::eq[0]
2019-10-17T22:07:31.5832348Z MONO_ITEM fn overloaded_operators::{{impl}}[4]::ne[0]
2019-10-17T22:07:31.5832481Z 
2019-10-17T22:07:31.5832506Z 
2019-10-17T22:07:31.5832555Z These items were contained but should not have been:
2019-10-17T22:07:31.5832586Z 
2019-10-17T22:07:31.5832586Z 
2019-10-17T22:07:31.5832651Z MONO_ITEM fn overloaded_operators::{{impl}}[5]::eq[0] @@
2019-10-17T22:07:31.5832868Z MONO_ITEM fn overloaded_operators::{{impl}}[5]::ne[0] @@
2019-10-17T22:07:31.5832932Z 
2019-10-17T22:07:31.5833405Z thread '[codegen-units] codegen-units/item-collection/overloaded-operators.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2609:13
2019-10-17T22:07:31.5833474Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-10-17T22:07:31.5833686Z 
---
2019-10-17T22:07:31.5837101Z 
2019-10-17T22:07:31.5843183Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-10-17T22:07:31.5848010Z 
2019-10-17T22:07:31.5848151Z 
2019-10-17T22:07:31.5849781Z 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/codegen-units" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen-units" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "codegen-units" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/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" "6.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"
2019-10-17T22:07:31.5850031Z 
2019-10-17T22:07:31.5850060Z 
2019-10-17T22:07:31.5861596Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-10-17T22:07:31.5862299Z Build completed unsuccessfully in 1:07:23
2019-10-17T22:07:31.5862299Z Build completed unsuccessfully in 1:07:23
2019-10-17T22:07:31.5918506Z == clock drift check ==
2019-10-17T22:07:31.5976041Z   local time: Thu Oct 17 22:07:31 UTC 2019
2019-10-17T22:07:31.9112005Z   network time: Thu, 17 Oct 2019 22:07:31 GMT
2019-10-17T22:07:31.9115694Z == end clock drift check ==
2019-10-17T22:07:36.2029524Z ##[error]Bash exited with code '1'.
2019-10-17T22:07:36.2097738Z ##[section]Starting: Checkout
2019-10-17T22:07:36.2099422Z ==============================================================================
2019-10-17T22:07:36.2099474Z Task         : Get sources
2019-10-17T22:07:36.2099518Z 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)

@bors
Copy link
Contributor

bors commented Oct 17, 2019

☔ The latest upstream changes (presumably #65495) made this pull request unmergeable. Please resolve the merge conflicts.

src/libsyntax_ext/deriving/mod.rs Show resolved Hide resolved
src/librustc_mir/hair/pattern/const_to_pat.rs Outdated Show resolved Hide resolved
src/librustc_mir/hair/pattern/const_to_pat.rs Outdated Show resolved Hide resolved
src/librustc_mir/hair/pattern/const_to_pat.rs Outdated Show resolved Hide resolved
src/librustc_mir/hair/pattern/const_to_pat.rs Outdated Show resolved Hide resolved
@Centril
Copy link
Contributor

Centril commented Oct 18, 2019

cc @varkor

@pnkfelix
Copy link
Member Author

The job x86_64-gnu-llvm-6.0 of your PR failed

(Hmm apparently I need to include a few extra suites in my local test runs.)

@pnkfelix
Copy link
Member Author

One thing we probably will want is a perf run on this. I do not know if there might be an impact from the way I implemented type_marked_structural.

(If necessary, we could batch up the obligations and try to solve them all at once, but its tricky because we want to have hard errors in some cases and lints in others, due to future-compatibility concerns. That trickiness is why I opted to take this approach first.)

@pnkfelix pnkfelix force-pushed the issue-63438-trait-based-structural-match branch from f4626f6 to 17231a0 Compare October 18, 2019 09:37
@petrochenkov petrochenkov removed their assignment Oct 18, 2019
// keep old code until future-compat upgraded to errors.
ty::Ref(_, adt_ty @ ty::TyS { kind: ty::Adt(_, _), .. }, _)
if !self.type_marked_structural(adt_ty) => {
let adt_def = if let ty::Adt(adt_def, _) = adt_ty.kind {
Copy link
Contributor

Choose a reason for hiding this comment

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

The identation here is a bit confusing

Copy link
Member Author

Choose a reason for hiding this comment

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

heh, this is the bit of code that inspired me to file #65490

@bors
Copy link
Contributor

bors commented Oct 20, 2019

☔ The latest upstream changes (presumably #65632) made this pull request unmergeable. Please resolve the merge conflicts.

@pnkfelix pnkfelix force-pushed the issue-63438-trait-based-structural-match branch from dceb5e3 to ee61fd1 Compare October 21, 2019 14:44
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 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.
2019-10-21T14:45:10.4568606Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-21T14:45:10.4803555Z ##[command]git config gc.auto 0
2019-10-21T14:45:10.4896563Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-21T14:45:10.4946480Z ##[command]git config --get-all http.proxy
2019-10-21T14:45:10.5102035Z ##[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/65519/merge:refs/remotes/pull/65519/merge
---
2019-10-21T15:52:29.0327422Z .................................................................................................... 1600/9203
2019-10-21T15:52:34.8475626Z .................................................................................................... 1700/9203
2019-10-21T15:52:48.7004905Z ................................i...............i................................................... 1800/9203
2019-10-21T15:52:56.9525405Z .................................................................................................... 1900/9203
2019-10-21T15:53:12.4520191Z ......................iiiii......................................................................... 2000/9203
2019-10-21T15:53:24.1656539Z .................................................................................................... 2200/9203
2019-10-21T15:53:27.0265785Z .................................................................................................... 2300/9203
2019-10-21T15:53:32.6147261Z .................................................................................................... 2400/9203
2019-10-21T15:53:56.9036830Z .................................................................................................... 2500/9203
---
2019-10-21T15:57:08.3513577Z .........................i...............i.......................................................... 4800/9203
2019-10-21T15:57:21.7882640Z .................................................................................................... 4900/9203
2019-10-21T15:57:28.8163221Z .................................................................................................... 5000/9203
2019-10-21T15:57:38.9213681Z .................................................................................................... 5100/9203
2019-10-21T15:57:47.0106563Z .........................ii.ii...................................................................... 5200/9203
2019-10-21T15:57:58.0330967Z .................................................................................................... 5400/9203
2019-10-21T15:58:09.3935020Z ...........................................................................................i........ 5500/9203
2019-10-21T15:58:18.4366573Z .................................................................................................... 5600/9203
2019-10-21T15:58:23.8042872Z .................................................................................................... 5700/9203
2019-10-21T15:58:23.8042872Z .................................................................................................... 5700/9203
2019-10-21T15:58:35.2175445Z .........................................................................................ii..i..ii.. 5800/9203
2019-10-21T15:59:04.3876964Z .................................................................................................... 6000/9203
2019-10-21T15:59:14.6709769Z .................................................................................................... 6100/9203
2019-10-21T15:59:22.8619792Z .................................................................................................... 6200/9203
2019-10-21T15:59:22.8619792Z .................................................................................................... 6200/9203
2019-10-21T15:59:38.0518399Z ..........i..ii..................................................................................... 6300/9203
2019-10-21T16:00:00.0757871Z ......................................................................i............................. 6500/9203
2019-10-21T16:00:02.5882444Z .................................................................................................... 6600/9203
2019-10-21T16:00:05.2319689Z .............................................i...................................................... 6700/9203
2019-10-21T16:00:09.2256706Z .................................................................................................... 6800/9203
---
2019-10-21T16:05:05.8442609Z  finished in 6.581
2019-10-21T16:05:05.8688825Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-21T16:05:06.0451394Z 
2019-10-21T16:05:06.0451667Z running 153 tests
2019-10-21T16:05:09.6569883Z i....iii......iii..iiii...i..............................i.i..................i....i...........ii.i. 100/153
2019-10-21T16:05:11.7998370Z i..iiii..............i.........iii.i.........ii......
2019-10-21T16:05:11.7998945Z 
2019-10-21T16:05:11.7999018Z  finished in 5.931
2019-10-21T16:05:11.8238443Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-21T16:05:11.9989659Z 
---
2019-10-21T16:05:14.1975714Z  finished in 2.374
2019-10-21T16:05:14.2203377Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-21T16:05:14.3960851Z 
2019-10-21T16:05:14.3963591Z running 9 tests
2019-10-21T16:05:14.3974450Z iiiiiiiii
2019-10-21T16:05:14.3975753Z 
2019-10-21T16:05:14.3975955Z  finished in 0.176
2019-10-21T16:05:14.4217631Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-21T16:05:14.6085587Z 
---
2019-10-21T16:05:34.5369633Z  finished in 20.115
2019-10-21T16:05:34.5573294Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-21T16:05:34.7314314Z 
2019-10-21T16:05:34.7314596Z running 123 tests
2019-10-21T16:06:01.7898275Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....ii..........iiii..........i...ii...i.......ii. 100/123
2019-10-21T16:06:06.9859909Z i.i.i......iii.i.....ii
2019-10-21T16:06:06.9863847Z 
2019-10-21T16:06:06.9864402Z  finished in 32.429
2019-10-21T16:06:06.9885114Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-10-21T16:06:06.9885501Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-10-21T16:20:07.7428352Z 
2019-10-21T16:20:07.7429685Z    Doc-tests core
2019-10-21T16:20:13.1684944Z 
2019-10-21T16:20:13.1687593Z running 2407 tests
2019-10-21T16:20:25.5969432Z ......iiiii......................................................................................... 100/2407
2019-10-21T16:20:37.6371806Z ................................................................................ii.................. 200/2407
2019-10-21T16:21:06.1189233Z ..i................................................................................................. 400/2407
2019-10-21T16:21:06.1189233Z ..i................................................................................................. 400/2407
2019-10-21T16:21:18.3005546Z .................................................i..i.................iiii.......................... 500/2407
2019-10-21T16:21:29.5320866Z ..F................................................................................................. 600/2407
2019-10-21T16:21:53.6733761Z .................................................................................................... 800/2407
2019-10-21T16:22:05.8463332Z .................................................................................................... 900/2407
2019-10-21T16:22:17.7006508Z .................................................................................................... 1000/2407
2019-10-21T16:22:29.6428463Z .................................................................................................... 1100/2407
---
2019-10-21T16:25:12.4127445Z ................i................................................................................... 2400/2407
2019-10-21T16:25:13.2475187Z .......
2019-10-21T16:25:13.2479930Z failures:
2019-10-21T16:25:13.2479982Z 
2019-10-21T16:25:13.2480829Z ---- marker.rs - marker::StructuralEq (line 177) stdout ----
2019-10-21T16:25:13.2480948Z error: expected one of `:` or `|`, found `)`
2019-10-21T16:25:13.2481237Z   |
2019-10-21T16:25:13.2481237Z   |
2019-10-21T16:25:13.2481280Z 5 | fn higher_order(&()) { }
2019-10-21T16:25:13.2481359Z   |                    ^ expected one of `:` or `|` here
2019-10-21T16:25:13.2481431Z error[E0308]: mismatched types
2019-10-21T16:25:13.2481665Z  --> marker.rs:184:9
2019-10-21T16:25:13.2481710Z   |
2019-10-21T16:25:13.2481710Z   |
2019-10-21T16:25:13.2481751Z 9 |         CFN => {}
2019-10-21T16:25:13.2481796Z   |         ^^^ expected fn item, found fn pointer
2019-10-21T16:25:13.2481854Z   |
2019-10-21T16:25:13.2481900Z   = note: expected type `Wrap<fn([type error]) {higher_order}>`
2019-10-21T16:25:13.2482145Z              found type `Wrap<for<'r> fn(&'r ())>`
2019-10-21T16:25:13.2482235Z error: aborting due to 2 previous errors
2019-10-21T16:25:13.2482262Z 
2019-10-21T16:25:13.2482522Z For more information about this error, try `rustc --explain E0308`.
2019-10-21T16:25:13.2482761Z Couldn't compile the test.
---
2019-10-21T16:25:13.2483198Z 
2019-10-21T16:25:13.2648768Z error: test failed, to rerun pass '--doc'
2019-10-21T16:25:13.2660367Z 
2019-10-21T16:25:13.2661192Z 
2019-10-21T16:25:13.2663085Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "-Zconfig-profile" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libtest/Cargo.toml" "-p" "core" "--" "--quiet"
2019-10-21T16:25:13.2663294Z 
2019-10-21T16:25:13.2663326Z 
2019-10-21T16:25:13.2678179Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-10-21T16:25:13.2678275Z Build completed unsuccessfully in 1:33:16
2019-10-21T16:25:13.2678275Z Build completed unsuccessfully in 1:33:16
2019-10-21T16:25:13.2741204Z == clock drift check ==
2019-10-21T16:25:13.2758589Z   local time: Mon Oct 21 16:25:13 UTC 2019
2019-10-21T16:25:13.3091992Z   network time: Mon, 21 Oct 2019 16:25:13 GMT
2019-10-21T16:25:13.3095554Z == end clock drift check ==
2019-10-21T16:25:13.9296043Z 
2019-10-21T16:25:13.9463803Z ##[error]Bash exited with code '1'.
2019-10-21T16:25:13.9548337Z ##[section]Starting: Checkout
2019-10-21T16:25:13.9551247Z ==============================================================================
2019-10-21T16:25:13.9551335Z Task         : Get sources
2019-10-21T16:25:13.9551388Z 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)

@pnkfelix
Copy link
Member Author

2019-10-21T16:25:13.2480829Z ---- marker.rs - marker::StructuralEq (line 177) stdout ----
2019-10-21T16:25:13.2480948Z error: expected one of : or |, found )
2019-10-21T16:25:13.2481237Z |
2019-10-21T16:25:13.2481237Z |
2019-10-21T16:25:13.2481280Z 5 | fn higher_order(&()) { }
2019-10-21T16:25:13.2481359Z | ^ expected one of : or | here

hmm, whoopsie.

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 24, 2019

📌 Commit c7da944105fd62d29f0378c20346ca1994b4a84c has been approved by matthewjasper

@bors
Copy link
Contributor

bors commented Oct 24, 2019

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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 Oct 24, 2019
@bors
Copy link
Contributor

bors commented Oct 25, 2019

☔ The latest upstream changes (presumably #65771) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 25, 2019
@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 25, 2019
bors added a commit that referenced this pull request Oct 25, 2019
Rollup of 9 pull requests

Successful merges:

 - #62959 (Add by-value iterator for arrays )
 - #65390 (Add long error explanation for E0576)
 - #65408 (reorder config.toml.example options and add one missing option)
 - #65414 (ignore uninhabited non-exhaustive variant fields)
 - #65666 (Deprecated proc_macro doesn't trigger warning on build library)
 - #65742 (Pre-expansion gate most of the things)
 - #65747 (Adjust the tracking issue for `untagged_unions`.)
 - #65763 (Changed APIT with explicit generic args span to specific arg spans)
 - #65775 (Fix more `ReEmpty` ICEs)

Failed merges:

 - #65519 (trait-based structural match implementation)

r? @ghost
(Or more precisely, a pair of such traits: one for `derive(PartialEq)` and one
for `derive(Eq)`.)

((The addition of the second marker trait, `StructuralEq`, is largely a hack to
work-around `fn (&T)` not implementing `PartialEq` and `Eq`; see also issue
rust-lang#46989; otherwise I would just check if `Eq` is implemented.))

Note: this does not use trait fulfillment error-reporting machinery; it just
uses the trait system to determine if the ADT was tagged or not. (Nonetheless, I
have kept an `on_unimplemented` message on the new trait for structural_match
check, even though it is currently not used.)

Note also: this does *not* resolve the ICE from rust-lang#65466, as noted
in a comment added in this commit. Further work is necessary to resolve that and
other problems with the structural match checking, especially to do so without
breaking stable code (adapted from test fn-ptr-is-structurally-matchable.rs):

```rust
fn r_sm_to(_: &SM) {}

fn main() {
    const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to);
    let input: Wrap<fn(&SM)> = Wrap(r_sm_to);
    match Wrap(input) {
        Wrap(CFN6) => {}
        Wrap(_) => {}
    };
}
```

where we would hit a problem with the strategy of unconditionally checking for
`PartialEq` because the type `for <'a> fn(&'a SM)` does not currently even
*implement* `PartialEq`.

----

added review feedback:
* use an or-pattern
* eschew `return` when tail position will do.
* don't need fresh_expansion; just add `structural_match` to appropriate `allow_internal_unstable` attributes.

also fixed example in doc comment so that it actually compiles.
(My inference is that the number changed from 4 to 5 because `derive(PartialEq)` now injects an extra trait impl before.)
@pnkfelix pnkfelix force-pushed the issue-63438-trait-based-structural-match branch from c7da944 to f645e90 Compare October 25, 2019 13:15
@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 26, 2019

📌 Commit f645e90 has been approved by matthewjasper

@bors
Copy link
Contributor

bors commented Oct 26, 2019

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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 26, 2019
@bors
Copy link
Contributor

bors commented Oct 27, 2019

⌛ Testing commit f645e90 with merge b7176b4...

bors added a commit that referenced this pull request Oct 27, 2019
…tch, r=matthewjasper

trait-based structural match implementation

Moves from using a `#[structural_match]` attribute to using a marker trait (or pair of such traits, really) instead.

Fix #63438.

(This however does not remove the hacks that I believe were put into place to support the previous approach of injecting the attribute based on the presence of both derives... I have left that for follow-on work.)
@bors
Copy link
Contributor

bors commented Oct 27, 2019

☀️ Test successful - checks-azure
Approved by: matthewjasper
Pushing b7176b4 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 27, 2019
@bors bors merged commit f645e90 into rust-lang:master Oct 27, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 5, 2019
…trochenkov

Remove `PartialEq` and `Eq` from the `SpecialDerives`.

Now that PR rust-lang#65519 landed, this is the follow-on work of removing `PartialEq` and `Eq` from the set of `SpecialDerives` .
Centril added a commit to Centril/rust that referenced this pull request Nov 6, 2019
…trochenkov

Remove `PartialEq` and `Eq` from the `SpecialDerives`.

Now that PR rust-lang#65519 landed, this is the follow-on work of removing `PartialEq` and `Eq` from the set of `SpecialDerives` .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

"Structural match" annotations should be moved from struct/enum items to impl items
7 participants