[rust-dev] no error or warning when an unknown attribute is used

Ilya Dmitrichenko errordeveloper at gmail.com
Wed Jul 16 06:38:34 PDT 2014


Hi List,

Using serialize crate, I have made a typo in attribute name and wrote
'derives' instead of 'deriving' and I got an error message about
`ToJson` trait not being implemented.

Here is what I did:

> cat foo.rs
extern crate serialize;
use serialize::json;

#[derive(Decodable, Encodable)]
pub struct Data {
  test: bool,
  uuid: int,
  time: f64,
}

fn main() {
  let data = Data { test: true, uuid: 123, time: 34349480.24 };
  json::encode(&data);
}

> rustc foo.rs
foo.rs:13:3: 13:15 error: failed to find an implementation of trait
serialize::serialize::Encodable<serialize::json::Encoder<'_>,std::io::IoError>
for Data
foo.rs:13   json::encode(&data);
                ^~~~~~~~~~~~

The compiler happily skipped over unknown attribute... Is this a
desired behaviour or a known issues?

Cheers,
-- 
Ilya


More information about the Rust-dev mailing list