Skip to content

Implement more precise binary op return type heuristic #8457

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

Merged
merged 3 commits into from
Apr 10, 2021

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Apr 10, 2021

Should fix #7150

@Veykril
Copy link
Member Author

Veykril commented Apr 10, 2021

r? @flodiebold

Comment on lines 1939 to 1946
98..99 'g': |u64| -> i32
102..111 '|v| v + 1': |u64| -> i32
98..99 'g': |u64| -> {unknown}
102..111 '|v| v + 1': |u64| -> {unknown}
103..104 'v': u64
106..107 'v': u64
106..111 'v + 1': i32
106..111 'v + 1': {unknown}
110..111 '1': i32
117..118 'g': |u64| -> i32
117..124 'g(1u64)': i32
117..118 'g': |u64| -> {unknown}
117..124 'g(1u64)': {unknown}
Copy link
Member Author

@Veykril Veykril Apr 10, 2021

Choose a reason for hiding this comment

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

This involves a general InferenceVar which results in these not resolving anymore since we can't make assumptions for those as well as not having std's ops implementation in scope in the tests

Copy link
Member

Choose a reason for hiding this comment

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

Hm. Can we add the necessary impls to the test to make this work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, ye should've done that from the start. Resolves with those impls added.

@Veykril Veykril changed the title Implement more precise binary op return type prediction Implement more precise binary op return type heuristic Apr 10, 2021
@flodiebold
Copy link
Member

r=me, though it'd also be nice to add a test for #7150.

@Veykril
Copy link
Member Author

Veykril commented Apr 10, 2021

bors r=flodiebold

@Veykril
Copy link
Member Author

Veykril commented Apr 10, 2021

changelog fix Don't assume wrong binary operator return type when primitives are involved

@bors
Copy link
Contributor

bors bot commented Apr 10, 2021

@bors bors bot merged commit 4bf32ee into rust-lang:master Apr 10, 2021
@Veykril Veykril deleted the bin_op_ret_ty branch April 10, 2021 16:02
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.

Operator overloading type inference Error
2 participants