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

Possible suggestion improvements on match_ref_pats #849

Open
llogiq opened this issue Apr 10, 2016 · 2 comments
Open

Possible suggestion improvements on match_ref_pats #849

llogiq opened this issue Apr 10, 2016 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST

Comments

@llogiq
Copy link
Contributor

llogiq commented Apr 10, 2016

Another example from Carboxyl:

        match &mut *current.borrow_mut() {
            &mut Some(ref mut trans) => action(trans),
            _ => panic!("there is no active transaction to register a callback"),
        }

Our lint suggests using match *&mut *current.borrow_mut() { .. } while actually match *current.borrow_mut() { .. } (and removing &mut in the arm) will suffice.

@llogiq llogiq added good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Apr 10, 2016
@oli-obk
Copy link
Contributor

oli-obk commented Apr 11, 2016

Orthogonal issue:

shouldn't it actually be current.borrow_mut().expect("there is no active transaction to register a callback") ?

@llogiq
Copy link
Contributor Author

llogiq commented Apr 11, 2016

I'm not going to judge... 😄

One could lint match some_option { None => panic!(..), .. }, but unless this is the only non-empty arm, it'd look very opinionated.

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 good-first-issue These issues are a good way to get started with Clippy T-AST Type: Requires working with the AST
Projects
None yet
Development

No branches or pull requests

4 participants