-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Function pointer docs may need updating #46989
Comments
This probably refers to:
Which is not true as proved by the more simple example below: fn assert_partialeq<T: PartialEq<T>>() {}
fn main() {
assert_partialeq::<fn(&i32)>();
} Rewording the last paragraph so it directs user to see the list of implementations on the relevant traits’ pages should suffice as a fix. |
Wait... So it's just that eg.
I find the lists... less than useful. It's impossible to find anything there, really, and if you do, it doesn't help you understand why |
Agreed; as a newcomer, it's not obvious why this is the case. (read: I still don't know why this is case…) If it's possible to write such a |
Triage: something changed here, but I don't know what. @nagisa's example compiles on beta. |
Related #45048 |
I doubt #55986 is related. @rust-lang/wg-traits might know which PR it was. |
@nikomatsakis said that somebody has been flxing a problem with |
Only #55517 seems plausible, IMO. |
Confirmed with rustup-toolchain-install-master |
I tried to test something like |
I tried reading PR #55517 but I have no clue what it does. Can someone (@eddyb @nikomatsakis @scalexm ?) elaborate and also say whether the resulting change to the behavior observed here was intentional? We have about 3 weeks to revert the behavior from beta before it becomes stable. |
ping @eddyb @nikomatsakis @scalexm |
Re-implement leak check in terms of universes This PR temporarily restores the leak-check, but implemented in terms of universes. This is not because the leak check behavior was necessarily **correct**, but because (a) we may want to have a transition period and because (b) we want to have more breathing room to work through the full implications of handling higher-ranked types correctly. Note that this PR builds atop #58056. Fixes #58451 Fixes #46989 Fixes #57639 r? @aturon cc @arielb1, @lqd ~~Temporary note: I've not finished running `./x.py test` locally -- I'm confident a lot of error messages in tests will need updating. I sort of expect them to revert to the older, (imo) less good error messages, which is mildly unfortunate. There might be a way to preserve the new error messages, not sure.~~
removing E-needstest since #58592 implies it is no longer implicitly working, at least for now... |
triage: P-high. Reasoning: the fallout that came out of universes (where said fallout has been undone by the re-introduction of a leak-check) implies to me that this is P-high. Removing nomination label since this is now prioritized and assigned (@aturon volunteered) |
note: blocks #59490 |
triage: re-prioritizing as P-medium. The investigation of fallout described here still needs to happen, but its not sufficiently pressing to warrant P-high label. |
I just want to compare two |
@jesskfullwood You can just cast them safely, e.g.: |
(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.
I believe this will be fixed by #108080. See #108080 (comment) |
We may need documentation updated for function pointers when used in enums. I won't pretend I understand half of what's written here, but here's the log from IRC (#rust_beginners) where we debugged this issue:
Sharlin
)spear2
)The text was updated successfully, but these errors were encountered: