Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upunable to build doge API! #25684
unable to build doge API! #25684
Comments
|
Few corrections that should remove most of the errors:
|
|
Hey! those inputs were really helpful, but I am still getting these errors: shrey@LAPTOP-L08HN83K MINGW64 /c/Users/shrey/servo (master) Completed script v0.0.1 custom-build (run) in 15.9s error[E0277]: the trait bound error[E0277]: the trait bound error[E0277]: the trait bound error: aborting due to 4 previous errors For more information about this error, try To learn more, run the command again with --verbose. |
|
Ah, I missed that. You forgot to import dom_struct ( |
|
made these changes as well, thank you. But still facing 2 more errors: shrey@LAPTOP-L08HN83K MINGW64 /c/Users/shrey/servo (master) Completed script v0.0.1 custom-build (run) in 7.0s error[E0053]: method error: aborting due to 2 previous errors Some errors have detailed explanations: E0053, E0433. To learn more, run the command again with --verbose. |
|
In the new function, the first argument should be |
|
Build completed, thank you so much for your help!! |
|
I'll update the original instructions to incorporate the appropriate code changes. Thanks for asking these questions @shreyarastogi, and thanks for answering them @kunalmohan! |
I am trying to implement the doge API and this is the code that I am implementing:
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::DogeBinding::{DogeMethods, DogeInit, Wrap as DogeWrap};
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::GlobalScope;
use crate::dom::bindings::root;
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
use crate::dom::bindings::str::DOMString;
use crate::rand;
use crate::rand::Rng;
extern crate rand;
#[dom_struct]
pub struct Doge {
reflector_: Reflector,
such_list: DOMRefCell<Vec>,
}
impl Doge{
pub fn new_inherited() -> Doge {
Doge {
reflector_: Reflector::new(),
such_list: DomRefCell::new(vec![]),
}
}
pub fn new(global: &GlobalScope) -> Root {
reflect_dom_object(Box::Doge::new_inherited(), global, DogeWrap)
}
// https://jeenalee.github.io/doge-standard/#dom-doge
pub fn Constructor(global: &GlobalScope, init: Option) -> Fallible<Root> {
// Step 1
let doge = Doge::new(global);
// Step 2
if let Some(i) = init {
for word in i {
doge.Append(word);
}
}
// Step 3
Ok(doge)
}
}
impl DogeMethods for Doge{
// https://jeenalee.github.io/doge-standard/#dom-doge-append
fn Append(&self, word: DOMString) -> () {
self.such_list.borrow_mut().push(word);
}
fn Random(&self) -> Fallible {
// Step 1
let list = self.such_list.borrow();
// Step 2
if list.len() == 0 {
return Err(Error::Type("Such list is empty".to_string()));
} else {
// Step 3
let random_index = servo_rand::thread_rng().gen_range(0, list.len());
return Ok(list[random_index].clone());
}
}
}
These are the errors that I am facing:
$ ./mach build --dev
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Blocking waiting for file lock on package cache
Compiling script v0.0.1 (C:\Users\shrey\servo\components\script)
warning: Error finalizing incremental compilation session directory
\\?\C:\Users\shrey\servo\target\debug\incremental\canvas_traits-aj1987kq9sua\s-fkbu5d627i-159yjr0-working: Access is denied. (os error 5)Completed script v0.0.1 custom-build (run) in 13.6s
error[E0432]: unresolved import
crate::dom::bindings::GlobalScope--> components\script\dom\doge.rs:4:5
|
4 | use crate::dom::bindings::GlobalScope;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no
GlobalScopeindom::bindingserror[E0432]: unresolved import
crate::rand--> components\script\dom\doge.rs:8:5
|
8 | use crate::rand;
| ^^^^^^^^^^^ no
randin the rooterror[E0432]: unresolved import
crate::rand--> components\script\dom\doge.rs:9:12
|
9 | use crate::rand::Rng;
| ^^^^
| |
| unresolved import
| help: a similar path exists:
crate::dom::doge::randerror: cannot find attribute
dom_structin this scope--> components\script\dom\doge.rs:12:3
|
12 | #[dom_struct]
| ^^^^^^^^^^
error[E0412]: cannot find type
DOMRefCellin this scope--> components\script\dom\doge.rs:15:16
|
15 | such_list: DOMRefCell<Vec>,
| ^^^^^^^^^^ help: a struct with a similar name exists:
DomRefCell|
::: components\script\dom\bindings\cell.rs:21:1
|
21 | / pub struct DomRefCell {
22 | | value: RefCell,
23 | | }
| |_- similarly named struct
DomRefCelldefined hereerror[E0412]: cannot find type
Rootin this scope--> components\script\dom\doge.rs:27:37
|
27 | pub fn new(global: &GlobalScope) -> Root {
| ^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
1 | use crate::dom::bindings::root::Root;
|
error[E0412]: cannot find type
Rootin this scope--> components\script\dom\doge.rs:32:78
|
32 | pub fn Constructor(global: &GlobalScope, init: Option) -> Fallible<Root> {
| ^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
1 | use crate::dom::bindings::root::Root;
|
warning: unused import:
crate::dom::bindings::root--> components\script\dom\doge.rs:5:5
|
5 | use crate::dom::bindings::root;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note:
#[warn(unused_imports)]on by defaulterror[E0277]: the trait bound
dom::doge::Doge: dom::bindings::reflector::DomObjectis not satisfied--> C:\Users\shrey\servo\target\debug\build\script-0fc8d3571dfd85fa\out/Bindings\DogeBinding.rs:666:1
|
666 | / pub unsafe fn Wrap(cx: SafeJSContext, scope: &GlobalScope, object: Box) -> DomRoot {
667 | | let scope = scope.reflector().get_jsobject();
668 | | assert!(!scope.get().is_null());
669 | | assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
... |
689 | | DomRoot::from_ref(&*raw)
690 | | }
| |_^ the trait
dom::bindings::reflector::DomObjectis not implemented fordom::doge::Doge|
::: components\script\dom\bindings\root.rs:50:1
|
50 | pub struct Root<T: StableTraceObject> {
| ------------------------------------- required by
dom::bindings::root::Root|
= note: required because of the requirements on the impl of
dom::bindings::root::StableTraceObjectfordom::bindings::root::Dom<dom::doge::Doge>error: aborting due to 8 previous errors
Some errors have detailed explanations: E0277, E0412, E0432.
For more information about an error, try
rustc --explain E0277.error: could not compile
script.To learn more, run the command again with --verbose.
Build FAILED in 0:01:26
Made some changes in the original code that has been provided in the guide. Still these errors persist. What more changes should I do?