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

foo.unwrap_or(panic!(…)) #19

Open
ftxqxd opened this issue Dec 1, 2014 · 4 comments
Open

foo.unwrap_or(panic!(…)) #19

ftxqxd opened this issue Dec 1, 2014 · 4 comments
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types

Comments

@ftxqxd
Copy link

ftxqxd commented Dec 1, 2014

This should either be .expect() or .unwrap_or_else(|| panic!()) (if they want the formatting panic provides). Ideally this would be generalised to any diverging function (fn(…) -> !) as well.

@lambda-fairy
Copy link

Note that macro expansion runs before type checking runs before lints, so we'll need to match against std::rt::begin_unwind and friends instead.

@llogiq
Copy link
Contributor

llogiq commented May 3, 2015

Similarly, one can implement a lot of Option's API in terms of itself. A number of hints to use the right one will certainly be helpful for a number of people.

@Manishearth Manishearth added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types A-lint Area: New lints labels Aug 11, 2015
@camsteffen
Copy link
Contributor

I would generalize this to suspicious_panic_position and lint anything weird like Foo { field: panic!() } or any_function(.., panic!(), ..).

@bugadani
Copy link
Contributor

bugadani commented Dec 7, 2021

This seems to boil down to seeing the never type (!) used basically anywhere except expression statements? I would call anything suspicious that doesn't return but gets assigned to something - todo!(), variations of unreachable, asserts?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

6 participants