Uh oh!
There was an error while loading. Please reload this page.
forbid dyn Trait in patterns - #71038
Conversation
21185be to
b373917CompareIMO this PR's title/description should focus on pattern-matching. r? @pnkfelix |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
rust-highfive
commented
Apr 11, 2020
The job Click to expand the log.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 |
There was a problem hiding this comment.
Doesn't this stop your ICE as well?
There was a problem hiding this comment.
nope. ty_is_partial_eq is true for &dyn PartialEq<u32>. It is fixed for all other traits though.
This fails correctly
constF:&'staticdynSend = &7u32;fnmain(){let a:&dynSend = &7u32;match a {F => panic!(),//~^ ERROR trait object cannot be used in patterns
_ => {}}}There was a problem hiding this comment.
There was a problem hiding this comment.
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).
460b8c4 to
1c4fc95Comparerust-highfive
commented
Apr 12, 2020
The job Click to expand the log.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 |
1c4fc95 to
4549ef5CompareDylan-DPC-zz
commented
Apr 21, 2020
@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` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Not sure tbh, I think that we should allow something like trait A: StructuralMatch {} in the future.
cc @eddyb i guess
pnkfelix
commented
Apr 28, 2020
@bors r+ rollup |
bors
commented
Apr 28, 2020
📌 Commit 4549ef5 has been approved by |
…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. closesrust-lang#63322closesrust-lang#70972 r? @eddyb
Dylan-DPC-zz
commented
Apr 28, 2020
failed in rollup @bors r- |
4549ef5 to
ecf574fComparelcnr
commented
Apr 29, 2020
fixed |
bors
commented
Apr 29, 2020
☔ The latest upstream changes (presumably #67343) made this pull request unmergeable. Please resolve the merge conflicts. |
ecf574f to
2f5c0f5Comparelcnr
commented
May 3, 2020
@pnkfelix This should be ready for merge afaict. |
pnkfelix
commented
May 4, 2020
@bors r+ |
bors
commented
May 4, 2020
📌 Commit 2f5c0f5 has been approved by |
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
Uh oh!
There was an error while loading. Please reload this page.
Do not allow
&dyn Traitas a generic const parameters.This also changes dyn trait in pattern from ICE to error.
closes#63322
closes#70972
r? @eddyb