File tree Expand file tree Collapse file tree 1 file changed +26
-11
lines changed
compiler/rustc_ast_lowering/src Expand file tree Collapse file tree 1 file changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -870,18 +870,33 @@ impl<'hir> LoweringContext<'_, 'hir> {
870870 whole_span : Span ,
871871 ) -> hir:: ExprKind < ' hir > {
872872 // Return early in case of an ordinary assignment.
873- match lhs. kind {
874- ExprKind :: Array ( ..)
875- | ExprKind :: Call ( ..)
876- | ExprKind :: Struct ( _, _, None )
877- | ExprKind :: Tup ( ..) => { }
878- _ => {
879- return hir:: ExprKind :: Assign (
880- self . lower_expr ( lhs) ,
881- self . lower_expr ( rhs) ,
882- eq_sign_span,
883- ) ;
873+ let is_ordinary = match & lhs. kind {
874+ ExprKind :: Array ( ..) | ExprKind :: Struct ( _, _, None ) | ExprKind :: Tup ( ..) => false ,
875+ ExprKind :: Call ( callee, ..) => {
876+ // Check for tuple struct constructor.
877+ if let ExprKind :: Path ( qself, path) = & callee. kind {
878+ let qpath = self . lower_qpath (
879+ callee. id ,
880+ qself,
881+ path,
882+ ParamMode :: Optional ,
883+ ImplTraitContext :: disallowed ( ) ,
884+ ) ;
885+ match qpath {
886+ hir:: QPath :: Resolved (
887+ _,
888+ hir:: Path { res : Res :: Def ( DefKind :: Ctor ( ..) , _) , .. } ,
889+ ) => false ,
890+ _ => true ,
891+ }
892+ } else {
893+ true
894+ }
884895 }
896+ _ => true ,
897+ } ;
898+ if is_ordinary {
899+ return hir:: ExprKind :: Assign ( self . lower_expr ( lhs) , self . lower_expr ( rhs) , eq_sign_span) ;
885900 }
886901
887902 let mut assignments = Vec :: new ( ) ;
You can’t perform that action at this time.
0 commit comments