I found my error. It's a classical problem.
TestStruct2 implement the trait `extra::serialize::Encodable` using the generated impl by the compiler.
I didn't declare : use extra::serialize::Encodable;
So the compiler doesn't find it and declare the problem at the implementation. It's the same problem when you work with different file and the trait is implemented in one file and use in another. Usually I found the error but I was confused with other errors and the message wasn't clear. Is it possible to change the message by for example in this case trait `extra::serialize::Encodable` not found for encode,
or to add all `use` needed when using a type and its implementation.

Philippe

Le 05/12/2013 10:53, Philippe Delrieu a écrit :
Thank you it correct my first problems.

I didn't send code because I thought it has the same cause. For the last problems the code is :

use extra::serialize;
use extra::json::{Json, Decoder, ToJson, Object, Encoder, Decoder};
use extra::treemap::TreeMap;
use std::io::Decorator;

//second struct with manually implemented  Decodable, Encodable
#[deriving(Decodable, Encodable, Eq)]
pub struct TestStruct2    {
    dataInt: u8,
    dataStr:~str,
    dataArray:~[u8],
}

let test3 : TestStruct2 = TestStruct2 {dataInt: 1, dataStr:~"toto", dataArray:~[2,3,4,5]}; //{\"dataArray\":[2,3,4,5],\"dataInt\":1,\"dataStr\":\"toto\"}
    let mut m3 = MemWriter::new();
    {
        let mut encoder3 =Encoder::init(&mut m3 as &mut Writer);
        test3.encode(&mut encoder3);
    }

Rustc result :
test_json.rs:292:8: 292:36 error: type `TestStruct2` does not implement any method in scope named `encode`
test/test_json.rs:292         test3.encode(&mut encoder3);

Philippe



Le 05/12/2013 09:56, Kevin Ballard a écrit :
`do` no longer works with stack closures. It now only works with the new proc() type, which basically means you're only going to see it used with spawn().

You need to now say something like

     let rc = endpoint.with_c_str(|cstr| {
         unsafe {smq_bind(self.sock, cstr)}
     });

I can't speculate on your encode error without seeing it.

-Kevin

On Dec 5, 2013, at 12:43 AM, Philippe Delrieu <[email protected]> wrote:

Hello,

since a few days, I have a lot of new errors in the master compiler. For example in the rust_zmq lib that I use. When I compile it I have these errors : 321:9 error: last argument in `do` call has non-procedure type: |*i8| -> <V3> /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:319 let rc = do endpoint.with_c_str |cstr| { /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:320 unsafe {zmq_bind(self.sock, cstr)} /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:321 }; /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:328:29: 330:9 error: last argument in `do` call has non-procedure type: |*i8| -> <V3> /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:328 let rc = do endpoint.with_c_str |cstr| { /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:329 unsafe {zmq_connect(self.sock, cstr)} /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:330 }; /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:337:16: 352:9 error: last argument in `do` call has non-procedure type: |*u8, uint| -> <V3> /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:337 do data.as_imm_buf |base_ptr, len| { /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:338 let msg = [0, ..32]; /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:339 /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:340 unsafe { /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:341 // Copy the data into the message. /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:342 zmq_msg_init_size(&msg, len as size_t);
...
/home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:342:40: 342:43 error: the type of this value must be known in this context /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:342 zmq_msg_init_size(&msg, len as size_t);
^~~
/home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:344:16: 344:32 error: cannot determine a type for this bounded type parameter: unconstrained type /home/pdelrieu/Documents/dev/musit/rust/zmq/git/rust-zmq/src/zmq/lib.rs:344 ptr::copy_memory(::cast::transmute(zmq_msg_data(&msg)), base_ptr, len);
^~~~~~~~~~~~~~~~
I have the same type of errors in my code plus other error when the trait can't be found like type `MyType` does not implement any method in scope named `encode` and the function is implemented just above.
This code where compiling last week.

Philippe Delrieu

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev



_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev



_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to