-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Presence of Add impl for unrelated type prevents compilation #77143
Comments
This seems like expected behavior |
I'm confused -- why would |
Because the trait system then has two impls available to select from, |
Hmm, okay. So I guess this is a duplicate for #44619. |
@jonas-schievink It doesn't compile even if a mod x {
struct FakeString {}
impl std::ops::Add<FakeString> for String {
type Output = Self;
fn add(mut self, rhs: FakeString) -> Self::Output {
unreachable!()
}
}
}
mod y {
pub fn hw() {
println!("{}", "Hello".to_string() + &(" World".to_string()));
}
} |
Yeah, that doesn't affect trait selection to my knowledge |
Is there a workaround for this issue, short of removing the offending Add implementations? (as they can be in dependencies. e.g: I'm unable to add prometheus_client, as it breaks other code in the project) |
They interact with builtin implementation in confusing ways: rust-lang/rust#77143 Fixes prometheus#68
They interact with builtin implementation in confusing ways: rust-lang/rust#77143 Fixes prometheus#68 Signed-off-by: Benedek Thaler <[email protected]>
They interact with builtin implementation in confusing ways: rust-lang/rust#77143 Fixes prometheus#68 Signed-off-by: Benedek Thaler <[email protected]>
They conflict with builtin implementations, see rust-lang/rust#77143 Signed-off-by: Benedek Thaler <[email protected]>
They conflict with builtin implementations, see rust-lang/rust#77143 Signed-off-by: Benedek Thaler <[email protected]> Signed-off-by: ackintosh <[email protected]>
Simplified version of bodil/smartstring#7.
I tried this code:
I expected to see this happen: this should compile correctly.
Instead, it fails like this:
Removing the
Add
impl makes it work.Meta
This is on current stable, 1.46.0.
The text was updated successfully, but these errors were encountered: