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

forbid dyn Trait in patterns #71038

Merged
merged 2 commits into from
May 4, 2020
Merged

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Apr 11, 2020

Do not allow &dyn Trait as a generic const parameters.
This also changes dyn trait in pattern from ICE to error.

closes #63322
closes #70972

r? @eddyb

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 11, 2020
@lcnr lcnr force-pushed the dyn_trait_structural_match branch from 21185be to b373917 Compare April 11, 2020 20:12
@eddyb
Copy link
Member

eddyb commented Apr 11, 2020

IMO this PR's title/description should focus on pattern-matching.
Affecting const generics is a side-effect from that.

r? @pnkfelix

@rust-highfive rust-highfive assigned pnkfelix and unassigned eddyb Apr 11, 2020
@lcnr lcnr changed the title forbid dyn Trait in const generics forbid dyn Trait in patterns Apr 11, 2020
@varkor varkor added the F-const_generics `#![feature(const_generics)]` label Apr 11, 2020
@rust-highfive
Copy link
Collaborator

The job mingw-check 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-04-11T21:59:45.0073491Z ========================== Starting Command Output ===========================
2020-04-11T21:59:45.0075723Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/f3f142f7-6748-4741-86c0-fec9af16cfd5.sh
2020-04-11T21:59:45.0075987Z 
2020-04-11T21:59:45.0079519Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-11T21:59:45.0097303Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71038/merge to s
2020-04-11T21:59:45.0100389Z Task         : Get sources
2020-04-11T21:59:45.0100669Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-11T21:59:45.0100946Z Version      : 1.0.0
2020-04-11T21:59:45.0101145Z Author       : Microsoft
---
2020-04-11T21:59:46.0046186Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-11T21:59:46.0053714Z ##[command]git config gc.auto 0
2020-04-11T21:59:46.0058957Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-11T21:59:46.0064235Z ##[command]git config --get-all http.proxy
2020-04-11T21:59:46.0072866Z ##[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/71038/merge:refs/remotes/pull/71038/merge
---
2020-04-11T22:02:00.2552171Z  ---> 78ad2f4d4aca
2020-04-11T22:02:00.2552369Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2020-04-11T22:02:00.2557471Z  ---> Using cache
2020-04-11T22:02:00.2557840Z  ---> 4d2dc61c4d00
2020-04-11T22:02:00.2559089Z Step 7/7 : ENV SCRIPT python3 ../x.py test src/tools/expand-yaml-anchors &&            python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python3 ../x.py build --stage 0 src/tools/build-manifest &&            python3 ../x.py test --stage 0 src/tools/compiletest &&            python3 ../x.py test src/tools/tidy &&            /scripts/validate-toolstate.sh
2020-04-11T22:02:00.2565624Z  ---> 776b6266a8b7
2020-04-11T22:02:00.2596833Z Successfully built 776b6266a8b7
2020-04-11T22:02:00.2631427Z Successfully tagged rust-ci:latest
2020-04-11T22:02:00.2877461Z Built container sha256:776b6266a8b7d63e2d3c2b5a784dbf521184a904fb10bf818c6b5c7e1ab74d4a
2020-04-11T22:02:00.2877461Z Built container sha256:776b6266a8b7d63e2d3c2b5a784dbf521184a904fb10bf818c6b5c7e1ab74d4a
2020-04-11T22:02:00.2890577Z Looks like docker image is the same as before, not uploading
2020-04-11T22:02:06.9366475Z [CI_JOB_NAME=mingw-check]
2020-04-11T22:02:06.9614938Z [CI_JOB_NAME=mingw-check]
2020-04-11T22:02:06.9640766Z == clock drift check ==
2020-04-11T22:02:06.9650478Z   local time: Sat Apr 11 22:02:06 UTC 2020
2020-04-11T22:02:07.1510304Z   network time: Sat, 11 Apr 2020 22:02:07 GMT
2020-04-11T22:02:07.1551693Z Starting sccache server...
2020-04-11T22:02:07.2584437Z configure: processing command line
2020-04-11T22:02:07.2584815Z configure: 
2020-04-11T22:02:07.2585741Z configure: rust.parallel-compiler := True
---
2020-04-11T22:05:29.4737080Z     Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-11T22:05:29.6375324Z     Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-11T22:05:29.8227173Z     Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-11T22:05:29.8473291Z     Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-11T22:05:30.3899440Z     Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-11T22:05:32.4306641Z     Checking rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-11T22:05:32.8910975Z     Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-11T22:05:34.7624208Z     Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-11T22:05:35.1609485Z     Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-11T22:07:11.7945165Z configure: rust.codegen-units-std := 1
2020-04-11T22:07:11.7945693Z configure: rust.verify-llvm-ir  := True
2020-04-11T22:07:11.7946106Z configure: llvm.assertions      := True
2020-04-11T22:07:11.7946464Z configure: llvm.ccache          := sccache
2020-04-11T22:07:11.7947136Z configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
2020-04-11T22:07:11.7947771Z configure: writing `config.toml` in current directory
2020-04-11T22:07:11.7948004Z configure: 
2020-04-11T22:07:11.7948480Z configure: run `python /checkout/x.py --help`
2020-04-11T22:07:11.7948791Z configure: 
---
2020-04-11T22:08:33.5850462Z Hugepagesize:       2048 kB
2020-04-11T22:08:33.5850640Z DirectMap4k:      141248 kB
2020-04-11T22:08:33.5850816Z DirectMap2M:     5101568 kB
2020-04-11T22:08:33.5851008Z DirectMap1G:     4194304 kB
2020-04-11T22:08:33.5872000Z + python3 ../x.py test src/tools/expand-yaml-anchors
2020-04-11T22:08:34.8288562Z Ensuring the YAML anchors in the GitHub Actions config were expanded
2020-04-11T22:08:34.8288562Z Ensuring the YAML anchors in the GitHub Actions config were expanded
2020-04-11T22:08:34.8295873Z Building stage0 tool expand-yaml-anchors (x86_64-unknown-linux-gnu)
2020-04-11T22:08:35.0374444Z    Compiling unicode-xid v0.2.0
2020-04-11T22:08:35.1571821Z    Compiling syn v1.0.11
2020-04-11T22:08:35.8976914Z    Compiling linked-hash-map v0.5.2
2020-04-11T22:08:35.9376950Z    Compiling lazy_static v1.4.0
2020-04-11T22:08:35.9376950Z    Compiling lazy_static v1.4.0
2020-04-11T22:08:36.1138144Z    Compiling yaml-rust v0.4.3
2020-04-11T22:08:40.0048253Z    Compiling quote v1.0.2
2020-04-11T22:08:52.8307980Z    Compiling thiserror-impl v1.0.5
2020-04-11T22:08:57.0416865Z    Compiling thiserror v1.0.5
2020-04-11T22:08:57.0995473Z    Compiling yaml-merge-keys v0.4.0
2020-04-11T22:08:58.1561126Z    Compiling expand-yaml-anchors v0.1.0 (/checkout/src/tools/expand-yaml-anchors)
2020-04-11T22:08:59.5878373Z Build completed successfully in 0:00:25
2020-04-11T22:08:59.5979024Z + python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu
2020-04-11T22:08:59.8370550Z     Finished dev [unoptimized] target(s) in 0.15s
2020-04-11T22:09:00.8529827Z Checking rustdoc artifacts (x86_64-unknown-linux-gnu -> i686-pc-windows-gnu)
---
2020-04-11T22:10:54.8132825Z     Checking rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-11T22:10:54.9153620Z     Checking fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-11T22:10:55.1156189Z     Checking rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-11T22:10:55.2133577Z     Checking rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-11T22:10:55.6990929Z     Checking rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-11T22:10:57.7068296Z     Checking rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-11T22:10:58.1661269Z     Checking rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-11T22:11:00.0717548Z     Checking rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-11T22:11:00.4879331Z     Checking rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-11T22:14:40.6560870Z Diff in /checkout/src/librustc_mir_build/hair/pattern/const_to_pat.rs at line 110:
2020-04-11T22:14:40.6561202Z                              path, path,
2020-04-11T22:14:40.6561434Z                          )
2020-04-11T22:14:40.6565103Z                      }
2020-04-11T22:14:40.6569111Z -                    traits::NonStructuralMatchTy::Dynamic => {
2020-04-11T22:14:40.6571764Z -                        format!("ok")
2020-04-11T22:14:40.6594026Z -                    }
2020-04-11T22:14:40.6596356Z +                    traits::NonStructuralMatchTy::Dynamic => format!("ok"),
2020-04-11T22:14:40.6596763Z                      traits::NonStructuralMatchTy::Param => {
2020-04-11T22:14:40.6597168Z                          bug!("use of constant whose type is a parameter inside a pattern")
2020-04-11T22:14:40.6597457Z                      }
2020-04-11T22:14:40.6598485Z Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/src/librustc_mir_build/hair/pattern/const_to_pat.rs"` failed.
2020-04-11T22:14:40.6599416Z If you're running `tidy`, try again with `--bless` flag. Or, you just want to format code, run `./x.py fmt` instead.
2020-04-11T22:14:40.6601710Z Build completed unsuccessfully in 0:00:39
2020-04-11T22:14:40.6690210Z == clock drift check ==
2020-04-11T22:14:40.6707279Z   local time: Sat Apr 11 22:14:40 UTC 2020
2020-04-11T22:14:40.6816121Z   network time: Diff in /checkout/src/librustc_mir_build/hair/pattern/_match.rs at line 316:
2020-04-11T22:14:40.6816121Z   network time: Diff in /checkout/src/librustc_mir_build/hair/pattern/_match.rs at line 316:
2020-04-11T22:14:40.6816518Z              | (_, ty::Str, ty::Str) => val,
2020-04-11T22:14:40.6817350Z              // FIXME(oli-obk): this is reachable for `const FOO: &&&u32 = &&&42;` being used
2020-04-11T22:14:40.6817666Z              (val, _, _) => {
2020-04-11T22:14:40.6818202Z -                self.tcx.sess.delay_span_bug(DUMMY_SP, &format!("cannot deref {:#?}, {} -> {}", val, crty, rty));
2020-04-11T22:14:40.6818569Z +                self.tcx.sess.delay_span_bug(
2020-04-11T22:14:40.6818768Z +                    DUMMY_SP,
2020-04-11T22:14:40.6819200Z +                    &format!("cannot deref {:#?}, {} -> {}", val, crty, rty),
2020-04-11T22:14:40.6819611Z                  val
2020-04-11T22:14:40.6820056Z -            },
2020-04-11T22:14:40.6820208Z +            }
2020-04-11T22:14:40.6820334Z          }
2020-04-11T22:14:40.6820334Z          }
2020-04-11T22:14:40.6820449Z      }
2020-04-11T22:14:40.6820566Z  }
2020-04-11T22:14:40.9784802Z Sat, 11 Apr 2020 22:14:40 GMT
2020-04-11T22:14:42.7169577Z 
2020-04-11T22:14:42.7169577Z 
2020-04-11T22:14:42.7234611Z ##[error]Bash exited with code '1'.
2020-04-11T22:14:42.7247829Z ##[section]Finishing: Run build
2020-04-11T22:14:42.7291453Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71038/merge to s
2020-04-11T22:14:42.7296362Z Task         : Get sources
2020-04-11T22:14:42.7296684Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-11T22:14:42.7296979Z Version      : 1.0.0
2020-04-11T22:14:42.7297202Z Author       : Microsoft
2020-04-11T22:14:42.7297202Z Author       : Microsoft
2020-04-11T22:14:42.7297530Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-11T22:14:42.7297916Z ==============================================================================
2020-04-11T22:14:43.0219866Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-11T22:14:43.0268423Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/71038/merge to s
2020-04-11T22:14:43.0344174Z Cleaning up task key
2020-04-11T22:14:43.0345304Z Start cleaning up orphan processes.
2020-04-11T22:14:43.0502248Z Terminate orphan process: pid (3640) (python)
2020-04-11T22:14:43.0627939Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

