-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
// src/lib.rs
fn calculate() -> usize {
1 + 2
}
// tests/file.rs
use temp::*;
#[test]
fn tmp() {
assert_eq!(calculate(), 3);
}
Current output
warning: unused import: `temp::*`
--> tests/file.rs:1:5
|
1 | use temp::*;
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0425]: cannot find function `calculate` in this scope
--> tests/file.rs:5:16
|
5 | assert_eq!(calculate(), 3);
| ^^^^^^^^^ not found in this scope
Desired output
warning: unused import: `temp::*`
--> tests/file.rs:1:5
|
1 | use temp::*;
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0603]: function `calculate` is private and not accessible via `use temp::*`
--> tests/file.rs:5:16
|
1 | use temp::*;
| ------- wildcard import excludes private items: `calculate`
...
5 | assert_eq!(calculate(), 3);
| ^^^^^^^^^ function `calculate` is private
|
note: the function `calculate` is defined here
--> src/lib.rs:1:1
|
1 | fn calculate() -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^
Rationale and extra context
With the original error, it takes a moment to put two and two together and realize that the calculate
function is not imported because it is declared private. It might be nice to follow error E0603
's footsteps to make the intended message significantly clearer.
For reference, E0603
looks like:
error[E0603]: function `calculate` is private
--> tests/file.rs:1:11
|
1 | use temp::calculate;
| ^^^^^^^^^ private function
|
note: the function `calculate` is defined here
--> src/lib.rs:1:1
|
1 | fn calculate() -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^
Rust Version
rustc 1.90.0-nightly (ba7e63b63 2025-07-29)
binary: rustc
commit-hash: ba7e63b63871a429533c189adbfb1d9a6337e000
commit-date: 2025-07-29
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
Anything else?
No response
kakserpom
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.