Skip to content
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

Fix a compile error in derive(Deserialize) with no_std + alloc #1543

Merged
merged 1 commit into from May 31, 2019
Merged

Fix a compile error in derive(Deserialize) with no_std + alloc #1543

merged 1 commit into from May 31, 2019

Conversation

jplatte
Copy link
Contributor

@jplatte jplatte commented May 31, 2019

The fact that the existing no_std test suite only runs on Nightly (why is it a binary crate instead of a library crate?) and that there seems to be no test suite for the alloc feature at all makes me uncertain on how to add a test for this, but I'm happy to add it after being told where / how. This is it, anyway:

#![no_std]

use serde::Deserialize;

#[derive(Deserialize)]
struct Foo;

#[derive(Deserialize)]
struct Bar {
    #[serde(flatten)]
    foo: Foo,
}

Without this PR, it fails with this:

error[E0599]: no method named `to_string` found for type `&str` in the current scope
 --> src/lib.rs:8:10
  |
8 | #[derive(Deserialize)]
  |          ^^^^^^^^^^^
  |
  = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
  |
3 | use alloc::string::ToString;

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay dtolnay merged commit 0a3eeab into serde-rs:master May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants