@@ -368,14 +368,6 @@ pub trait MutVisitor: Sized {
368368
369369super :: common_visitor_and_walkers!( ( mut ) MutVisitor ) ;
370370
371- /// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
372- /// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
373- /// method.
374- pub fn visit_clobber < T : DummyAstNode > ( t : & mut T , f : impl FnOnce ( T ) -> T ) {
375- let old_t = std:: mem:: replace ( t, T :: dummy ( ) ) ;
376- * t = f ( old_t) ;
377- }
378-
379371#[ inline]
380372fn visit_vec < T , F > ( elems : & mut Vec < T > , mut visit_elem : F )
381373where
@@ -1417,101 +1409,6 @@ fn walk_capture_by<T: MutVisitor>(vis: &mut T, capture_by: &mut CaptureBy) {
14171409 }
14181410}
14191411
1420- /// Some value for the AST node that is valid but possibly meaningless. Similar
1421- /// to `Default` but not intended for wide use. The value will never be used
1422- /// meaningfully, it exists just to support unwinding in `visit_clobber` in the
1423- /// case where its closure panics.
1424- pub trait DummyAstNode {
1425- fn dummy ( ) -> Self ;
1426- }
1427-
1428- impl < T > DummyAstNode for Option < T > {
1429- fn dummy ( ) -> Self {
1430- Default :: default ( )
1431- }
1432- }
1433-
1434- impl < T : DummyAstNode + ' static > DummyAstNode for P < T > {
1435- fn dummy ( ) -> Self {
1436- P ( DummyAstNode :: dummy ( ) )
1437- }
1438- }
1439-
1440- impl DummyAstNode for Item {
1441- fn dummy ( ) -> Self {
1442- Item {
1443- attrs : Default :: default ( ) ,
1444- id : DUMMY_NODE_ID ,
1445- span : Default :: default ( ) ,
1446- vis : Visibility {
1447- kind : VisibilityKind :: Public ,
1448- span : Default :: default ( ) ,
1449- tokens : Default :: default ( ) ,
1450- } ,
1451- kind : ItemKind :: ExternCrate ( None , Ident :: dummy ( ) ) ,
1452- tokens : Default :: default ( ) ,
1453- }
1454- }
1455- }
1456-
1457- impl DummyAstNode for Expr {
1458- fn dummy ( ) -> Self {
1459- Expr {
1460- id : DUMMY_NODE_ID ,
1461- kind : ExprKind :: Dummy ,
1462- span : Default :: default ( ) ,
1463- attrs : Default :: default ( ) ,
1464- tokens : Default :: default ( ) ,
1465- }
1466- }
1467- }
1468-
1469- impl DummyAstNode for Ty {
1470- fn dummy ( ) -> Self {
1471- Ty {
1472- id : DUMMY_NODE_ID ,
1473- kind : TyKind :: Dummy ,
1474- span : Default :: default ( ) ,
1475- tokens : Default :: default ( ) ,
1476- }
1477- }
1478- }
1479-
1480- impl DummyAstNode for Pat {
1481- fn dummy ( ) -> Self {
1482- Pat {
1483- id : DUMMY_NODE_ID ,
1484- kind : PatKind :: Wild ,
1485- span : Default :: default ( ) ,
1486- tokens : Default :: default ( ) ,
1487- }
1488- }
1489- }
1490-
1491- impl DummyAstNode for Stmt {
1492- fn dummy ( ) -> Self {
1493- Stmt { id : DUMMY_NODE_ID , kind : StmtKind :: Empty , span : Default :: default ( ) }
1494- }
1495- }
1496-
1497- impl DummyAstNode for Crate {
1498- fn dummy ( ) -> Self {
1499- Crate {
1500- attrs : Default :: default ( ) ,
1501- items : Default :: default ( ) ,
1502- spans : Default :: default ( ) ,
1503- id : DUMMY_NODE_ID ,
1504- is_placeholder : Default :: default ( ) ,
1505- }
1506- }
1507- }
1508-
1509- impl < N : DummyAstNode , T : DummyAstNode > DummyAstNode for crate :: ast_traits:: AstNodeWrapper < N , T > {
1510- fn dummy ( ) -> Self {
1511- crate :: ast_traits:: AstNodeWrapper :: new ( N :: dummy ( ) , T :: dummy ( ) )
1512- }
1513- }
1514-
15151412#[ derive( Debug ) ]
15161413pub enum FnKind < ' a > {
15171414 /// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
0 commit comments