diff --git a/.changeset/large-olives-walk.md b/.changeset/large-olives-walk.md new file mode 100644 index 00000000000..2fe12b22d16 --- /dev/null +++ b/.changeset/large-olives-walk.md @@ -0,0 +1,8 @@ +--- +swc_css_visit: patch +swc_ecma_visit: patch +swc_html_visit: patch +swc_xml_visit: patch +--- + +fix(visit): Fix regression diff --git a/crates/swc_css_visit/src/generated.rs b/crates/swc_css_visit/src/generated.rs index 7301880e8fb..d1bd673559e 100644 --- a/crates/swc_css_visit/src/generated.rs +++ b/crates/swc_css_visit/src/generated.rs @@ -37273,9 +37273,12 @@ impl VisitWithAstPath for [CalcProductOrOperator] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37299,9 +37302,12 @@ impl VisitWithAstPath for [CalcValueOrOperator] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37325,9 +37331,12 @@ impl VisitWithAstPath for [ComplexSelectorChildren] visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37351,8 +37360,13 @@ impl VisitWithAstPath for [ComplexSelector] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -37375,8 +37389,13 @@ impl VisitWithAstPath for [ComponentValue] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -37399,9 +37418,12 @@ impl VisitWithAstPath for [CompoundSelector] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37425,9 +37447,12 @@ impl VisitWithAstPath for [ContainerQueryType] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37451,8 +37476,13 @@ impl VisitWithAstPath for [CustomIdent] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -37476,9 +37506,12 @@ impl VisitWithAstPath for [DocumentPreludeMatchingF visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37502,8 +37535,13 @@ impl VisitWithAstPath for [FamilyName] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -37526,9 +37564,12 @@ impl VisitWithAstPath for [ForgivingComplexSelector visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37552,9 +37593,12 @@ impl VisitWithAstPath for [ForgivingRelativeSelecto visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37578,8 +37622,9 @@ impl VisitWithAstPath for [Ident] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -37602,9 +37647,12 @@ impl VisitWithAstPath for [KeyframeSelector] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37628,8 +37676,9 @@ impl VisitWithAstPath for [LayerName] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -37652,9 +37701,12 @@ impl VisitWithAstPath for [MediaConditionAllType] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37679,9 +37731,12 @@ impl VisitWithAstPath for [MediaConditionWithoutOrT visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -37705,8 +37760,13 @@ impl VisitWithAstPath for [MediaQuery] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -38492,9 +38552,12 @@ impl VisitWithAstPath for [PageSelectorPseudo] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -38518,8 +38581,13 @@ impl VisitWithAstPath for [PageSelector] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -38543,9 +38611,12 @@ impl VisitWithAstPath for [PseudoClassSelectorChild visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -38570,9 +38641,12 @@ impl VisitWithAstPath for [PseudoElementSelectorChi visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -38596,9 +38670,12 @@ impl VisitWithAstPath for [RelativeSelector] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -38622,8 +38699,9 @@ impl VisitWithAstPath for [Rule] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -38668,9 +38746,12 @@ impl VisitWithAstPath for [SubclassSelector] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -38694,9 +38775,12 @@ impl VisitWithAstPath for [SupportsConditionType] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -38720,8 +38804,13 @@ impl VisitWithAstPath for [UrlModifier] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -72264,9 +72353,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72282,9 +72374,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72301,9 +72396,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72319,9 +72417,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72337,9 +72438,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72355,9 +72459,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72373,9 +72480,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72391,9 +72501,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72412,9 +72525,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72430,9 +72546,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72449,9 +72568,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72468,9 +72590,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72486,8 +72611,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -72502,9 +72632,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72520,9 +72653,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72539,9 +72675,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72560,9 +72699,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -72578,9 +72720,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73152,9 +73297,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73170,9 +73318,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73189,9 +73340,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73210,9 +73364,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73228,9 +73385,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73246,8 +73406,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -73276,9 +73441,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73295,9 +73463,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -73313,9 +73484,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -108016,11 +108190,17 @@ impl FoldWithAstPath for Vec #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108034,11 +108214,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108052,11 +108238,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108070,9 +108262,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108086,9 +108286,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108102,9 +108310,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108118,11 +108334,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108136,9 +108358,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108153,11 +108383,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108171,9 +108407,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108187,11 +108431,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108205,11 +108455,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108223,9 +108479,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108239,9 +108499,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108255,9 +108523,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108271,11 +108547,17 @@ impl FoldWithAstPath for Vec #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108289,11 +108571,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108307,9 +108595,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108799,11 +109095,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108817,9 +109119,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108833,11 +109143,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108852,11 +109168,17 @@ impl FoldWithAstPath for Vec Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108870,9 +109192,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108886,9 +109216,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108916,9 +109250,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108932,11 +109274,17 @@ impl FoldWithAstPath for Vec #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -108950,9 +109298,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -121747,6 +122103,15 @@ pub type AstNodePath<'ast> = swc_visit::AstNodePath>; #[cfg(any(docsrs, feature = "path"))] pub mod fields { use swc_css_ast::*; + #[inline(always)] + fn assert_initial_index(idx: usize, index: usize) { + #[cfg(debug_assertions)] + if !(idx == usize::MAX || index == usize::MAX) { + { + panic!("Should be usize::MAX"); + } + } + } impl AbsoluteColorBaseField { #[inline(always)] pub(crate) fn set_index(&mut self, _: usize) {} @@ -122041,12 +122406,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Expressions(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122075,12 +122435,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Expressions(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122210,12 +122565,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122315,12 +122665,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::SubclassSelectors(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122342,12 +122687,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122390,12 +122730,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Queries(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122567,12 +122902,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Value(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122686,12 +123016,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::MatchingFunctions(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122763,12 +123088,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::FontFamily(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122808,12 +123128,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122831,12 +123146,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -122881,12 +123191,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Value(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123071,12 +123376,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Prelude(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123154,12 +123454,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Name(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123177,12 +123472,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::NameList(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123238,12 +123528,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123277,12 +123562,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Conditions(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123326,12 +123606,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Conditions(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123557,12 +123832,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Queries(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123710,12 +123980,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Selectors(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123927,12 +124192,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -123995,12 +124255,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -124018,12 +124273,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Value(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -124041,12 +124291,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Value(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -124225,12 +124470,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Rules(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -124281,12 +124521,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Conditions(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} diff --git a/crates/swc_ecma_visit/src/generated.rs b/crates/swc_ecma_visit/src/generated.rs index 34153933317..41183dcc7c4 100644 --- a/crates/swc_ecma_visit/src/generated.rs +++ b/crates/swc_ecma_visit/src/generated.rs @@ -48916,8 +48916,13 @@ impl VisitWithAstPath for [ClassMember] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -48940,8 +48945,9 @@ impl VisitWithAstPath for [Decorator] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -48964,8 +48970,13 @@ impl VisitWithAstPath for [ExportSpecifier] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -48988,8 +48999,13 @@ impl VisitWithAstPath for [ExprOrSpread] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49012,8 +49028,9 @@ impl VisitWithAstPath for [Box] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - as VisitWithAstPath>::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as VisitWithAstPath>::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -49036,8 +49053,13 @@ impl VisitWithAstPath for [ImportSpecifier] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49060,8 +49082,13 @@ impl VisitWithAstPath for [ImportWithItem] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49084,8 +49111,13 @@ impl VisitWithAstPath for [JSXAttrOrSpread] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49108,8 +49140,13 @@ impl VisitWithAstPath for [JSXElementChild] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49132,8 +49169,13 @@ impl VisitWithAstPath for [ModuleItem] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49156,8 +49198,13 @@ impl VisitWithAstPath for [ObjectPatProp] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49858,9 +49905,12 @@ impl VisitWithAstPath for [Option] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); as VisitWithAstPath>::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -49884,8 +49934,13 @@ impl VisitWithAstPath for [Option] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - as VisitWithAstPath>::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as VisitWithAstPath>::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -49908,9 +49963,12 @@ impl VisitWithAstPath for [ParamOrTsParamProp] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -49934,8 +49992,9 @@ impl VisitWithAstPath for [Param] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -49958,8 +50017,9 @@ impl VisitWithAstPath for [Pat] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -49982,8 +50042,13 @@ impl VisitWithAstPath for [PropOrSpread] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50028,8 +50093,9 @@ impl VisitWithAstPath for [Stmt] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -50052,8 +50118,13 @@ impl VisitWithAstPath for [SwitchCase] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50098,8 +50169,13 @@ impl VisitWithAstPath for [TplElement] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50122,8 +50198,13 @@ impl VisitWithAstPath for [TsEnumMember] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50146,9 +50227,12 @@ impl VisitWithAstPath for [TsExprWithTypeArgs] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -50172,8 +50256,9 @@ impl VisitWithAstPath for [TsFnParam] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -50196,8 +50281,13 @@ impl VisitWithAstPath for [TsTupleElement] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50220,8 +50310,13 @@ impl VisitWithAstPath for [TsTypeElement] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50244,8 +50339,13 @@ impl VisitWithAstPath for [TsTypeParam] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50268,8 +50368,13 @@ impl VisitWithAstPath for [Box] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - as VisitWithAstPath>::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as VisitWithAstPath>::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -50292,8 +50397,13 @@ impl VisitWithAstPath for [VarDeclarator] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -92452,9 +92562,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92470,9 +92583,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92488,9 +92604,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92506,9 +92625,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92524,9 +92646,12 @@ impl VisitMutWithAstPath for Vec> { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); as VisitMutWithAstPath>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92542,9 +92667,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92560,9 +92688,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92578,9 +92709,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92596,9 +92730,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92614,9 +92751,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -92632,9 +92772,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93130,9 +93273,12 @@ impl VisitMutWithAstPath for Vec as VisitMutWithAstPath>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93148,9 +93294,12 @@ impl VisitMutWithAstPath for Vec> { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); as VisitMutWithAstPath>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93166,9 +93315,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93184,8 +93336,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -93200,8 +93357,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -93216,9 +93378,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93248,8 +93413,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -93264,9 +93434,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93296,9 +93469,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93314,9 +93490,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93332,9 +93511,12 @@ impl VisitMutWithAstPath for Vec>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93350,9 +93532,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93368,9 +93553,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93386,9 +93574,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93404,9 +93595,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93422,9 +93616,12 @@ impl VisitMutWithAstPath for Vec> { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); as VisitMutWithAstPath>::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -93440,9 +93637,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -137313,9 +137513,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137329,9 +137537,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137345,9 +137561,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137361,9 +137585,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137377,9 +137609,17 @@ impl FoldWithAstPath for Vec> { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - as FoldWithAstPath>::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as FoldWithAstPath>::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137393,9 +137633,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137409,9 +137657,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137425,9 +137681,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137441,9 +137705,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137457,9 +137729,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137473,9 +137753,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137897,11 +138185,17 @@ impl FoldWithAstPath for Vec> { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - as FoldWithAstPath>::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as FoldWithAstPath>::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137915,9 +138209,17 @@ impl FoldWithAstPath for Vec> { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - as FoldWithAstPath>::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as FoldWithAstPath>::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137931,11 +138233,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137949,9 +138257,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137965,9 +138277,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -137981,9 +138297,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138011,9 +138335,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138027,9 +138355,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138057,9 +138393,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138073,9 +138417,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138089,11 +138441,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path( - item, visitor, __ast_path, - ) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138107,9 +138465,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138123,9 +138489,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138139,9 +138513,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138155,9 +138537,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138171,9 +138561,17 @@ impl FoldWithAstPath for Vec> { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - as FoldWithAstPath>::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + as FoldWithAstPath>::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -138187,9 +138585,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -154742,6 +155148,15 @@ pub type AstNodePath<'ast> = swc_visit::AstNodePath>; #[cfg(any(docsrs, feature = "path"))] pub mod fields { use swc_ecma_ast::*; + #[inline(always)] + fn assert_initial_index(idx: usize, index: usize) { + #[cfg(debug_assertions)] + if !(idx == usize::MAX || index == usize::MAX) { + { + panic!("Should be usize::MAX"); + } + } + } impl AccessibilityField { #[inline(always)] pub(crate) fn set_index(&mut self, _: usize) {} @@ -154759,12 +155174,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Elems(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -154782,12 +155192,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Elems(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -154809,12 +155214,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -154973,12 +155373,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -155131,12 +155526,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Stmts(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -155195,12 +155585,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Args(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -155253,30 +155638,15 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Body(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Implements(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -155391,12 +155761,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -155468,12 +155833,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -155963,21 +156323,11 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156091,12 +156441,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Specifiers(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156194,12 +156539,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Values(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156322,12 +156662,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156416,12 +156751,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156486,12 +156816,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Attrs(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156714,12 +157039,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Body(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156786,12 +157106,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Specifiers(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156863,12 +157178,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Props(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156886,12 +157196,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Props(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156926,12 +157231,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Args(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -156982,12 +157282,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157095,12 +157390,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157258,12 +157548,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Body(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157283,12 +157568,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Exprs(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157483,12 +157763,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Cons(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157508,12 +157783,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Cases(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157579,21 +157849,11 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Exprs(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Quasis(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157692,12 +157952,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157753,12 +158008,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157780,12 +158030,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157820,12 +158065,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Members(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -157946,12 +158186,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158029,12 +158264,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158106,12 +158336,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Body(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158129,12 +158354,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Extends(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158160,12 +158380,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Types(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158283,12 +158498,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158316,12 +158526,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Body(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158454,12 +158659,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decorators(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158619,21 +158819,11 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Types(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Quasis(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158669,12 +158859,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::ElemTypes(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158810,12 +158995,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Members(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158886,12 +159066,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -158909,12 +159084,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Params(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -159004,12 +159174,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Types(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -159093,12 +159258,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decls(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -159118,12 +159278,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Decls(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} diff --git a/crates/swc_html_visit/src/generated.rs b/crates/swc_html_visit/src/generated.rs index d8f6dc1e4ca..99e57a70f36 100644 --- a/crates/swc_html_visit/src/generated.rs +++ b/crates/swc_html_visit/src/generated.rs @@ -3804,8 +3804,13 @@ impl VisitWithAstPath for [AttributeToken] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -3828,8 +3833,9 @@ impl VisitWithAstPath for [Attribute] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -3852,8 +3858,9 @@ impl VisitWithAstPath for [Child] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -7260,9 +7267,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -7278,9 +7288,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -7296,8 +7309,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -10780,9 +10798,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -10796,9 +10822,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -10812,9 +10846,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -12275,6 +12313,15 @@ pub type AstNodePath<'ast> = swc_visit::AstNodePath>; #[cfg(any(docsrs, feature = "path"))] pub mod fields { use swc_html_ast::*; + #[inline(always)] + fn assert_initial_index(idx: usize, index: usize) { + #[cfg(debug_assertions)] + if !(idx == usize::MAX || index == usize::MAX) { + { + panic!("Should be usize::MAX"); + } + } + } impl AttributeField { pub(crate) fn set_index(&mut self, index: usize) { match self { @@ -12354,12 +12401,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -12379,12 +12421,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -12435,21 +12472,11 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Attributes(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} diff --git a/crates/swc_xml_visit/src/generated.rs b/crates/swc_xml_visit/src/generated.rs index 0edc54a5012..3cb5440bfb6 100644 --- a/crates/swc_xml_visit/src/generated.rs +++ b/crates/swc_xml_visit/src/generated.rs @@ -3701,8 +3701,13 @@ impl VisitWithAstPath for [AttributeToken] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -3725,8 +3730,9 @@ impl VisitWithAstPath for [Attribute] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -3749,8 +3755,9 @@ impl VisitWithAstPath for [Child] { visitor: &mut V, __ast_path: &mut AstNodePath<'r>, ) { - self.iter().for_each(|item| { - >::visit_with_ast_path(item, visitor, __ast_path) + self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_with_ast_path(item, visitor, &mut *__ast_path) }) } } @@ -6984,9 +6991,12 @@ impl VisitMutWithAstPath for Vec #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -7002,9 +7012,12 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); >::visit_mut_with_ast_path( - item, visitor, __ast_path, + item, + visitor, + &mut *__ast_path, ) }) } @@ -7020,8 +7033,13 @@ impl VisitMutWithAstPath for Vec { #[inline] fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - self.iter_mut().for_each(|item| { - >::visit_mut_with_ast_path(item, visitor, __ast_path) + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::visit_mut_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) }) } } @@ -10365,9 +10383,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -10381,9 +10407,17 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path( + item, + visitor, + &mut *__ast_path, + ) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -10397,9 +10431,13 @@ impl FoldWithAstPath for Vec { #[inline] fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - swc_visit::util::move_map::MoveMap::move_map(self, |item| { - >::fold_with_ast_path(item, visitor, __ast_path) - }) + self.into_iter() + .enumerate() + .map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + >::fold_with_ast_path(item, visitor, &mut *__ast_path) + }) + .collect() } } #[cfg(any(docsrs, feature = "path"))] @@ -11747,6 +11785,15 @@ pub type AstNodePath<'ast> = swc_visit::AstNodePath>; #[cfg(any(docsrs, feature = "path"))] pub mod fields { use swc_xml_ast::*; + #[inline(always)] + fn assert_initial_index(idx: usize, index: usize) { + #[cfg(debug_assertions)] + if !(idx == usize::MAX || index == usize::MAX) { + { + panic!("Should be usize::MAX"); + } + } + } impl AttributeField { pub(crate) fn set_index(&mut self, index: usize) { match self { @@ -11846,12 +11893,7 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} @@ -11902,21 +11944,11 @@ pub mod fields { pub(crate) fn set_index(&mut self, index: usize) { match self { Self::Attributes(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } Self::Children(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; } _ => {} diff --git a/tools/generate-code/src/generators/visitor.rs b/tools/generate-code/src/generators/visitor.rs index a38dd2643a9..e0315b18630 100644 --- a/tools/generate-code/src/generators/visitor.rs +++ b/tools/generate-code/src/generators/visitor.rs @@ -997,26 +997,48 @@ impl Generator { let inner = inner.as_ref(); let inner_ty = quote!(#inner); - match self.kind { - TraitKind::Visit | TraitKind::VisitAll => { + match (self.kind, self.variant) { + (TraitKind::Visit | TraitKind::VisitAll, Variant::Normal) => { parse_quote!(self.iter().for_each(|item| { <#inner_ty as #visit_with_trait_name>::#visit_with_name(item, visitor #ast_path_arg) })) } - TraitKind::VisitMut => { + (TraitKind::Visit | TraitKind::VisitAll, Variant::AstPath) => { + parse_quote!(self.iter().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + <#inner_ty as #visit_with_trait_name>::#visit_with_name(item, visitor, &mut *__ast_path) + })) + } + (TraitKind::VisitMut, Variant::Normal) => { parse_quote!( self.iter_mut().for_each(|item| { <#inner_ty as #visit_with_trait_name>::#visit_with_name(item, visitor #ast_path_arg) }) ) } - TraitKind::Fold => { + (TraitKind::VisitMut, Variant::AstPath) => { + parse_quote!( + self.iter_mut().enumerate().for_each(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + <#inner_ty as #visit_with_trait_name>::#visit_with_name(item, visitor, &mut *__ast_path) + }) + ) + } + (TraitKind::Fold, Variant::Normal) => { parse_quote!( swc_visit::util::move_map::MoveMap::move_map(self, |item| { <#inner_ty as #visit_with_trait_name>::#visit_with_name(item, visitor #ast_path_arg) }) ) } + (TraitKind::Fold, Variant::AstPath) => { + parse_quote!( + self.into_iter().enumerate().map(|(__idx, item)| { + let mut __ast_path = __ast_path.with_index_guard(__idx); + <#inner_ty as #visit_with_trait_name>::#visit_with_name(item, visitor, &mut *__ast_path) + }).collect() + ) + } } } "Option" => { @@ -1239,12 +1261,7 @@ fn field_variant(type_name: &Ident, field: &Field) -> Option<(TokenStream, Optio ); let arg = parse_quote!( Self::#variant_name(idx) => { - #[cfg(debug_assertions)] - if !(*idx == usize::MAX || index == usize::MAX) { - { - panic!("Should be usize::MAX"); - } - } + assert_initial_index(*idx, index); *idx = index; }, @@ -1309,6 +1326,18 @@ fn define_fields(crate_name: &Ident, node_types: &[&Item]) -> Vec { use #crate_name::*; )); + defs.push(parse_quote!( + #[inline(always)] + fn assert_initial_index(idx: usize, index: usize) { + #[cfg(debug_assertions)] + if !(idx == usize::MAX || index == usize::MAX) { + { + panic!("Should be usize::MAX"); + } + } + } + )); + for ty in node_types { let type_name = match ty { Item::Enum(data) => data.ident.clone(),