症状
编译器报出 error[E0425]: cannot find value ... in this scope。该条目在别处明显存在,说明问题出在可见性或路径,而非真正的拼写错误。
诊断
找出条目的定义位置及其暴露方式:
mod helpers { pub fn parse() {} } // pub required to cross modules
use helpers::parse; // bring it into scope
同时检查依赖:
cargo tree | grep the-crate
修复
补充导入或使用完整路径,并将条目设为 public:
use crate::helpers::parse;
parse();
// or fully qualified:
crate::helpers::parse();
验证
cargo check 编译通过且不再出现 E0425,证明该名字现在能经由可见路径解析。