@@ -28,9 +28,9 @@ use crate::structured_errors::StructuredDiagnostic;
28
28
use std:: iter;
29
29
use std:: slice;
30
30
31
- enum FnArgsAsTuple < ' hir > {
32
- Single ( & ' hir hir:: Expr < ' hir > ) ,
33
- Multi { first : & ' hir hir :: Expr < ' hir > , last : & ' hir hir:: Expr < ' hir > } ,
31
+ struct FnArgsAsTuple < ' hir > {
32
+ first : & ' hir hir:: Expr < ' hir > ,
33
+ last : & ' hir hir:: Expr < ' hir > ,
34
34
}
35
35
36
36
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
@@ -432,23 +432,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
432
432
String :: from ( "()" ) ,
433
433
Applicability :: MachineApplicable ,
434
434
) ;
435
- } else if let Some ( tuple_fn_arg) = sugg_tuple_wrap_args {
436
- use FnArgsAsTuple :: * ;
437
-
438
- let spans = match tuple_fn_arg {
439
- Multi { first, last } => vec ! [
435
+ } else if let Some ( FnArgsAsTuple { first, last } ) = sugg_tuple_wrap_args {
436
+ err. multipart_suggestion (
437
+ "use parentheses to construct a tuple" ,
438
+ vec ! [
440
439
( first. span. shrink_to_lo( ) , '(' . to_string( ) ) ,
441
440
( last. span. shrink_to_hi( ) , ')' . to_string( ) ) ,
442
441
] ,
443
- Single ( single) => vec ! [
444
- ( single. span. shrink_to_lo( ) , '(' . to_string( ) ) ,
445
- ( single. span. shrink_to_hi( ) , ",)" . to_string( ) ) ,
446
- ] ,
447
- } ;
448
-
449
- err. multipart_suggestion (
450
- "use parentheses to construct a tuple" ,
451
- spans,
452
442
Applicability :: MachineApplicable ,
453
443
) ;
454
444
} else {
@@ -519,8 +509,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
519
509
if all_match {
520
510
match provided_args {
521
511
[ ] => None ,
522
- [ single] => Some ( FnArgsAsTuple :: Single ( single) ) ,
523
- [ first, .., last] => Some ( FnArgsAsTuple :: Multi { first, last } ) ,
512
+ [ _] => unreachable ! (
513
+ "shouldn't reach here - need count mismatch between 1-tuple and 1-argument"
514
+ ) ,
515
+ [ first, .., last] => Some ( FnArgsAsTuple { first, last } ) ,
524
516
}
525
517
} else {
526
518
None
0 commit comments