Skip to content

Commit c583fa6

Browse files
committed
Auto merge of #141644 - compiler-errors:rollup-gl5hize, r=compiler-errors
Rollup of 17 pull requests Successful merges: - #140591 (Fix malformed suggestion for E0061 when method is a macro token in macro context) - #141536 (Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics) - #141552 (Pull out dedicated `cfg_version` syntax test from feature gate test) - #141556 (bootstrap: translate Windows paths in a way that works for both Cygwin and MSYS2) - #141563 (Remove out-of-date `noop_*` names.) - #141568 (dist: make sure llvm-project submodule is present) - #141580 (Use more detailed spans in dyn compat errors within bodies) - #141582 (intrinsics, ScalarInt: minor cleanup) - #141584 (Support `opaque_types_defined_by` for `SyntheticCoroutineBody`) - #141587 (Add missing edition directives for async-await tests) - #141594 (Add `generic_arg_infer` test) - #141596 (rustc book: fix erratic sentence by making it more simple) - #141599 (Remove an unnecessary use of `Box::into_inner`.) - #141611 (Update mdbook to 0.4.51) - #141616 (Remove spastorino from vacations) - #141623 (use custom types to clarify arguments to `emit_ptr_va_arg`) - #141635 (further dedup `WalkItemKind` for `mut_visit` and `visit`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 642e49b + d7e961a commit c583fa6

93 files changed

Lines changed: 1281 additions & 997 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎compiler/rustc_ast/src/mut_visit.rs‎

Lines changed: 4 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ pub trait MutVisitor: Sized {
4040
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
4141
// fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
4242
//
43-
// Any additions to this trait should happen in form of a call to a public
44-
// `noop_*` function that only calls out to the visitor again, not other
45-
// `noop_*` functions. This is a necessary API workaround to the problem of
46-
// not being able to call out to the super default method in an overridden
47-
// default method.
48-
//
4943
// When writing these methods, it is better to use destructuring like this:
5044
//
5145
// fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
@@ -179,7 +173,7 @@ pub trait MutVisitor: Sized {
179173
}
180174

181175
fnfilter_map_expr(&mutself,e:P<Expr>) -> Option<P<Expr>>{
182-
noop_filter_map_expr(self, e)
176+
walk_filter_map_expr(self, e)
183177
}
184178

185179
fnvisit_generic_arg(&mutself,arg:&mutGenericArg){
@@ -381,14 +375,11 @@ super::common_visitor_and_walkers!((mut) MutVisitor);
381375
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
382376
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
383377
/// method.
384-
//
385-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
386378
pubfnvisit_clobber<T:DummyAstNode>(t:&mutT,f:implFnOnce(T) -> T){
387379
let old_t = std::mem::replace(t,T::dummy());
388380
*t = f(old_t);
389381
}
390382

391-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
392383
#[inline]
393384
fnvisit_vec<T,F>(elems:&mutVec<T>,mutvisit_elem:F)
394385
where
@@ -399,7 +390,6 @@ where
399390
}
400391
}
401392

402-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
403393
#[inline]
404394
fnvisit_thin_vec<T,F>(elems:&mutThinVec<T>,mutvisit_elem:F)
405395
where
@@ -410,7 +400,6 @@ where
410400
}
411401
}
412402

413-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
414403
#[inline]
415404
fnvisit_opt<T,F>(opt:&mutOption<T>,mutvisit_elem:F)
416405
where
@@ -421,25 +410,21 @@ where
421410
}
422411
}
423412

424-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
425413
fnvisit_attrs<T:MutVisitor>(vis:&mutT,attrs:&mutAttrVec){
426414
for attr in attrs.iter_mut(){
427415
vis.visit_attribute(attr);
428416
}
429417
}
430418

431-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
432419
#[allow(unused)]
433420
fnvisit_exprs<T:MutVisitor>(vis:&mutT,exprs:&mutVec<P<Expr>>){
434421
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
435422
}
436423

437-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
438424
fnvisit_thin_exprs<T:MutVisitor>(vis:&mutT,exprs:&mutThinVec<P<Expr>>){
439425
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
440426
}
441427

442-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
443428
fnvisit_attr_args<T:MutVisitor>(vis:&mutT,args:&mutAttrArgs){
444429
match args {
445430
AttrArgs::Empty => {}
@@ -451,7 +436,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
451436
}
452437
}
453438

454-
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
455439
fnvisit_delim_args<T:MutVisitor>(vis:&mutT,args:&mutDelimArgs){
456440
letDelimArgs{ dspan,delim: _,tokens: _ } = args;
457441
letDelimSpan{ open, close } = dspan;
@@ -1041,78 +1025,6 @@ pub fn walk_item_kind<K: WalkItemKind>(
10411025
kind.walk(span, id, visibility, ctxt, vis)
10421026
}
10431027

1044-
implWalkItemKindforAssocItemKind{
1045-
typeCtxt = AssocCtxt;
1046-
fnwalk<V:MutVisitor>(
1047-
&mutself,
1048-
span:Span,
1049-
id:NodeId,
1050-
visibility:&mutVisibility,
1051-
ctxt:Self::Ctxt,
1052-
visitor:&mutV,
1053-
){
1054-
matchself{
1055-
AssocItemKind::Const(item) => {
1056-
walk_const_item(visitor, item);
1057-
}
1058-
AssocItemKind::Fn(func) => {
1059-
visitor.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), visibility,&mut*func), span, id);
1060-
}
1061-
AssocItemKind::Type(box TyAlias{
1062-
defaultness,
1063-
ident,
1064-
generics,
1065-
where_clauses,
1066-
bounds,
1067-
ty,
1068-
}) => {
1069-
visit_defaultness(visitor, defaultness);
1070-
visitor.visit_ident(ident);
1071-
visitor.visit_generics(generics);
1072-
visit_bounds(visitor, bounds,BoundKind::Bound);
1073-
visit_opt(ty, |ty| visitor.visit_ty(ty));
1074-
walk_ty_alias_where_clauses(visitor, where_clauses);
1075-
}
1076-
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
1077-
AssocItemKind::Delegation(box Delegation{
1078-
id,
1079-
qself,
1080-
path,
1081-
ident,
1082-
rename,
1083-
body,
1084-
from_glob: _,
1085-
}) => {
1086-
visitor.visit_id(id);
1087-
visitor.visit_qself(qself);
1088-
visitor.visit_path(path);
1089-
visitor.visit_ident(ident);
1090-
ifletSome(rename) = rename {
1091-
visitor.visit_ident(rename);
1092-
}
1093-
ifletSome(body) = body {
1094-
visitor.visit_block(body);
1095-
}
1096-
}
1097-
AssocItemKind::DelegationMac(box DelegationMac{ qself, prefix, suffixes, body }) => {
1098-
visitor.visit_qself(qself);
1099-
visitor.visit_path(prefix);
1100-
ifletSome(suffixes) = suffixes {
1101-
for(ident, rename)in suffixes {
1102-
visitor.visit_ident(ident);
1103-
ifletSome(rename) = rename {
1104-
visitor.visit_ident(rename);
1105-
}
1106-
}
1107-
}
1108-
ifletSome(body) = body {
1109-
visitor.visit_block(body);
1110-
}
1111-
}
1112-
}
1113-
}
1114-
}
1115-
11161028
pubfnwalk_crate<T:MutVisitor>(vis:&mutT,krate:&mutCrate){
11171029
letCrate{ attrs, items, spans, id,is_placeholder: _ } = krate;
11181030
vis.visit_id(id);
@@ -1123,14 +1035,6 @@ pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
11231035
vis.visit_span(inject_use_span);
11241036
}
11251037

1126-
pubfnwalk_item(visitor:&mutimplMutVisitor,item:&mutP<Item<implWalkItemKind<Ctxt = ()>>>){
1127-
walk_item_ctxt(visitor, item,())
1128-
}
1129-
1130-
pubfnwalk_assoc_item(visitor:&mutimplMutVisitor,item:&mutP<AssocItem>,ctxt:AssocCtxt){
1131-
walk_item_ctxt(visitor, item, ctxt)
1132-
}
1133-
11341038
pubfnwalk_flat_map_item(vis:&mutimplMutVisitor,mutitem:P<Item>) -> SmallVec<[P<Item>;1]>{
11351039
vis.visit_item(&mut item);
11361040
smallvec![item]
@@ -1153,53 +1057,6 @@ pub fn walk_flat_map_assoc_item(
11531057
smallvec![item]
11541058
}
11551059

1156-
implWalkItemKindforForeignItemKind{
1157-
typeCtxt = ();
1158-
fnwalk<V:MutVisitor>(
1159-
&mutself,
1160-
span:Span,
1161-
id:NodeId,
1162-
visibility:&mutVisibility,
1163-
_ctxt:Self::Ctxt,
1164-
visitor:&mutV,
1165-
){
1166-
matchself{
1167-
ForeignItemKind::Static(box StaticItem{
1168-
ident,
1169-
ty,
1170-
mutability: _,
1171-
expr,
1172-
safety: _,
1173-
define_opaque,
1174-
}) => {
1175-
visitor.visit_ident(ident);
1176-
visitor.visit_ty(ty);
1177-
visit_opt(expr, |expr| visitor.visit_expr(expr));
1178-
walk_define_opaques(visitor, define_opaque);
1179-
}
1180-
ForeignItemKind::Fn(func) => {
1181-
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, visibility,&mut*func), span, id);
1182-
}
1183-
ForeignItemKind::TyAlias(box TyAlias{
1184-
defaultness,
1185-
ident,
1186-
generics,
1187-
where_clauses,
1188-
bounds,
1189-
ty,
1190-
}) => {
1191-
visit_defaultness(visitor, defaultness);
1192-
visitor.visit_ident(ident);
1193-
visitor.visit_generics(generics);
1194-
visit_bounds(visitor, bounds,BoundKind::Bound);
1195-
visit_opt(ty, |ty| visitor.visit_ty(ty));
1196-
walk_ty_alias_where_clauses(visitor, where_clauses);
1197-
}
1198-
ForeignItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
1199-
}
1200-
}
1201-
}
1202-
12031060
pubfnwalk_pat<T:MutVisitor>(vis:&mutT,pat:&mutP<Pat>){
12041061
letPat{ id, kind, span,tokens: _ } = pat.deref_mut();
12051062
vis.visit_id(id);
@@ -1500,11 +1357,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
15001357
vis.visit_span(span);
15011358
}
15021359

1503-
pubfnnoop_filter_map_expr<T:MutVisitor>(vis:&mutT,mute:P<Expr>) -> Option<P<Expr>>{
1504-
Some({
1505-
vis.visit_expr(&mut e);
1506-
e
1507-
})
1360+
pubfnwalk_filter_map_expr<T:MutVisitor>(vis:&mutT,mute:P<Expr>) -> Option<P<Expr>>{
1361+
vis.visit_expr(&mut e);
1362+
Some(e)
15081363
}
15091364

15101365
pubfnwalk_flat_map_stmt<T:MutVisitor>(

0 commit comments

Comments
 (0)