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

FN needless_return: "return" at end of void-function #4181

Closed
matthiaskrgr opened this issue Jun 7, 2019 · 2 comments · Fixed by #4220
Closed

FN needless_return: "return" at end of void-function #4181

matthiaskrgr opened this issue Jun 7, 2019 · 2 comments · Fixed by #4220
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@matthiaskrgr
Copy link
Member

If we have a function that does not return a type and has return as last statement, we could suggest that that return could be omitted:

pub fn a() {
	println!("blurb");
	return; // unneeded
}

pub fn b() {
	println!("blarb");
	return // unneeded
}

=>

pub fn a() {
	println!("blurb");
}

pub fn b() {
	println!("blarb");
}
@matthiaskrgr matthiaskrgr added the L-suggestion Lint: Improving, adding or fixing lint suggestions label Jun 7, 2019
@matthiaskrgr matthiaskrgr changed the title fn needless_return: "return" at end of void-function FN needless_return: "return" at end of void-function Jun 7, 2019
@phansch
Copy link
Member

phansch commented Jun 7, 2019

I guess this could be part of needless_return?

@matthiaskrgr
Copy link
Member Author

yeah, that's why I put it in the title :p

@flip1995 flip1995 added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jun 8, 2019
bors added a commit that referenced this issue Jun 22, 2019
…r=flip1995

make needless_return work with void functions

fixes #4181.

changelog: make needless_return work with void functions.

I don't think the failure is related to my changes, but I'm not sure 🤔
bors added a commit that referenced this issue Jun 22, 2019
…r=flip1995

make needless_return work with void functions

fixes #4181.

changelog: make needless_return work with void functions.

I don't think the failure is related to my changes, but I'm not sure 🤔
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants