Skip to content

Rollup of 17 pull requests #141644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3cd065d
macro expansion issue
Kivooeo May 2, 2025
7238669
intrinsics: reduce references to LLVM and update notes on where the i…
RalfJung May 24, 2025
ff33414
ScalarInt: support conversion with signed int types and cmp::Ordering
RalfJung May 24, 2025
77e295c
Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics
Urgau May 25, 2025
b71a127
dist: make sure llvm-project submodule is present
onur-ozkan May 26, 2025
0ea12c3
cfg_version: pull out dedicated syntax test from feature gate test
jieyouxu May 25, 2025
5e31cd3
Support opaque_types_defined_by for SyntheticCoroutineBody
compiler-errors May 26, 2025
1d35ac9
Add missing edition directives for async-await tests
Veykril May 26, 2025
c27aff3
Add test
BoxyUwU May 26, 2025
0497f31
rustc book: fix erratic sentence by making it more simple
tshepang May 26, 2025
19802e8
Remove an unnecessary use of `Box::into_inner`.
nnethercote May 26, 2025
108c16e
bootstrap: translate Windows paths in a way that works for both Cygwi…
jeremyd2019 May 26, 2025
6a8663a
Update mdbook to 0.4.51
ehuss May 26, 2025
c8ed2a7
Remove spastorino from vacations
spastorino May 26, 2025
7fe8263
use custom types to clarify arguments to `emit_ptr_va_arg`
folkertdev May 26, 2025
e0d4cf3
further dedup `WalkItemKind` for `mut_visit` and `visit`
fee1-dead May 27, 2025
3fff727
Use more detailed spans in dyn compat errors within bodies
oli-obk May 26, 2025
89c21f7
Remove out-of-date `noop_*` names.
nnethercote May 19, 2025
77e3594
Rollup merge of #140591 - Kivooeo:new-fix-five, r=davidtwco
compiler-errors May 27, 2025
a0d77f3
Rollup merge of #141536 - Urgau:ambi_wide_ptr-cmp-diag, r=fee1-dead
compiler-errors May 27, 2025
b7854c6
Rollup merge of #141552 - jieyouxu:cfg-version-tests, r=est31
compiler-errors May 27, 2025
f1371a8
Rollup merge of #141556 - jeremyd2019:patch-1, r=jieyouxu
compiler-errors May 27, 2025
7acdffb
Rollup merge of #141563 - nnethercote:rm-noop, r=petrochenkov
compiler-errors May 27, 2025
2c5361a
Rollup merge of #141568 - onur-ozkan:141393-fix, r=Kobzol
compiler-errors May 27, 2025
fbac805
Rollup merge of #141580 - oli-obk:early-dyn-catches-the-incompat, r=c…
compiler-errors May 27, 2025
fb4cc99
Rollup merge of #141582 - RalfJung:cleanup, r=bjorn3
compiler-errors May 27, 2025
9d46af1
Rollup merge of #141584 - compiler-errors:typing-env-synthetic-body, …
compiler-errors May 27, 2025
38d1862
Rollup merge of #141587 - ferrocene:lw-yurotqzwvwlw, r=jieyouxu
compiler-errors May 27, 2025
6344245
Rollup merge of #141594 - BoxyUwU:another_gai_test, r=jieyouxu
compiler-errors May 27, 2025
4b47bd4
Rollup merge of #141596 - tshepang:patch-2, r=Urgau
compiler-errors May 27, 2025
2de2e65
Rollup merge of #141599 - nnethercote:rm-Box-into_inner, r=fmease,che…
compiler-errors May 27, 2025
761dbc7
Rollup merge of #141611 - ehuss:update-mdbook, r=Mark-Simulacrum
compiler-errors May 27, 2025
1aa6a27
Rollup merge of #141616 - spastorino:remove-spastorino-on-vacations, …
compiler-errors May 27, 2025
f0ee1d7
Rollup merge of #141623 - folkertdev:va-arg-explicit-types, r=working…
compiler-errors May 27, 2025
d7e961a
Rollup merge of #141635 - fee1-dead-contrib:push-lmyymwotrspk, r=oli-obk
compiler-errors May 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 4 additions & 149 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ pub trait MutVisitor: Sized {
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
// fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
//
// Any additions to this trait should happen in form of a call to a public
// `noop_*` function that only calls out to the visitor again, not other
// `noop_*` functions. This is a necessary API workaround to the problem of
// not being able to call out to the super default method in an overridden
// default method.
//
// When writing these methods, it is better to use destructuring like this:
//
// fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
Expand Down Expand Up @@ -179,7 +173,7 @@ pub trait MutVisitor: Sized {
}

fn filter_map_expr(&mut self, e: P<Expr>) -> Option<P<Expr>> {
noop_filter_map_expr(self, e)
walk_filter_map_expr(self, e)
}

fn visit_generic_arg(&mut self, arg: &mut GenericArg) {
Expand Down Expand Up @@ -381,14 +375,11 @@ super::common_visitor_and_walkers!((mut) MutVisitor);
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
/// method.
//
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_clobber<T: DummyAstNode>(t: &mut T, f: impl FnOnce(T) -> T) {
let old_t = std::mem::replace(t, T::dummy());
*t = f(old_t);
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline]
fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
where
Expand All @@ -399,7 +390,6 @@ where
}
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline]
fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
where
Expand All @@ -410,7 +400,6 @@ where
}
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline]
fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
where
Expand All @@ -421,25 +410,21 @@ where
}
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_attrs<T: MutVisitor>(vis: &mut T, attrs: &mut AttrVec) {
for attr in attrs.iter_mut() {
vis.visit_attribute(attr);
}
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[allow(unused)]
fn visit_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut Vec<P<Expr>>) {
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_thin_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut ThinVec<P<Expr>>) {
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
match args {
AttrArgs::Empty => {}
Expand All @@ -451,7 +436,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
}
}

// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_delim_args<T: MutVisitor>(vis: &mut T, args: &mut DelimArgs) {
let DelimArgs { dspan, delim: _, tokens: _ } = args;
let DelimSpan { open, close } = dspan;
Expand Down Expand Up @@ -1041,78 +1025,6 @@ pub fn walk_item_kind<K: WalkItemKind>(
kind.walk(span, id, visibility, ctxt, vis)
}

impl WalkItemKind for AssocItemKind {
type Ctxt = AssocCtxt;
fn walk<V: MutVisitor>(
&mut self,
span: Span,
id: NodeId,
visibility: &mut Visibility,
ctxt: Self::Ctxt,
visitor: &mut V,
) {
match self {
AssocItemKind::Const(item) => {
walk_const_item(visitor, item);
}
AssocItemKind::Fn(func) => {
visitor.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), visibility, &mut *func), span, id);
}
AssocItemKind::Type(box TyAlias {
defaultness,
ident,
generics,
where_clauses,
bounds,
ty,
}) => {
visit_defaultness(visitor, defaultness);
visitor.visit_ident(ident);
visitor.visit_generics(generics);
visit_bounds(visitor, bounds, BoundKind::Bound);
visit_opt(ty, |ty| visitor.visit_ty(ty));
walk_ty_alias_where_clauses(visitor, where_clauses);
}
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
AssocItemKind::Delegation(box Delegation {
id,
qself,
path,
ident,
rename,
body,
from_glob: _,
}) => {
visitor.visit_id(id);
visitor.visit_qself(qself);
visitor.visit_path(path);
visitor.visit_ident(ident);
if let Some(rename) = rename {
visitor.visit_ident(rename);
}
if let Some(body) = body {
visitor.visit_block(body);
}
}
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
visitor.visit_qself(qself);
visitor.visit_path(prefix);
if let Some(suffixes) = suffixes {
for (ident, rename) in suffixes {
visitor.visit_ident(ident);
if let Some(rename) = rename {
visitor.visit_ident(rename);
}
}
}
if let Some(body) = body {
visitor.visit_block(body);
}
}
}
}
}

pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
let Crate { attrs, items, spans, id, is_placeholder: _ } = krate;
vis.visit_id(id);
Expand All @@ -1123,14 +1035,6 @@ pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
vis.visit_span(inject_use_span);
}

pub fn walk_item(visitor: &mut impl MutVisitor, item: &mut P<Item<impl WalkItemKind<Ctxt = ()>>>) {
walk_item_ctxt(visitor, item, ())
}

pub fn walk_assoc_item(visitor: &mut impl MutVisitor, item: &mut P<AssocItem>, ctxt: AssocCtxt) {
walk_item_ctxt(visitor, item, ctxt)
}

pub fn walk_flat_map_item(vis: &mut impl MutVisitor, mut item: P<Item>) -> SmallVec<[P<Item>; 1]> {
vis.visit_item(&mut item);
smallvec![item]
Expand All @@ -1153,53 +1057,6 @@ pub fn walk_flat_map_assoc_item(
smallvec![item]
}

impl WalkItemKind for ForeignItemKind {
type Ctxt = ();
fn walk<V: MutVisitor>(
&mut self,
span: Span,
id: NodeId,
visibility: &mut Visibility,
_ctxt: Self::Ctxt,
visitor: &mut V,
) {
match self {
ForeignItemKind::Static(box StaticItem {
ident,
ty,
mutability: _,
expr,
safety: _,
define_opaque,
}) => {
visitor.visit_ident(ident);
visitor.visit_ty(ty);
visit_opt(expr, |expr| visitor.visit_expr(expr));
walk_define_opaques(visitor, define_opaque);
}
ForeignItemKind::Fn(func) => {
visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, visibility, &mut *func), span, id);
}
ForeignItemKind::TyAlias(box TyAlias {
defaultness,
ident,
generics,
where_clauses,
bounds,
ty,
}) => {
visit_defaultness(visitor, defaultness);
visitor.visit_ident(ident);
visitor.visit_generics(generics);
visit_bounds(visitor, bounds, BoundKind::Bound);
visit_opt(ty, |ty| visitor.visit_ty(ty));
walk_ty_alias_where_clauses(visitor, where_clauses);
}
ForeignItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
}
}
}

pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
let Pat { id, kind, span, tokens: _ } = pat.deref_mut();
vis.visit_id(id);
Expand Down Expand Up @@ -1500,11 +1357,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
vis.visit_span(span);
}

pub fn noop_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: P<Expr>) -> Option<P<Expr>> {
Some({
vis.visit_expr(&mut e);
e
})
pub fn walk_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: P<Expr>) -> Option<P<Expr>> {
vis.visit_expr(&mut e);
Some(e)
}

pub fn walk_flat_map_stmt<T: MutVisitor>(
Expand Down
Loading
Loading