-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
suggest removing return type on use of void #156381
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test when there is a valid type called void please, so we can see how rustc behaves in that case? Probably best to have the void type privatley scoped inside a mod { } so we don't need another file for the test. Also consider unifying this test with the existing core::ffi::c_void test somehow. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #![crate_type = "lib"] | ||
|
|
||
| pub fn foo() -> void {} //~ ERROR cannot find type `void` | ||
|
|
||
| pub fn bar(v: void) {} //~ ERROR cannot find type `void` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| error[E0425]: cannot find type `void` in this scope | ||
| --> $DIR/return-void.rs:3:17 | ||
| | | ||
| LL | pub fn foo() -> void {} | ||
| | ^^^^ functions with no return value use `()` | ||
| | | ||
| help: omit the return type to return `()` implicitly | ||
| | | ||
| LL - pub fn foo() -> void {} | ||
| LL + pub fn foo() {} | ||
| | | ||
|
|
||
| error[E0425]: cannot find type `void` in this scope | ||
| --> $DIR/return-void.rs:5:15 | ||
| | | ||
| LL | pub fn bar(v: void) {} | ||
| | ^^^^ not found in this scope | ||
|
|
||
| error: aborting due to 2 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0425`. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be nicer to add the new logic to
compiler/rustc_lint/src/c_void_returns.rsthat https://github.com/rust-lang/rust/pull/156379/changes added?View changes since the review