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

Integer type variable gets lost during trait solving #4072

Closed
flodiebold opened this issue Apr 21, 2020 · 3 comments · Fixed by #4652
Closed

Integer type variable gets lost during trait solving #4072

flodiebold opened this issue Apr 21, 2020 · 3 comments · Fixed by #4652
Labels
A-ty type system / type inference / traits / method resolution

Comments

@flodiebold
Copy link
Member

2020-04-21-132741_1013x192_scrot

Somehow in the first case, the type variable seems to get 'disconnected' in the chain, whereas it works for a concrete type or a normal type variable 🤔

@flodiebold flodiebold added the A-ty type system / type inference / traits / method resolution label Apr 22, 2020
@adamrk
Copy link
Contributor

adamrk commented May 1, 2020

I'm not seeing the this issue, but I do see the one from #4132 (on commit 9230ae5):
image

@flodiebold
Copy link
Member Author

flodiebold commented May 2, 2020

The original problem indeed seems to have fixed itself, which is interesting -- I have no idea what might have done that.

The problem with ranges is a variation of rust-lang/chalk#327, I think: Since we haven't fallen back to i32 yet when we're checking the from_iter call, we basically ask Chalk "does Range<?0> implement Iterator, and what's the type of Iterator::Item?" The problem is, Range<T> only implements Iterator for T: Step. So the answer from Chalk is "maybe, but no idea what the item type is", because it doesn't know that the impl applies. Whereas rustc can see here that because ?0 has to be some kind of integer, regardless of which one it is, it'll implement Step and so the impl<A: Step> Iterator for Range<A> applies. At least, I think that's how rustc figures it out. (Alternatively, maybe it just reasons that that impl is the only one that could apply anyway, so at least the item type has to be ?0. I.e. Chalk could be better at giving guidance even if the result is ambiguous.)

Edit: Actually yeah, it's the second option, since rustc also figures it out when the type variable is a general type variable.

@JohnWall2016
Copy link

There're some same problems about the range literals:
屏幕快照 2020-05-03 下午3 08 34

bors bot added a commit that referenced this issue May 29, 2020
4652: Upgrade Chalk r=kjeremy a=flodiebold

Fixes #4072.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
@bors bors bot closed this as completed in ab28f6c May 29, 2020
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Jan 7, 2025
Implement blocking unnamed_socket
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.

3 participants