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

Add blanket impls to allow the various Fn traits to be interconverted. #18388

Merged
merged 4 commits into from
Nov 6, 2014

Conversation

nikomatsakis
Copy link
Contributor

Add blanket impls to allow the various Fn traits to be interconverted.

Fixes #18387.

impl<F,A,R> FnMut<A,R> for F
where F : Fn<A,R>
{
#[rust_call_abi_hack]
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed? I thought it was only needed until a snapshot landed and could be replaced with extern "rust-call"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luqmana I think you are correct.

@nikomatsakis
Copy link
Contributor Author

Hmm, I still think this approach is right, but it does yield many more inference failures, due to a similar situation as described in #17901. It is likely that using an associated type for the fn return would help here, but I'd prefer not to couple these two features. I'll ponder for a bit if there's a way to improve the situation.

@nikomatsakis
Copy link
Contributor Author

OK, this version of the branch passes tests. It also fixes #17901 along the way, although I think there may be a more comprehensive fix (this version does cause the example there to compile successfully, however).

@nikomatsakis
Copy link
Contributor Author

r? @aturon for these latest changes, since he and I discussed them at a high-level.

…type

variables in the intracrate case. This requires a deeper distinction
between inter- and intra-crate so as to keep coherence working.

I suspect the best fix is to generalize the recursion check that
exists today, but this requires a bit more refactoring to achieve.

(In other words, where today it says OK for an exact match, we'd want
to not detect exact matches but rather skolemize each trait-reference
fresh and return AMBIG -- but that requires us to make builtin bounds
work shallowly like everything else and move the cycle detection into
the fulfillment context.)
bors added a commit that referenced this pull request Nov 6, 2014
Add blanket impls to allow the various `Fn` traits to be interconverted.

Fixes #18387.
@bors bors closed this Nov 6, 2014
@bors bors merged commit cf753a2 into rust-lang:master Nov 6, 2014
@nikomatsakis nikomatsakis deleted the fn-trait-hierarchy branch March 30, 2016 16:13
lnicola added a commit to lnicola/rust that referenced this pull request Oct 29, 2024
Fix checking for `false` `labelDetailsSupport` value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fn trait hierarchy not respected
3 participants