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

Suggest type or module with similar name when code is incorrect #56982

Open
ariasuni opened this issue Dec 19, 2018 · 4 comments
Open

Suggest type or module with similar name when code is incorrect #56982

ariasuni opened this issue Dec 19, 2018 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ariasuni
Copy link
Contributor

ariasuni commented Dec 19, 2018

Given the following code:

use std::ffi::CString;

fn main() {
    let s = Cstring::new("hello").unwrap();
}

rustc gives me this output:

error[E0433]: failed to resolve: use of undeclared type or module `Cstring`
 --> main.rs:4:13
  |
4 |     let s = Cstring::new("hello").unwrap();
  |             ^^^^^^^ use of undeclared type or module `Cstring`

warning: unused import: `std::ffi::CString`
 --> main.rs:1:5
  |
1 | use std::ffi::CString;
  |     ^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.

when it should give something like this:

error[E0433]: failed to resolve: use of undeclared type or module `Cstring`
 --> main.rs:4:13
  |
4 |     let s = Cstring::new("hello").unwrap();
  |             ^^^^^^^ did you mean `CString`?
@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Dec 19, 2018
@estebank estebank added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-papercut Diagnostics: An error or lint that needs small tweaks. labels Jan 25, 2020
@phansch
Copy link
Member

phansch commented Jan 26, 2020

@rustbot claim (I think I have a rough idea what needs to be done)

@rustbot
Copy link
Collaborator

rustbot commented Jan 26, 2020

Error: Parsing assign command in comment failed: ...tbot claim|error: expected end of command at >| (I think ...

Please let @rust-lang/release know if you're having trouble with this bot.

@phansch
Copy link
Member

phansch commented Jan 26, 2020

@rustbot claim

@kadiwa4
Copy link
Contributor

kadiwa4 commented Jan 25, 2023

Fixed:

error[E0433]: failed to resolve: use of undeclared type `Cstring`
 --> src/main.rs:4:13
  |
4 |     let s = Cstring::new("hello").unwrap();
  |             ^^^^^^^
  |             |
  |             use of undeclared type `Cstring`
  |             help: a struct with a similar name exists (notice the capitalization): `CString`

For more information about this error, try `rustc --explain E0433`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants