-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specifically
Description
As commented in #1127 here: #1127 (comment) there are two confusing error messages when compiling with --test without "use std":
$ cat ./test_compile_error_example.rs
fn inc_int(x: int) -> int { x + 1 }
#[test]
fn test_inc_int() {
assert (inc_int(3) == 4);
}
$ rustc --test ./test_compile_error_example.rs
./test_compile_error_example.rs:1:0: 1:0 error: unresolved name
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
./test_compile_error_example.rs:1:0: 1:0 error: use of undeclared module `std::test`
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
./test_compile_error_example.rs:1:0: 1:0 error: unresolved name: std::test::test_main
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
./test_compile_error_example.rs:1:0: 1:0 error: unresolved name
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
./test_compile_error_example.rs:1:0: 1:0 error: use of undeclared module `std::test`
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
./test_compile_error_example.rs:1:0: 1:0 error: use of undeclared type name `std::test::test_desc`
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
error: aborting due to 6 previous errors
The first and fourth error message are quite ambiguous. Both say this:
./test_compile_error_example.rs:1:0: 1:0 error: unresolved name
./test_compile_error_example.rs:1 fn inc_int(x: int) -> int { x + 1 }
^
Which name is unresolved? All identifiers in the given text are either declared ("inc_int" and "x") or should be in scope ("int" and "x").
This issue would be fixed by including the name in the error message which is unresolvable.
Note that even this fix may still yield confusing error messages due to other issues, such as #1448 or #1127, but this issue is distinct and should be separately addressed.
Metadata
Metadata
Assignees
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specifically