Skip to content

Commit 8909f70

Browse files
committed
Change fold_qpath to fold_qself.
It's simpler that way.
1 parent f97e896 commit 8909f70

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/libsyntax/fold.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ pub trait Folder : Sized {
168168
noop_fold_path(p, self)
169169
}
170170

171-
fn fold_qpath(&mut self, qs: Option<QSelf>, p: Path) -> (Option<QSelf>, Path) {
172-
noop_fold_qpath(qs, p, self)
171+
fn fold_qself(&mut self, qs: Option<QSelf>) -> Option<QSelf> {
172+
noop_fold_qself(qs, self)
173173
}
174174

175175
fn fold_generic_args(&mut self, p: GenericArgs) -> GenericArgs {
@@ -367,8 +367,7 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
367367
TyKind::Tup(tys) => TyKind::Tup(tys.move_map(|ty| fld.fold_ty(ty))),
368368
TyKind::Paren(ty) => TyKind::Paren(fld.fold_ty(ty)),
369369
TyKind::Path(qself, path) => {
370-
let (qself, path) = fld.fold_qpath(qself, path);
371-
TyKind::Path(qself, path)
370+
TyKind::Path(fld.fold_qself(qself), fld.fold_path(path))
372371
}
373372
TyKind::Array(ty, length) => {
374373
TyKind::Array(fld.fold_ty(ty), fld.fold_anon_const(length))
@@ -425,17 +424,14 @@ pub fn noop_fold_path<T: Folder>(Path { segments, span }: Path, fld: &mut T) ->
425424
}
426425
}
427426

428-
pub fn noop_fold_qpath<T: Folder>(qself: Option<QSelf>,
429-
path: Path,
430-
fld: &mut T) -> (Option<QSelf>, Path) {
431-
let qself = qself.map(|QSelf { ty, path_span, position }| {
427+
pub fn noop_fold_qself<T: Folder>(qself: Option<QSelf>, fld: &mut T) -> Option<QSelf> {
428+
qself.map(|QSelf { ty, path_span, position }| {
432429
QSelf {
433430
ty: fld.fold_ty(ty),
434431
path_span: fld.new_span(path_span),
435432
position,
436433
}
437-
});
438-
(qself, fld.fold_path(path))
434+
})
439435
}
440436

441437
pub fn noop_fold_generic_args<T: Folder>(generic_args: GenericArgs, fld: &mut T) -> GenericArgs
@@ -1083,8 +1079,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
10831079
pats.move_map(|x| folder.fold_pat(x)), ddpos)
10841080
}
10851081
PatKind::Path(qself, pth) => {
1086-
let (qself, pth) = folder.fold_qpath(qself, pth);
1087-
PatKind::Path(qself, pth)
1082+
PatKind::Path(folder.fold_qself(qself), folder.fold_path(pth))
10881083
}
10891084
PatKind::Struct(pth, fields, etc) => {
10901085
let pth = folder.fold_path(pth);
@@ -1251,8 +1246,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
12511246
lim)
12521247
}
12531248
ExprKind::Path(qself, path) => {
1254-
let (qself, path) = folder.fold_qpath(qself, path);
1255-
ExprKind::Path(qself, path)
1249+
ExprKind::Path(folder.fold_qself(qself), folder.fold_path(path))
12561250
}
12571251
ExprKind::Break(opt_label, opt_expr) => {
12581252
ExprKind::Break(opt_label.map(|label| folder.fold_label(label)),

0 commit comments

Comments
 (0)