Francisco Ayala created THRIFT-5550:
---------------------------------------

             Summary: error: an inner attribute is not permitted in this context
                 Key: THRIFT-5550
                 URL: https://issues.apache.org/jira/browse/THRIFT-5550
             Project: Thrift
          Issue Type: Bug
          Components: Rust - Compiler
            Reporter: Francisco Ayala


Right now the compiler generates inner attributes at the top of each generated 
source file:
{code:java}
#![allow(unused_imports)]
#![allow(unused_extern_crates)]
#![allow(clippy::too_many_arguments, clippy::type_complexity, clippy::vec_box)]
#![cfg_attr(rustfmt, rustfmt_skip)]{code}
If rust source files are generated by the project's build.rs file, then they 
must be included in the following way:
{code:java}
include!(concat!(env!("OUT_DIR"), "/service.rs")); {code}
However, doing this leads to errors of the following form:
{code:java}
error: an inner attribute is not permitted in this context
 --> 
/thrift-test/target/debug/build/thrift-test-345cae8ce43a395d/out/service.rs:4:1
  |
4 | #![allow(unused_imports)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
...
9 | use std::cell::RefCell;
  | ----------------------- the inner attribute doesn't annotate this `use` 
import
  |
  = note: inner attributes, like `#![no_std]`, annotate the item enclosing 
them, and are usually found at the beginning of source files
help: to annotate the `use` import, change the attribute from inner to outer 
style
  |
4 - #![allow(unused_imports)]
4 + #[allow(unused_imports)] {code}
Related:

https://github.com/google/flatbuffers/issues/6261



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to