Comment on lines 147 to +159
if !ty_is_partial_eq {
// span_fatal avoids ICE from resolution of non-existent method (rare case).
self.tcx().sess.span_fatal(self.span, &make_msg());
self.tcx().sess.span_fatal(self.span, &msg);
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this stop your ICE as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope. ty_is_partial_eq is true for &dyn PartialEq<u32>. It is fixed for all other traits though.

This fails correctly

const F: &'static dyn Send = &7u32;

fn main() {
    let a: &dyn Send = &7u32;
    match a {
        F => panic!(),
        //~^ ERROR trait object cannot be used in patterns
        _ => {}
    }
}

Copy link
Member

Choose a reason for hiding this comment

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

It is fixed for all other traits though.

Ah I see. I think it's fine to leave dyn PartialEq an ICE (and we can do an ICE test, I think we have another one already). At least that's what this comment makes me think:

// FIXME(oli-obk): this is reachable for `const FOO: &&&u32 = &&&42;` being used

@oli-obk has a PR that should allow fixing this more directly: #70743

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the test to dyn Send and rebased.

Don't know how to test for an ICE, we could just open an issue for dyn PartialEq after this is merged (which is then added to glacier).

@lcnr lcnr force-pushed the dyn_trait_structural_match branch from 460b8c4 to 1c4fc95 Compare April 12, 2020 13:34
@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-04-12T13:35:28.5733873Z ========================== Starting Command Output ===========================
2020-04-12T13:35:28.5738844Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/8c2dd2c2-252a-49d3-9ea1-c9c86631d819.sh
2020-04-12T13:35:28.5739275Z 
2020-04-12T13:35:28.5743367Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-12T13:35:28.5764522Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71038/merge to s
2020-04-12T13:35:28.5768041Z Task         : Get sources
2020-04-12T13:35:28.5768322Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-12T13:35:28.5768589Z Version      : 1.0.0
2020-04-12T13:35:28.5768823Z Author       : Microsoft
---
2020-04-12T13:35:29.6777419Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-12T13:35:29.6788257Z ##[command]git config gc.auto 0
2020-04-12T13:35:29.6795700Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-12T13:35:29.6802209Z ##[command]git config --get-all http.proxy
2020-04-12T13:35:29.6812964Z ##[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/71038/merge:refs/remotes/pull/71038/merge
---
2020-04-12T13:37:41.2734259Z Looks like docker image is the same as before, not uploading
2020-04-12T13:37:46.0382660Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-12T13:37:46.0703030Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-12T13:37:46.0744006Z == clock drift check ==
2020-04-12T13:37:46.0744308Z   local time: Sun Apr 12 13:37:46 UTC 2020
2020-04-12T13:37:46.2333764Z   network time: Sun, 12 Apr 2020 13:37:46 GMT
2020-04-12T13:37:46.2360207Z Starting sccache server...
2020-04-12T13:37:46.3322973Z configure: processing command line
2020-04-12T13:37:46.3323234Z configure: 
2020-04-12T13:37:46.3324266Z configure: rust.dist-src        := False
---
2020-04-12T13:44:15.7497186Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-12T13:44:17.5913874Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-12T13:44:19.5909305Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-12T13:44:22.6067421Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-12T13:44:32.3963790Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-12T13:44:37.3894938Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-12T13:44:43.3351499Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-12T13:44:48.8972614Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-12T13:44:59.3242292Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-12T14:11:34.4436067Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-12T14:11:36.5224840Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-12T14:11:38.8337256Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-12T14:11:41.8824635Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-12T14:11:53.2483963Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-12T14:11:58.4119056Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-12T14:12:04.7079445Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-12T14:12:10.9848824Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-12T14:12:22.9579677Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-12T14:41:17.3500827Z .................................................................................................... 1700/9891
2020-04-12T14:41:22.4367020Z .................................................................................................... 1800/9891
2020-04-12T14:41:32.3786267Z .................................................................................................... 1900/9891
2020-04-12T14:41:41.9208691Z .....i.............................................................................................. 2000/9891
2020-04-12T14:41:49.2648274Z ...............................................................................................iiiii 2100/9891
2020-04-12T14:42:13.5221765Z .................................................................................................... 2300/9891
2020-04-12T14:42:15.8274666Z .................................................................................................... 2400/9891
2020-04-12T14:42:18.2606802Z .................................................................................................... 2500/9891
2020-04-12T14:42:24.3045060Z .................................................................................................... 2600/9891
---
2020-04-12T14:45:42.4435042Z .................................................................................................... 5100/9891
2020-04-12T14:45:51.0192700Z .................................................................................................... 5200/9891
2020-04-12T14:45:56.6674539Z ...............i.................................................................................... 5300/9891
2020-04-12T14:46:07.5024347Z .................................................................................................... 5400/9891
2020-04-12T14:46:13.3080055Z ....ii.ii........i...i.............................................................................. 5500/9891
2020-04-12T14:46:21.7102484Z .................................................i.................................................. 5700/9891
2020-04-12T14:46:33.1420923Z .....................................................................ii............................. 5800/9891
2020-04-12T14:46:40.2934567Z ........i........................................................................................... 5900/9891
2020-04-12T14:46:46.9914017Z .................................................................................................... 6000/9891
2020-04-12T14:46:46.9914017Z .................................................................................................... 6000/9891
2020-04-12T14:46:58.9050696Z .................................................................................................... 6100/9891
2020-04-12T14:47:11.2279536Z ...ii...i..ii...........i........................................................................... 6200/9891
2020-04-12T14:47:28.4343243Z .................................................................................................... 6400/9891
2020-04-12T14:47:35.5462753Z .................................................................................................... 6500/9891
2020-04-12T14:47:35.5462753Z .................................................................................................... 6500/9891
2020-04-12T14:47:52.4747725Z .................................i..ii.............................................................. 6600/9891
2020-04-12T14:48:16.0322763Z .................................................................................................... 6800/9891
2020-04-12T14:48:18.1160349Z .................................i.................................................................. 6900/9891
2020-04-12T14:48:20.4850023Z .................................................................................................... 7000/9891
2020-04-12T14:48:23.0777360Z ........................................................................i........................... 7100/9891
---
2020-04-12T14:50:20.5025724Z .................................................................................................... 7800/9891
2020-04-12T14:50:25.3344568Z .................................................................................................... 7900/9891
2020-04-12T14:50:33.3030798Z .................................................................................................... 8000/9891
2020-04-12T14:50:40.8334143Z .......................................i............................................................ 8100/9891
2020-04-12T14:50:51.8459712Z ......................................................................................iiiiii.iiiii.i 8200/9891
2020-04-12T14:51:10.6473745Z ................................i......i............................................................ 8400/9891
2020-04-12T14:51:14.7777144Z .................................................................................................... 8500/9891
2020-04-12T14:51:27.0907727Z .................................................................................................... 8600/9891
2020-04-12T14:51:42.2101340Z .................................................................................................... 8700/9891
---
2020-04-12T14:53:58.6757205Z 
2020-04-12T14:53:58.6758179Z ---- [ui] ui/const-generics/issues/issue-63322-forbid-dyn.rs stdout ----
2020-04-12T14:53:58.6758876Z diff of stderr:
2020-04-12T14:53:58.6759188Z 
2020-04-12T14:53:58.6759806Z 12 LL | fn test<const T: &'static dyn A>() {
2020-04-12T14:53:58.6761002Z 13    |                  ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
2020-04-12T14:53:58.6762011Z - error: aborting due to previous error
2020-04-12T14:53:58.6762646Z + error: aborting due to previous error; 1 warning emitted
2020-04-12T14:53:58.6763166Z 16 
2020-04-12T14:53:58.6763805Z 17 For more information about this error, try `rustc --explain E0741`.
2020-04-12T14:53:58.6763805Z 17 For more information about this error, try `rustc --explain E0741`.
2020-04-12T14:53:58.6764413Z 18 
2020-04-12T14:53:58.6765336Z 
2020-04-12T14:53:58.6765452Z 
2020-04-12T14:53:58.6765682Z The actual stderr differed from the expected stderr.
2020-04-12T14:53:58.6766728Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-63322-forbid-dyn/issue-63322-forbid-dyn.stderr
2020-04-12T14:53:58.6767463Z To update references, rerun the tests and pass the `--bless` flag
2020-04-12T14:53:58.6768142Z To only update this specific test, also pass `--test-args const-generics/issues/issue-63322-forbid-dyn.rs`
2020-04-12T14:53:58.6768634Z error: 1 errors occurred comparing output.
2020-04-12T14:53:58.6768895Z status: exit code: 1
2020-04-12T14:53:58.6768895Z status: exit code: 1
2020-04-12T14:53:58.6771070Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/issues/issue-63322-forbid-dyn" "-A" "unused" "-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/const-generics/issues/issue-63322-forbid-dyn/auxiliary"
2020-04-12T14:53:58.6773032Z ------------------------------------------
2020-04-12T14:53:58.6773231Z 
2020-04-12T14:53:58.6773605Z ------------------------------------------
2020-04-12T14:53:58.6773813Z stderr:
---
2020-04-12T14:53:58.6776992Z 
2020-04-12T14:53:58.6777257Z error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq`
2020-04-12T14:53:58.6778096Z   --> /checkout/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs:8:18
2020-04-12T14:53:58.6778380Z    |
2020-04-12T14:53:58.6778771Z LL | fn test<const T: &'static dyn A>() {
2020-04-12T14:53:58.6779418Z    |                  ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
2020-04-12T14:53:58.6779934Z error: aborting due to previous error; 1 warning emitted
2020-04-12T14:53:58.6780884Z 
2020-04-12T14:53:58.6781449Z For more information about this error, try `rustc --explain E0741`.
2020-04-12T14:53:58.6781675Z 
---
2020-04-12T14:53:58.6783776Z test result: FAILED. 9829 passed; 1 failed; 61 ignored; 0 measured; 0 filtered out
2020-04-12T14:53:58.6784169Z 
2020-04-12T14:53:58.6788596Z 
2020-04-12T14:53:58.6788824Z 
2020-04-12T14:53:58.6795193Z 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-7/bin/FileCheck" "--nodejs" "/usr/bin/node" "--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" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2020-04-12T14:53:58.6797956Z 
2020-04-12T14:53:58.6798056Z 
2020-04-12T14:53:58.6798876Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
2020-04-12T14:53:58.6799330Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-04-12T14:53:58.6799330Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-04-12T14:53:58.6800559Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-12T14:53:58.6801091Z Build completed unsuccessfully in 1:14:15
2020-04-12T14:53:58.6852313Z == clock drift check ==
2020-04-12T14:53:58.6876979Z   local time: Sun Apr 12 14:53:58 UTC 2020
2020-04-12T14:53:58.9015130Z   network time: Sun, 12 Apr 2020 14:53:58 GMT
2020-04-12T14:53:59.2574757Z 
2020-04-12T14:53:59.2574757Z 
2020-04-12T14:53:59.2652246Z ##[error]Bash exited with code '1'.
2020-04-12T14:53:59.2665775Z ##[section]Finishing: Run build
2020-04-12T14:53:59.2716015Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/71038/merge to s
2020-04-12T14:53:59.2720888Z Task         : Get sources
2020-04-12T14:53:59.2721213Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-12T14:53:59.2721671Z Version      : 1.0.0
2020-04-12T14:53:59.2721888Z Author       : Microsoft
2020-04-12T14:53:59.2721888Z Author       : Microsoft
2020-04-12T14:53:59.2722246Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-12T14:53:59.2722624Z ==============================================================================
2020-04-12T14:53:59.6424063Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-12T14:53:59.6472544Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/71038/merge to s
2020-04-12T14:53:59.6574888Z Cleaning up task key
2020-04-12T14:53:59.6576189Z Start cleaning up orphan processes.
2020-04-12T14:53:59.6796613Z Terminate orphan process: pid (3721) (python)
2020-04-12T14:53:59.6991865Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@lcnr lcnr force-pushed the dyn_trait_structural_match branch from 1c4fc95 to 4549ef5 Compare April 12, 2020 14:57
@joelpalmer joelpalmer added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2020
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 21, 2020
@Dylan-DPC-zz
Copy link

@pnkfelix this is ready for review

impl A for B {}

fn test<const T: &'static dyn A>() {
//~^ ERROR the types of const generic parameters must derive `PartialEq` and `Eq`
Copy link
Member

Choose a reason for hiding this comment

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

The PR seems fine and I'm planning to r+ it, but I wanted to ask about this part:

Do you see the error here as being the absence of PartialEq and Eq, as indicated by the diagnostic? Or is it that any use of dyn A will be broken here?

I personally suspect that, unless we expose a StructuralMatch marker trait (at which point maybe one would be able to do trait A: StructuralMatch {}), the user error here is in the use of dyn A, and therefore the diagnostic message in this case is misleading.

But I'm willing to deal with that in a followup patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure tbh, I think that we should allow something like trait A: StructuralMatch {} in the future.

cc @eddyb i guess

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 28, 2020

📌 Commit 4549ef5 has been approved by pnkfelix

@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 Apr 28, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 28, 2020
…pnkfelix

forbid `dyn Trait` in patterns

Do not allow `&dyn Trait` as a generic const parameters.
This also changes dyn trait in pattern from ICE to error.

closes rust-lang#63322
closes rust-lang#70972

r? @eddyb
@Dylan-DPC-zz
Copy link

failed in rollup

@bors r-

@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 Apr 28, 2020
@lcnr lcnr force-pushed the dyn_trait_structural_match branch from 4549ef5 to ecf574f Compare April 29, 2020 10:02
@lcnr
Copy link
Contributor Author

lcnr commented Apr 29, 2020

fixed

@bors
Copy link
Contributor

bors commented Apr 29, 2020

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

@lcnr lcnr force-pushed the dyn_trait_structural_match branch from ecf574f to 2f5c0f5 Compare April 29, 2020 17:34
@lcnr
Copy link
Contributor Author

lcnr commented May 3, 2020

@pnkfelix This should be ready for merge afaict.

@pnkfelix
Copy link
Member

pnkfelix commented May 4, 2020

@bors r+

@bors
Copy link
Contributor

bors commented May 4, 2020

📌 Commit 2f5c0f5 has been approved by pnkfelix

@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 4, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 4, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#71038 (forbid `dyn Trait` in patterns)
 - rust-lang#71697 (Added MIR constant propagation of Scalars into function call arguments)
 - rust-lang#71773 (doc: misc rustdoc things)
 - rust-lang#71810 (Do not try to find binop method on RHS `TyErr`)
 - rust-lang#71877 (Use f64 in f64 examples)

Failed merges:

r? @ghost
@bors bors merged commit 679431f into rust-lang:master May 4, 2020
@lcnr lcnr deleted the dyn_trait_structural_match branch May 4, 2020 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-const_generics `#![feature(const_generics)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
9 participants