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

Function trait objects output is not normalized #5057

Closed
smmalis37 opened this issue Jun 25, 2020 · 6 comments · Fixed by #5319
Closed

Function trait objects output is not normalized #5057

smmalis37 opened this issue Jun 25, 2020 · 6 comments · Fixed by #5319
Labels
A-ty type system / type inference / traits / method resolution

Comments

@smmalis37
Copy link

smmalis37 commented Jun 25, 2020

Normally when I use the ? operator, type inference is able to correctly see through it and mark variables with the Ok type of the Result. This seems to fall apart when used on a ref to a function trait object:
image

I would expect the type of r to be u8.

@smmalis37 smmalis37 changed the title Combining function refs with ? breaks type inference Combining function trait objects with ? breaks type inference Jun 25, 2020
@flodiebold flodiebold added the A-ty type system / type inference / traits / method resolution label Jun 25, 2020
@lnicola
Copy link
Member

lnicola commented Jun 25, 2020

Duplicate of #4281?

@flodiebold
Copy link
Member

flodiebold commented Jun 25, 2020

I assume the problem is simply inferring the result of f(), nothing related to the ? operator. It was mentioned in #4958, but I don't think we have a bug for it yet.

@lnicola no, that one's about the Fn impl being missing for function defs; this one is about normalizing <dyn FnOnce() -> T as FnOnce>::Output, which looks like it should work without problems; I'm not sure what's happening there. (Thinking about it, one theory might be that Chalk does all the well-known trait handling when encountering this goal and 'forgets' to generate the clauses from the dyn bounds... Another theory is that we're doing something wrong while lowering that type, which is also very possible.)

@smmalis37
Copy link
Author

Ah, yeah this happens without ?. I was confused because I have other code that correctly normalizes Fn output, but what I didn't realize that that's on a generic over Fn, not a trait object. This seems to be something specific to trait object Fns.

@smmalis37 smmalis37 changed the title Combining function trait objects with ? breaks type inference Function trait objects output is not normalized Jun 25, 2020
@smmalis37
Copy link
Author

@cynecx
Copy link
Contributor

cynecx commented Jun 30, 2020

@smmalis37 Nope. I just checked, afaics it's still "broken".

@flodiebold
Copy link
Member

flodiebold commented Jul 10, 2020

It seems that's a bug in Chalk: rust-lang/chalk#567. (It was even simpler than my first theory -- any associated type bounds in dyn traits have this problem.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants