Skip to content

suboptimal suggestion with match and macro expanded arms #2954

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

Closed
oli-obk opened this issue Jul 24, 2018 · 3 comments
Closed

suboptimal suggestion with match and macro expanded arms #2954

oli-obk opened this issue Jul 24, 2018 · 3 comments
Labels
E-help-wanted Call for participation: Help is requested to fix this issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jul 24, 2018

We should rewrite this lint as a PreExpansionPass. We should rewrite a lot of lints as PreExpansionPasses...

error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
  --> $DIR/matches.rs:40:5
   |
40 | /     match tup {
41 | |         &(v, 1) => println!("{}", v),
42 | |         _ => println!("none"),
43 | |     }
   | |_____^
help: try this
   |
40 |     if let &(v, 1) = tup {
41 | # [ cfg ( not ( stage0 ) ) ] {
42 | ( $ crate :: io :: _print ( format_args_nl ! ( $ ( $ arg ) * ) ) ) ; } # [
43 | cfg ( stage0 ) ] { print ! ( "{}/n" , format_args ! ( $ ( $ arg ) * ) ) } } else {
44 | ( $ crate :: io :: _print ( format_args_nl ! ( $ ( $ arg ) * ) ) ) ; }
   |
@oli-obk oli-obk added the E-help-wanted Call for participation: Help is requested to fix this issue. label Jul 24, 2018
@phansch
Copy link
Member

phansch commented Jul 24, 2018

Is the PreExpansion pass a recently introduced lint pass?

@flip1995
Copy link
Member

Yep rust-lang/rust#52375

@camsteffen
Copy link
Contributor

I'm not sure how to reproduce this. Probably obsolete. And pre-expansion passes are discouraged these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-help-wanted Call for participation: Help is requested to fix this issue.
Projects
None yet
Development

No branches or pull requests

4 participants