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

trait js::conversions::ToJSValConvertible: core::marker::Sized not satisfied #13465

Closed
malisas opened this issue Sep 27, 2016 · 6 comments
Closed
Labels
A-content/dom Interacting with the DOM from web content I-papercut Small but painful.

Comments

@malisas
Copy link
Contributor

malisas commented Sep 27, 2016

The compiler produces the following error:

error[E0277]: the trait bound `js::conversions::ToJSValConvertible: core::marker::Sized` is not satisfied
  --> /home/malisa/git_repos/malisa-servo/servo/components/script/body.rs:71:21
   |
71 |             promise.resolve_native(promise.global().r().get_cx(), val);
   |                     ^^^^^^^^^^^^^^ trait `js::conversions::ToJSValConvertible: core::marker::Sized` not satisfied
   |
   = note: `js::conversions::ToJSValConvertible` does not have a constant size known at compile-time

when I try to compile this code:

let val: &ToJSValConvertible = match r {
    FetchedData::Text(s) => &USVString(s),
    FetchedData::Json(ref j) => j,
    FetchedData::BlobData(ref b) => b,
    FetchedData::FormData(ref f) => f,
};
promise.resolve_native(promise.global().r().get_cx(), val);
@jdm jdm added the A-content/dom Interacting with the DOM from web content label Sep 27, 2016
@jdm
Copy link
Member

jdm commented Sep 27, 2016

The problem is that resolve_native takes a generic value bounded by ToJSValConvertible, and instead of passing a concrete type to it we're trying to pass a trait object. I'm not sure if there's a way to get the ergonomic code we want (eg. the snippet) in the previous comment without creating a new method on Promise that accepts an &ToJSValConvertible argument instead.

@jdm jdm added the I-papercut Small but painful. label Sep 27, 2016
@nox
Copy link
Contributor

nox commented Nov 29, 2016

Can't we just implement ToJSValConvertible for &ToJSValConvertible? https://play.rust-lang.org/?gist=aabe46af9b3ba6b7138b3acc5c66d6f5&version=stable&backtrace=1

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 30, 2016

It's certainly possible, but would probably involve a virtual call... Might still be worth it.

@nox
Copy link
Contributor

nox commented Oct 5, 2017

We can just make ToJSValConvertible be ?Sized if we really want to be able to support trait objects, no?

@nox
Copy link
Contributor

nox commented Oct 5, 2017

Should this issue be closed? Not sure how it's actionable.

@jdm
Copy link
Member

jdm commented Oct 5, 2017

Yeah, no pressing need to fix this.

@jdm jdm closed this as completed Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/dom Interacting with the DOM from web content I-papercut Small but painful.
Projects
None yet
Development

No branches or pull requests

4 participants