Skip to content

Handle coercion on binary operator RHS #9973

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 1 commit into from
Aug 21, 2021
Merged

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Aug 21, 2021

Closes #9968
CC #8961

@lnicola
Copy link
Member Author

lnicola commented Aug 21, 2021

r? @flodiebold

@lnicola
Copy link
Member Author

lnicola commented Aug 21, 2021

Hmm, this doesn't fully fix #9971. We still don't normalize the output type in String::new() + &String::new(), but the type error is gone.

@flodiebold
Copy link
Member

The problem is that we only do the trait resolution at the end, but we need to do it before checking the right-hand side (with a variable in place of the RHS type). For String, that will tell us that the RHS type has to be &str.

@flodiebold
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 21, 2021

@bors bors bot merged commit 337ccc7 into rust-lang:master Aug 21, 2021
@lnicola lnicola deleted the binop-coercion branch August 21, 2021 16:24
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.

Type mismatch with deref and reseating references
2 participants