Skip to content

fix: avoid associated type projection in modifier! From impl#784

Closed
xlfish233 wants to merge 1 commit into
time-rs:mainfrom
xlfish233:fix/coherence-e0119
Closed

fix: avoid associated type projection in modifier! From impl#784
xlfish233 wants to merge 1 commit into
time-rs:mainfrom
xlfish233:fix/coherence-e0119

Conversation

@xlfish233

Copy link
Copy Markdown

The modifier! macro generates From<> using the associated type projection ::Type, which confuses the new trait solver (next-solver=coherence, default since Rust 1.84) during coherence checking. The solver cannot normalize the projection, causing false positive E0119 conflicts with blanket From impls in downstream crates.

Replace the projection with the concrete type via target_ty!, which the macro already uses for ModifierValue::Type. The generated code is identical, but avoids the opaque projection.

The modifier! macro generates From<> using the associated type
projection <ModifierValue>::Type, which confuses the new trait solver
(next-solver=coherence, default since Rust 1.84) during coherence
checking. The solver cannot normalize the projection, causing false
positive E0119 conflicts with blanket From<T> impls in downstream
crates.

Replace the projection with the concrete type via target_ty!, which
the macro already uses for ModifierValue::Type. The generated code
is identical, but avoids the opaque projection.
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.4%. Comparing base (5d8737c) to head (d4fc873).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #784   +/-   ##
=====================================
  Coverage   88.4%   88.4%           
=====================================
  Files         99      99           
  Lines      13079   13079           
=====================================
+ Hits       11556   11559    +3     
+ Misses      1523    1520    -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xlfish233

Copy link
Copy Markdown
Author

error spot at like: Checking cookie v0.18.1
Checking tracing-subscriber v0.3.23
error[E0119]: conflicting implementations of trait From<format_description::parse::format_item::HourBase> for type <format_description::parse::format_item::HourBase as format_description::parse::format_item::ModifierValue>::Type
--> /home/pgrx/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cookie-0.18.1/src/expiration.rs:129:1
|
129 | impl<T: Into<Option>> From for Expiration {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate time:
- impl From<format_description::parse::format_item::HourBase> for <format_description::parse::format_item::HourBase as format_description::parse::format_item::ModifierValue>::Type;
= note: upstream crates may add a new impl of trait std::convert::Into<std::option::Option<time::OffsetDateTime>> for type time::format_description::parse::format_item::HourBase in future versions

For more information about this error, try rustc --explain E0119.
error: could not compile cookie (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error[E0119]: conflicting implementations of trait From<format_description::parse::format_item::HourBase> for type <format_description::parse::format_item::HourBase as format_description::parse::format_item::ModifierValue>::Type
--> /home/pgrx/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.23/src/filter/env/mod.rs:759:1
|
759 | / impl From for EnvFilter
760 | | where
761 | | S: AsRef,
| |__________________^
|
= note: conflicting implementation in crate time:
- impl From<format_description::parse::format_item::HourBase> for <format_description::parse::format_item::HourBase as format_description::parse::format_item::ModifierValue>::Type;
= note: upstream crates may add a new impl of trait core::convert::AsRef<str> for type time::format_description::parse::format_item::HourBase in future versions

error: could not compile tracing-subscriber (lib) due to 1 previous error

@xlfish233

Copy link
Copy Markdown
Author

"This change has no effect on time's behavior, but resolves false-positive E0119 compilation errors in downstream crates like cookie, tracing-subscriber,and salvo_core."

@devalain

Copy link
Copy Markdown

Works for me. Added

[patch.crates-io]
time = { git = "https://github.com/xlfish233/time-fix.git", branch = "fix/coherence-e0119" }

in my Cargo.toml to test your PR.

anthrotype added a commit to googlefonts/fontc that referenced this pull request Jun 12, 2026
time 0.3.48 added an impl that trips rustc's coherence check (E0119) against any
crate carrying a blanket `From` impl. fea-rs's `impl<T: Into<GlyphName>>
From<T> for GlyphIdent` is among them, and this breaks the cargo doc and clippy
CI jobs under --all-features (time reaches fea-rs via plist -> norad).

Pin time to =0.3.47 in the workspace until the upstream fix
(time-rs/time#784) ships in 0.3.49.

See time-rs/time#783.
@mkrasnitski

Copy link
Copy Markdown

Just as a note, I tested with -Znext-solver=no and still run into the same breakage, so the new trait solver may not be at fault.

blackbeam added a commit to blackbeam/rust_mysql_common that referenced this pull request Jun 12, 2026
…3e8b1250634072cab

Partially revert `58879b2` (see time-rs/time#784)
@xlfish233

Copy link
Copy Markdown
Author

Just as a note, I tested with -Znext-solver=no and still run into the same breakage, so the new trait solver may not be at fault.

Could you give me more context of failure env, for current context i can't figure the root cause of your breakge.

grishasobol added a commit to gear-tech/gear that referenced this pull request Jun 12, 2026
…file

Keep the smoke test on fresh crates.io resolution (it doubles as an
ecosystem canary for cargo-gbuild users) and substitute the broken
time 0.3.48 with the rev-pinned branch of time-rs/time#784 until the
fix is released.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
pull Bot pushed a commit to imotai/rust_mysql_common that referenced this pull request Jun 12, 2026
@xlfish233

Copy link
Copy Markdown
Author

Just as a note, I tested with -Znext-solver=no and still run into the same breakage, so the new trait solver may not be at fault.

Thank for the note,i confirmed it actually not the root casue.

And i found diff between 0.3.47 and 0.3.48.

Actually author just changed :

  impl From<$name> for target_ty!($name $($target_ty)?) {

0.3.48 (broken):

  impl From<$name> for <$name as ModifierValue>::Type {

@jhpratt

jhpratt commented Jun 13, 2026

Copy link
Copy Markdown
Member

I merged #786 as that also changes time-macros, just in case.

@jhpratt jhpratt closed this Jun 13, 2026
anthrotype added a commit to googlefonts/fontc that referenced this pull request Jun 22, 2026
time 0.3.49 shipped the upstream fix for the 0.3.48 coherence regression
(time-rs/time#784), so the equality pin is no longer needed. Drops both the
workspace pin and the fontc shim that only existed to make it bite.

Verified cargo doc --workspace --all-features (the CI job that broke) is
clean with time 0.3.51.

Fixes #2042.
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.

4 participants