fix(str): import alloc::borrow::ToOwned in no_std + alloc builds#1280
Merged
Benoît Cortier (CBenoit) merged 1 commit intoMay 18, 2026
Conversation
ironrdp-str's prefixed and unframed modules call .to_owned() on &str
in their From<&str> impls. In std builds the std prelude brings ToOwned
into scope automatically, but the alloc prelude does not — so the calls
fail with E0599 when the crate is compiled with
--no-default-features --features alloc.
Adds `#[cfg(not(feature = "std"))] use alloc::borrow::ToOwned;` to both
files, matching the existing pattern that gates the
`use alloc::{string::String, vec::Vec}` imports on the same cfg.
cargo check -p ironrdp-str
cargo check -p ironrdp-str --features std
cargo check -p ironrdp-str --no-default-features --features alloc
cargo check -p ironrdp-str --no-default-features
All four feature combinations now compile cleanly.
Benoît Cortier (CBenoit)
approved these changes
May 18, 2026
Member
Benoît Cortier (CBenoit)
left a comment
There was a problem hiding this comment.
Thanks! LGTM!
fa78084
into
Devolutions:master
10 checks passed
This was referenced May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the no_std + alloc compile failure in
ironrdp-strflagged asCategory A of the workspace feature-matrix scan in #1123
(#1123 (comment)).
Approach
ironrdp-str/src/prefixed.rsandironrdp-str/src/unframed.rsbothdefine
impl From<&str>blocks that calls.to_owned()to lift theborrowed string into an owned representation.
.to_owned()is a methodfrom the
alloc::borrow::ToOwnedtrait. In std builds the std preludebrings
ToOwnedinto scope automatically; the alloc prelude does not.With
--no-default-features --features allocthe call sites fail withE0599: no method named 'to_owned' found for reference '&str' in the current scope.Adds:
to both files, matching the existing pattern that gates the
use alloc::{string::String, vec::Vec};imports on the same cfg.lib.rsalready gates these modules behind#[cfg(feature = "alloc")],so
allocis guaranteed available wherever the import compiles.Verification
cargo check -p ironrdp-str— greencargo check -p ironrdp-str --features std— greencargo check -p ironrdp-str --no-default-features --features alloc— green (was failing before)cargo check -p ironrdp-str --no-default-features— greencargo xtask check fmt -v— greencargo xtask check lints -v— greencargo xtask check tests -v— greencargo xtask check typos -v— greenReferences
arbitrary(std/no_std) #1123 Category A: CI: compile/test a feature matrix includingarbitrary(std/no_std) #1123 (comment)