You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by GitBox <gi...@apache.org> on 2022/05/10 03:03:25 UTC

[GitHub] [avro] jklamer opened a new pull request, #1683: Fix bugs in derive macro usage

jklamer opened a new pull request, #1683:
URL: https://github.com/apache/avro/pull/1683

   Silly build mistake I made: was not able to use derive macro without including in lib.rs.
   +
   Need to qualify HashMap in derive macro for use in contexts where hash map not imported. 
   
   results in being able to use as:
   ```
   use apache_avro::AvroSchema;
   use serde::{Serialize, Deserialize};
   
   #[derive(Debug, Serialize, Deserialize, AvroSchema)]
   struct A {
       a : i64,
       b: String,
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g merged pull request #1683: [AVRO-3516] Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g merged PR #1683:
URL: https://github.com/apache/avro/pull/1683


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g commented on pull request #1683: [AVRO-3516] Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g commented on PR #1683:
URL: https://github.com/apache/avro/pull/1683#issuecomment-1124175647

   Good guess!
   I've extracted the code in a separate app and now it indeed fails with:
   ```
      Compiling derive-test v0.1.0 (/home/martin/tmp/rust/derive-test)
   error: cannot find derive macro `AvroSchema` in this scope
    --> src/main.rs:6:41
     |
   6 | #[derive(Debug, Serialize, Deserialize, AvroSchema)]
     |                                         ^^^^^^^^^^
     |
   note: `AvroSchema` is imported here, but it is only a trait, without a derive macro
    --> src/main.rs:2:5
     |
   2 | use apache_avro::AvroSchema;
     |     ^^^^^^^^^^^^^^^^^^^^^^^
   
   error[E0599]: no function or associated item named `get_schema` found for struct `A` in the current scope
     --> src/main.rs:14:42
      |
   7  | struct A {
      | -------- function or associated item `get_schema` not found for this
   ...
   14 |     println!("Derived schema: {:#?}", A::get_schema());
      |                                          ^^^^^^^^^^ function or associated item not found in `A`
      |
      = help: items from traits can only be used if the trait is implemented and in scope
      = note: the following trait defines an item `get_schema`, perhaps you need to implement it:
              candidate #1: `AvroSchema`
   
   For more information about this error, try `rustc --explain E0599`.
   error: could not compile `derive-test` due to 2 previous errors
   ```
   
   I will remove the new example and merge!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g closed pull request #1683: Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g closed pull request #1683: Fix bugs in derive macro usage 
URL: https://github.com/apache/avro/pull/1683


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] jklamer commented on pull request #1683: Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
jklamer commented on PR #1683:
URL: https://github.com/apache/avro/pull/1683#issuecomment-1123119783

   @martin-g I think the examples and other tests run in dev mode where the apache_avro_derive is a dependency directly so didn't need to be imported into avro/src/lib.rs like we have to now! Thats my guess at least. Making JIRA now. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g commented on pull request #1683: [AVRO-3516] Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g commented on PR #1683:
URL: https://github.com/apache/avro/pull/1683#issuecomment-1124213359

   Thank you, @jklamer !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g commented on pull request #1683: Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g commented on PR #1683:
URL: https://github.com/apache/avro/pull/1683#issuecomment-1121968635

   @jklamer Since `derive` is not a default feature I've expected that the new [example](https://github.com/apache/avro/pull/1683/commits/8ebb0d79e92ee4f997ec2377b98f6a54264f4624) should not compile without `--features derive` but it does! What do I miss ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g commented on pull request #1683: [AVRO-3516] Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g commented on PR #1683:
URL: https://github.com/apache/avro/pull/1683#issuecomment-1124189662

   Using just `apache-avro = { version= "0.14.0", path = "/home/martin/git/apache/avro/lang/rust/avro", features=[ "derive"] }` works fine!
   
   But listing both dependencies explicitly 
   ```
   [dependencies]
   apache-avro-derive = { version= "0.14.0", path = "/home/martin/git/apache/avro/lang/rust/avro_derive" }
   apache-avro = { version= "0.14.0", path = "/home/martin/git/apache/avro/lang/rust/avro"}
   ```
   does not.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [avro] martin-g commented on pull request #1683: [AVRO-3516] Fix bugs in derive macro usage

Posted by GitBox <gi...@apache.org>.
martin-g commented on PR #1683:
URL: https://github.com/apache/avro/pull/1683#issuecomment-1124177951

   Hm. It still fails the same way even after adding `apache-avro-derive = { version= "0.14.0", path = "/home/martin/git/apache/avro/lang/rust/avro_derive" }` to `[dependencies]` ...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org