niuhuan / feign-rs

A restful http client of rust. like java feign.
11 stars 2 forks source link

出现编译错误,是依赖版本的问题 #2

Open hfh1999 opened 10 months ago

hfh1999 commented 10 months ago

darling 版本问题导致编译失败: 因为feign-macros的cargo.toml的版本依赖是darling = "0",而这总会安装最新的前缀的0.开头的版本,最新的版本同作者的程序不兼容,参考:https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html

解决方案:

[dependencies] darling = "=0.13.4" proc-macro-error = "1" proc-macro2 = "1" quote = "1" syn = "1"

[lib] proc-macro = true

- 方案二,推荐方案:
在作者电脑中编译通过后,上传cargo.lock文件,使得git跟踪cargo.lock文件。
参考:  https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

附错误信息如下:
[ERROR rust_analyzer::main_loop] FetchBuildDataError: error[E0432]: unresolved imports syn::FnArg, syn::TraitItemMethod --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/feign-macros-0.1.6/src/lib.rs:9:30 9 use syn::{parse_macro_input, FnArg, TraitItemMethod}; ^^^^^ ^^^^^^^^^^^^^^^ no TraitItemMethod in the root
no FnArg in the root
note: found an item that was configured out --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/lib.rs:363:5 363 FnArg, ForeignItem, ForeignItemFn, ForeignItemMacro, ForeignItemStatic, ForeignItemType, ^^^^^ = note: the item is gated behind the full feature note: found an item that was configured out --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/lib.rs:367:59
367 Signature, TraitItem, TraitItemConst, TraitItemMacro, TraitItemMethod, TraitItemType, UseGlob,
^^^^^^^^^^^^^^^
= note: the item is gated behind the `full` feature

error[E0433]: failed to resolve: could not find TraitItem in syn --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/feign-macros-0.1.6/src/lib.rs:59:18 | 59 | syn::TraitItem::Method(m) => Some(m), | ^^^^^^^^^ could not find TraitItem in syn

error[E0412]: cannot find type ItemTrait in crate syn --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/feign-macros-0.1.6/src/lib.rs:29:50 29 let input = parse_macro_input!(input as syn::ItemTrait); ^^^^^^^^^ not found in syn

note: found an item that was configured out --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/lib.rs:366:29 | 366 | ItemStatic, ItemStruct, ItemTrait, ItemTraitAlias, ItemType, ItemUnion, ItemUse, Receiver, | ^^^^^^^^^ = note: the item is gated behind the full feature

error[E0412]: cannot find type Pat in crate syn --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/feign-macros-0.1.6/src/lib.rs:372:23 372 Form(&'a Box), ^^^ help: a struct with a similar name exists: Path
::: /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/path.rs:4:1 4 / ast_struct! { 5 /// A path at which a named item is exported (e.g. std::collections::HashMap). 6 /// 7 /// *This type is available only if Syn is built with the "derive" or "full" ... 13 } 14 } _- similarly named struct Path defined here

note: found an item that was configured out --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/lib.rs:417:15 | 417 | FieldPat, Pat, PatBox, PatIdent, PatLit, PatMacro, PatOr, PatPath, PatRange, PatReference, | ^^^ = note: the item is gated behind the full feature

error[E0412]: cannot find type Pat in crate syn --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/feign-macros-0.1.6/src/lib.rs:373:23 373 Json(&'a Box), ^^^ help: a struct with a similar name exists: Path
::: /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/path.rs:4:1 4 / ast_struct! { 5 /// A path at which a named item is exported (e.g. std::collections::HashMap). 6 /// 7 /// *This type is available only if Syn is built with the "derive" or "full" ... 13 } 14 } _- similarly named struct Path defined here

note: found an item that was configured out --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-1.0.109/src/lib.rs:417:15 | 417 | FieldPat, Pat, PatBox, PatIdent, PatLit, PatMacro, PatOr, PatPath, PatRange, PatReference, | ^^^ = note: the item is gated behind the full feature

error[E0308]: mismatched types --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/feign-macros-0.1.6/src/lib.rs:30:56 30 let args: ClientArgs = match ClientArgs::from_list(&args) { --------------------- ^^^^^ expected &[NestedMeta], found &Vec<NestedMeta>
arguments to this function are incorrect
= note: expected reference `&[darling::ast::NestedMeta]`
           found reference `&Vec<syn::NestedMeta>`

note: associated function defined here --> /Users/feihuang.huang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/darling_core-0.20.3/src/from_meta.rs:101:8 | 101 | fn from_list(items: &[NestedMeta]) -> Result { | ^^^^^^^^^

niuhuan commented 10 months ago

很抱歉我想是因为代码很久没有更新,以至于依赖没有升级,我会抽出时间整理一下依赖并从新Publish。感谢您对一个探索性质的项目支持,也欢迎您进行PullRequest。