@@ -671,31 +671,28 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
671671
672672 // Select just those fields of the `with`
673673 // expression that will actually be used
674- match with_cmt. ty . sty {
675- ty:: TyStruct ( def, substs) => {
676- // Consume those fields of the with expression that are needed.
677- for with_field in & def. struct_variant ( ) . fields {
678- if !contains_field_named ( with_field, fields) {
679- let cmt_field = self . mc . cat_field (
680- & * with_expr,
681- with_cmt. clone ( ) ,
682- with_field. name ,
683- with_field. ty ( self . tcx ( ) , substs)
684- ) ;
685- self . delegate_consume ( with_expr. id , with_expr. span , cmt_field) ;
686- }
674+ if let ty:: TyStruct ( def, substs) = with_cmt. ty . sty {
675+ // Consume those fields of the with expression that are needed.
676+ for with_field in & def. struct_variant ( ) . fields {
677+ if !contains_field_named ( with_field, fields) {
678+ let cmt_field = self . mc . cat_field (
679+ & * with_expr,
680+ with_cmt. clone ( ) ,
681+ with_field. name ,
682+ with_field. ty ( self . tcx ( ) , substs)
683+ ) ;
684+ self . delegate_consume ( with_expr. id , with_expr. span , cmt_field) ;
687685 }
688686 }
689- _ => {
690- // the base expression should always evaluate to a
691- // struct; however, when EUV is run during typeck, it
692- // may not. This will generate an error earlier in typeck,
693- // so we can just ignore it.
694- if !self . tcx ( ) . sess . has_errors ( ) {
695- span_bug ! (
696- with_expr. span,
697- "with expression doesn't evaluate to a struct" ) ;
698- }
687+ } else {
688+ // the base expression should always evaluate to a
689+ // struct; however, when EUV is run during typeck, it
690+ // may not. This will generate an error earlier in typeck,
691+ // so we can just ignore it.
692+ if !self . tcx ( ) . sess . has_errors ( ) {
693+ span_bug ! (
694+ with_expr. span,
695+ "with expression doesn't evaluate to a struct" ) ;
699696 }
700697 }
701698
0 commit comments