Repository: astral-sh/ruff
File: crates/ty_python_semantic/src/types/infer/builder/type_expression.rs (Rust)

Code before:

                    if let ast::Expr::Starred(ast::ExprStarred {
                        value: starred_value,
                        ..
                    }) = element
                    {
                        let mut report_too_many_unpacked_tuples = || {
                            if let Some(first_unpacked_variadic_tuple) =
                                first_unpacked_variadic_tuple
                            {
                                if let Some(builder) =
                                    self.context.report_lint(&INVALID_TYPE_FORM, tuple)
                                {
                                    let mut diagnostic = builder.into_diagnostic(
                                        "Multiple unpacked variadic tuples \
                                            are not allowed in a `tuple` specialization",
                                    );
                                    diagnostic.annotate(
                                        self.context
                                            .secondary(first_unpacked_variadic_tuple)
                                            .message("First unpacked variadic tuple"),
                                    );
                                    diagnostic.annotate(
                                        self.context
                                            .secondary(element)
                                            .message("Second unpacked variadict tuple"),
                                    );
                                }
                            } else {
                                first_unpacked_variadic_tuple = Some(element);
                            }
                        };

                        if let Some(inner_tuple) = element_ty.exact_tuple_instance_spec(self.db()) {
                            element_types = element_types.concat(self.db(), &inner_tuple);

                            if inner_tuple.is_variadic() {
                                report_too_many_unpacked_tuples();
                            }
                        } else if self.expression_type(starred_value)
                            == Type::Dynamic(DynamicType::TodoTypeVarTuple)
                        {
                            report_too_many_unpacked_tuples();
                        } else {
                            // TODO: emit a diagnostic
                        }
                    } else {
                        element_types.push(element_ty);
                    }
                }


Review comment (suggestion):
```suggestion
                                            .message("Second unpacked variadic tuple"),
```

Code after:

                    if let ast::Expr::Starred(ast::ExprStarred {
                        value: starred_value,
                        ..
                    }) = element
                    {
                        let mut report_too_many_unpacked_tuples = || {
                            if let Some(first_unpacked_variadic_tuple) =
                                first_unpacked_variadic_tuple
                            {
                                if let Some(builder) =
                                    self.context.report_lint(&INVALID_TYPE_FORM, tuple)
                                {
                                    let mut diagnostic = builder.into_diagnostic(
                                        "Multiple unpacked variadic tuples \
                                            are not allowed in a `tuple` specialization",
                                    );
                                    diagnostic.annotate(
                                        self.context
                                            .secondary(first_unpacked_variadic_tuple)
                                            .message("First unpacked variadic tuple"),
                                    );
                                    diagnostic.annotate(
                                        self.context
                                            .secondary(element)
                                            .message("Later unpacked variadic tuple"),
                                    );
                                }
                            } else {
                                first_unpacked_variadic_tuple = Some(element);
                            }
                        };

                        if let Some(inner_tuple) = element_ty.exact_tuple_instance_spec(self.db()) {
                            element_types = element_types.concat(self.db(), &inner_tuple);

                            if inner_tuple.is_variadic() {
                                report_too_many_unpacked_tuples();
                            }
                        } else if self.expression_type(starred_value)
                            == Type::Dynamic(DynamicType::TodoTypeVarTuple)
                        {
                            report_too_many_unpacked_tuples();
                        } else {
                            // TODO: emit a diagnostic
                        }
                    } else {
                        element_types.push(element_ty);
                    }
                }