Skip to content

regression: error[E0119]: conflicting implementations of trait AsStr for type String #134708

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
cuviper opened this issue Dec 23, 2024 · 3 comments
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Milestone

Comments

@cuviper
Copy link
Member

cuviper commented Dec 23, 2024

[INFO] [stdout] error[E0119]: conflicting implementations of trait `AsStr` for type `String`
[INFO] [stdout]  --> examples/basic.rs:3:1
[INFO] [stdout]   |
[INFO] [stdout] 3 | #[delegate]
[INFO] [stdout]   | ^^^^^^^^^^^ conflicting implementation for `String`
[INFO] [stdout] ...
[INFO] [stdout] 8 | impl AsStr for String {
[INFO] [stdout]   | --------------------- first implementation here
[INFO] [stdout]   |
[INFO] [stdout]   = note: upstream crates may add a new impl of trait `temporary_enum_delegate_0_3_0::__macros::Convert` for type `std::string::String` in future versions
[INFO] [stdout]   = note: upstream crates may add a new impl of trait `temporary_enum_delegate_0_3_0::__macros::Bound<259758991428806249286467916654556560740, 268186603860731246084428674422145461480, 3, 1>` for type `std::string::String` in future versions
[INFO] [stdout]   = note: this error originates in the attribute macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info)
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] For more information about this error, try `rustc --explain E0119`.
[INFO] [stdout] 
[INFO] [stderr] error: could not compile `temporary_enum_delegate_0_3_0` (example "basic") due to 1 previous error

Version it worked on

It most recently worked on: 1.83.0

Version with regression

Using rustc 1.84.0-beta.4 in crater #134138.

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

@cuviper cuviper added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Dec 23, 2024
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-untriaged Untriaged performance or correctness regression. labels Dec 23, 2024
@compiler-errors
Copy link
Member

compiler-errors commented Dec 23, 2024

@lcnr: do you remember if this is known breakage from #130654? This seems coherence related 🤔

@lcnr
Copy link
Contributor

lcnr commented Dec 23, 2024

looking at the expansion, this feels like it's #114061

trait AsStr {}
impl<D> AsStr for D
where
    D: upstream::Convert + upstream::Bound<{ AsStr.0 }, { AsStr.1 }, { AsStr.2 }, { AsStr.3 }>,
    <D as upstream::Convert>::Owned: AsStr__DelegateOwned,
    for<'d> <D as upstream::Convert>::Ref<'d>: AsStr__DelegateRef<'d>,
    for<'d> <D as upstream::Convert>::RefMut<'d>: AsStr__DelegateRefMut<'d>,
{
}

impl AsStr for std::string::String {}

std::string::String: upstream::Convert fails the is_knowable check and should do so. This means that all these trait bounds have an unknown type as the self-type and have to be ambiguous. After-all, upstream could implement String: Convert with arbitrary associated types.

@cuviper cuviper added this to the 1.84.0 milestone Dec 24, 2024
@cuviper cuviper changed the title regression: conflicting implementations of trait AsStr for type String regression: error[E0119]: conflicting implementations of trait AsStr for type String Dec 24, 2024
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue. labels Dec 24, 2024
@Mark-Simulacrum
Copy link
Member

Closing as a known and relnotes'd soundness fix.

@Mark-Simulacrum Mark-Simulacrum closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@jieyouxu jieyouxu removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 3, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants