Skip to content

fix: add Serde std feature if needed - #1068

Merged
valenting merged 2 commits into
servo:mainfrom
reneca:fix-serde-dep
Aug 23, 2025
Merged

fix: add Serde std feature if needed#1068
valenting merged 2 commits into
servo:mainfrom
reneca:fix-serde-dep

Conversation

@reneca

@reneca reneca commented Aug 22, 2025

Copy link
Copy Markdown
Contributor

There is an issue introduced by #1033
Serde no longer include std feature that result in an error when using url with serde feature:

error[E0599]: the method `serialize` exists for tuple `(&String, &u32, &u32, &u32, &u32, &HostInternal, &core::option::Option<u16>, &u32, &core::option::Option<u32>, &core::option::Option<u32>)`, but its trait bounds were not satisfied
    --> /Users/jht/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/url-2.5.6/src/lib.rs:2648:14
     |
2636 | /         (
2637 | |             serialization,
2638 | |             scheme_end,
2639 | |             username_end,
...    |
2648 | |             .serialize(serializer)
     | |             -^^^^^^^^^ method cannot be called due to unsatisfied trait bounds
     | |_____________|
     |
     |
     = note: the following trait bounds were not satisfied:
             `&String: Serialize`
             which is required by `(&String, &u32, &u32, &u32, &u32, &HostInternal, &core::option::Option<u16>, &u32, &core::option::Option<u32>, &core::option::Option<u32>): Serialize`

error[E0277]: the trait bound `String: Deserialize<'_>` is not satisfied
    --> /Users/jht/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/url-2.5.6/src/lib.rs:2675:13
     |
2675 |         ) = Deserialize::deserialize(deserializer)?;
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `String`
     |
     = note: for local types consider adding `#[derive(serde::Deserialize)]` to your `String` type
     = note: for types from other crates check whether the crate offers a `serde` feature flag
     = help: the trait `Deserialize<'_>` is not implemented for `String`
             but it is implemented for `&str`
     = help: for that trait implementation, expected `&str`, found `String`
     = note: required for `(String, _, _, _, _, _, _, _, _, _)` to implement `Deserialize<'_>`

This PR solve this by adding the std flag if needed to serde.
I've test it for my project, it work.

@valenting valenting left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you also bump the version to 2.5.7 - also in lib.rs?

@codecov

codecov Bot commented Aug 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@aae60cf). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1068   +/-   ##
=======================================
  Coverage        ?   82.63%           
=======================================
  Files           ?       24           
  Lines           ?     4245           
  Branches        ?        0           
=======================================
  Hits            ?     3508           
  Misses          ?      737           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 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.

@reneca

reneca commented Aug 22, 2025

Copy link
Copy Markdown
Contributor Author

Could you also bump the version to 2.5.7 - also in lib.rs?

I've changed it in url/Cargo.toml, and url/lib.rs
Should be fine.

@reneca
reneca requested a review from valenting August 22, 2025 14:15
@valenting
valenting enabled auto-merge August 23, 2025 12:23
@valenting
valenting added this pull request to the merge queue Aug 23, 2025
Merged via the queue into servo:main with commit 2387efa Aug 23, 2025
18 checks passed
@reneca
reneca deleted the fix-serde-dep branch August 23, 2025 13:44
takumi-earth pushed a commit to earthlings-dev/rust-url that referenced this pull request Jan 27, 2026
* fix: add Serde std feature if needed

* bump the version to 2.5.7
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.

2 participants