Cargo-Udeps: cannot access private module

Hi there,

I'm trying to check for unused dependencies using the cargo-udeps crate, but when I do it seems to reference this file .cargo/git/checkouts/substrate-a7fa553ead635512/816fc31/frame/support/procedural/tools/src/syn_ext.rs:50:14

let syn::group::$name { token, content } = syn::group::$parse(input)?;

Which complains that the group module is private so it cannot access it.

But keep in mind I'm not using the syn crate within my project but I think a dependency in my project may be using it.

Looks like frame-support-procedural-tools (which is probably used indirectly by your code) is currently broken - it was using hidden API of syn, namely syn::group, which was since then made non-public. This is already fixed in the repository, but I'm not sure whether this change is on crates.io already.

As a workaround, you can pin the version of syn manually, by adding this to Cargo.toml:

[dependencies.syn]
version = "=1.0.58"
features = ["full", "visit", "extra-traits"]

The first line specifies that the version must not be upgraded, and the second one specifies the necessary features for the tools crate to compile.

Thank you for your response @Cerber-Ursi , It says version '=1.0.58' doesn't exist, so I decided to try version =1.0.98, Which i then still ended up having the same error.

Could you copy the exact error from cargo check and the full Cargo.toml? This version definitely do exist, so this must be some kind of configuration issue.

My mistake, It does exist! the packages which are being used by the project require above that version.

Sure.

# Cargo.toml

[package]
authors     = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node implementation in Rust"
edition     = "2021"
homepage    = "https://darwinia.network"
license     = "GPL-3.0"
name        = "darwinia"
repository  = "https://github.com/darwinia-network/darwinia"
version     = "0.12.4-2"

[[bin]]
name = "darwinia"
path = "src/main.rs"

[badges]
maintenance = { status = "actively-developed" }

[dependencies]
# crates.io
futures = { version = "0.3" }
# darwinia-network
darwinia-cli          = { path = "cli" }
darwinia-node-service = { path = "node/service" }

[features]
default = ["darwinia-cli/wasmtime"]

fast-runtime = ["darwinia-cli/fast-runtime"]

evm-tracing = ["darwinia-cli/evm-tracing"]

runtime-benchmarks = ["darwinia-cli/runtime-benchmarks"]

try-runtime = ["darwinia-cli/try-runtime"]

[workspace]
members = [
	"cli",
	"primitives",
	"rpc",
	"runtime/common",
	"runtime/crab",
	"runtime/darwinia",
	"node/service",
]

[profile.dev.package]
blake2            = { opt-level = 3 }
blake2-rfc        = { opt-level = 3 }
blake2b_simd      = { opt-level = 3 }
chacha20poly1305  = { opt-level = 3 }
cranelift-codegen = { opt-level = 3 }
cranelift-wasm    = { opt-level = 3 }
crc32fast         = { opt-level = 3 }
crossbeam-deque   = { opt-level = 3 }
crypto-mac        = { opt-level = 3 }
curve25519-dalek  = { opt-level = 3 }
ed25519-dalek     = { opt-level = 3 }
flate2            = { opt-level = 3 }
futures-channel   = { opt-level = 3 }
hash-db           = { opt-level = 3 }
hashbrown         = { opt-level = 3 }
hmac              = { opt-level = 3 }
httparse          = { opt-level = 3 }
integer-sqrt      = { opt-level = 3 }
keccak            = { opt-level = 3 }
libm              = { opt-level = 3 }
librocksdb-sys    = { opt-level = 3 }
libsecp256k1      = { opt-level = 3 }
libz-sys          = { opt-level = 3 }
mio               = { opt-level = 3 }
nalgebra          = { opt-level = 3 }
num-bigint        = { opt-level = 3 }
parking_lot       = { opt-level = 3 }
parking_lot_core  = { opt-level = 3 }
percent-encoding  = { opt-level = 3 }
primitive-types   = { opt-level = 3 }
ring              = { opt-level = 3 }
rustls            = { opt-level = 3 }
sha2              = { opt-level = 3 }
sha3              = { opt-level = 3 }
smallvec          = { opt-level = 3 }
snow              = { opt-level = 3 }
twox-hash         = { opt-level = 3 }
uint              = { opt-level = 3 }
wasmi             = { opt-level = 3 }
x25519-dalek      = { opt-level = 3 }
yamux             = { opt-level = 3 }
zeroize           = { opt-level = 3 }

[profile.release]
# Darwinia runtime requires unwinding.
panic = "unwind"

[profile.release-lto]
inherits = "release"
lto      = true

[dependencies.syn]
version = "=1.0.98"
features = ["full", "visit", "extra-traits"]
# Cargo check

note: the module `group` is defined here
   --> /.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.98/src/lib.rs:304:1
    |
304 | mod group;
    | ^^^^^^^^^^

error[E0603]: module `group` is private
   --> /.cargo/git/checkouts/substrate-a7fa553ead635512/816fc31/frame/support/procedural/tools/src/syn_ext.rs:50:14
    |
50  |                 let syn::group::$name { token, content } = syn::group::$parse(input)?;
    |                          ^^^^^ private module
    |
note: the module `group` is defined here
   --> /.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.98/src/lib.rs:304:1
    |
304 | mod group;
    | ^^^^^^^^^^

   Compiling sp-runtime-interface-proc-macro v4.0.0-dev (https://github.com/darwinia-network/substrate?branch=darwinia-v0.12.4#816fc31b)
For more information about this error, try `rustc --explain E0603`.
error: could not compile `frame-support-procedural-tools` due to 2 previous errors

Aha, so you're using you own fork of substrate, it seems, and the offending file is not updated there yet. It might be better if you're able to pull the updates from upstream, but if that's impossible, you could run cargo tree -i syn to see what dependency is pulling the newer version and what version does it really require. Maybe it's somewhere between 1.0.58 and 1.0.98, when syn::group was still available.

1 Like

Yes it was, I didn't see that, thank you @Cerber-Ursi!

It was at 1.081. Some of the calls referenced within the crate had not been updated yet like this parse_quote_spanned which results in an error.