-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Sublime Text Version
Sublime Text 3.1.1 (Build 3176)
Rust Enhanced Version
2.18.0
Operating system
OS Name: Microsoft Windows 10 Enterprise
Version: 1803
OS Build: 17134.472
System type: x64
Expected behavior
No error.
Actual behavior
error: failed to resolve: could not find client
in {{root}}
Steps to reproduce
cargo new --lib namespace_error
cd namespace_error/src
- Put the content of
lib.rs
(see below) intolib.rs
- Save and the unexpected error message appears in Sublime Text, but on the command line
cargo build
orcargo check
passes fine!
Rust Enhanced Debug Log
+0.000 Running: cargo metadata --no-deps
+0.057 Running: cargo metadata --no-deps
+0.059 Running: rustc --version
+0.058 Running: cargo check --lib --message-format=json --profile=test
+0.051 Checking ch7-02_error v0.1.0 (D:\odrive\Steve-OneDrive\Dev\Rust\ch7-02_error)
+0.064 error: Could not compile `ch7-02_error`.
+0.000
+0.000 To learn more, run the command again with --verbose.
+0.007 On-save check finished.
The content of lib.rs
pub mod client {
pub fn connect() {}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
::client::connect();
}
}
Additional details
This is a simplified version of an example from the book, chapter 7.3.
super::client::connect()
works with Rust Enhanced too, but the shorter ::
version should work too.
cargo check --lib --message-format=json --profile=test
in my Cmder mintty.exe (git for windows) command line works fine, but I get the same error if I run the same command in windows cmd
.
$ which cargo
/c/Users/Aurora/.cargo/bin/cargo
...
>where cargo
C:\Users\Aurora\.cargo\bin\cargo.exe
It seems the same cargo
binary produces different outputs in different environments.
However, running the test returns the same error in both mintty and cmd:
$ cargo test
Compiling namespace_error v0.1.0 (D:\odrive\Steve-OneDrive\Dev\Rust\namespace_error)
error[E0433]: failed to resolve: could not find `client` in `{{root}}`
--> src\lib.rs:9:11
|
9 | ::client::connect();
| ^^^^^^ could not find `client` in `{{root}}`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0433`.
error: Could not compile `namespace_error`.
To learn more, run the command again with --verbose.
Is this valid code or chapter 7.3 is wrong in the book?