Rollup merge of #145783 - Erk-:et-cetera-span, r=compiler-errors

add span to struct pattern rest (..)

Struct pattern rest (`..`) did not retain span information compared to normal fields. This patch adds span information for it.

The motivation of this patch comes from when I implemented this PR for Clippy: https://github.com/rust-lang/rust-clippy/pull/15000#discussion_r2134145163

It is possible to get the span of the Et cetera in a bit roundabout way, but I thought this would be nicer.
This commit is contained in:
Guillaume Gomez
2025-09-02 17:08:52 +02:00
committed by GitHub
18 changed files with 50 additions and 40 deletions

View File

@@ -1516,7 +1516,7 @@ impl<'a> Parser<'a> {
|| self.check_noexpect(&token::DotDotDot)
|| self.check_keyword(exp!(Underscore))
{
etc = PatFieldsRest::Rest;
etc = PatFieldsRest::Rest(self.token.span);
let mut etc_sp = self.token.span;
if first_etc_and_maybe_comma_span.is_none() {
if let Some(comma_tok) =