Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include name in "unresolved name" error messages. #3242

Closed
nejucomo opened this issue Aug 21, 2012 · 2 comments
Closed

Include name in "unresolved name" error messages. #3242

nejucomo opened this issue Aug 21, 2012 · 2 comments
Labels
A-resolve Area: Path resolution

Comments

@nejucomo
Copy link

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.

@graydon
Copy link
Contributor

graydon commented Mar 20, 2013

Error in question no longer occurs with this input; can still provoke with a bad path but it's not as serious since it's not synthetic. In any case, not fixing for 0.6 so de-milestoning.

@graydon
Copy link
Contributor

graydon commented May 15, 2013

As with resolution to #1127, std is linked by default with --test now, the example here now compiles fine. Closing.

@graydon graydon closed this as completed May 15, 2013
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
RFC describing the support for existential and universal quantifiers in
Kani.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Signed-off-by: Felipe R. Monteiro <felisous@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution
Projects
None yet
Development

No branches or pull requests

2 participants