Skip to content

Commit b924f94

Browse files
committed
Auto merge of #162284 - JonathanBrouwer:rollup-xBLkMAP, r=JonathanBrouwer
Rollup of 7 pull requests Successful merges: - #157808 (sanitizers: Implement support for the sanitize ignorelist) - #160660 (c-variadic: use `emit_ptr_va_arg` for `va_arg` on `sparc`) - #162237 (make -Ctarget-feature warnings more explicitly FCWs) - #160111 (Generalize Decodable impl for arrays to all types) - #162174 (Update internal docs & tests to use `!` rather than `Infallible` in relation to `Try`) - #162226 (Clean up the AST visitor) - #162281 (rustc-dev-guide subtree update)
2 parents 71238e2 + c97aa40 commit b924f94

148 files changed

Lines changed: 2606 additions & 1253 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.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4751,6 +4751,7 @@ name = "rustc_sanitizers"
47514751
version = "0.0.0"
47524752
dependencies = [
47534753
"bitflags",
4754+
"libc",
47544755
"rustc_abi",
47554756
"rustc_data_structures",
47564757
"rustc_hir",

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ where
9797
}
9898
}
9999

100-
impl<V: MutVisitor, T> MutVisitable<V> for (T,)
101-
where
102-
T: MutVisitable<V>,
103-
{
104-
type Extra = T::Extra;
105-
fn visit_mut(&mut self, visitor: &mut V, extra: Self::Extra) {
106-
self.0.visit_mut(visitor, extra);
107-
}
108-
}
109-
110100
impl<V: MutVisitor, T1, T2> MutVisitable<V> for (T1, T2)
111101
where
112102
T1: MutVisitable<V, Extra = ()>,
@@ -154,23 +144,17 @@ pub trait MutWalkable<V: MutVisitor> {
154144
}
155145

156146
macro_rules! visit_visitable {
157-
(mut $visitor:expr, $($expr:expr),* $(,)?) => {{
147+
($visitor:expr, $($expr:expr),* $(,)?) => {{
158148
$(MutVisitable::visit_mut($expr, $visitor, ());)*
159149
}};
160150
}
161151

162152
macro_rules! visit_visitable_with {
163-
(mut $visitor:expr, $expr:expr, $extra:expr $(,)?) => {
153+
($visitor:expr, $expr:expr, $extra:expr $(,)?) => {
164154
MutVisitable::visit_mut($expr, $visitor, $extra)
165155
};
166156
}
167157

168-
macro_rules! walk_walkable {
169-
($visitor:expr, $expr:expr, mut) => {
170-
MutWalkable::walk_mut($expr, $visitor)
171-
};
172-
}
173-
174158
macro_rules! impl_visitable {
175159
(|&mut $self:ident: $self_ty:ty,
176160
$vis:ident: &mut $vis_ty:ident,
@@ -186,10 +170,9 @@ macro_rules! impl_visitable {
186170
}
187171

188172
macro_rules! impl_walkable {
189-
($(<$K:ident: $Kb:ident>)? |&mut $self:ident: $self_ty:ty,
173+
(|&mut $self:ident: $self_ty:ty,
190174
$vis:ident: &mut $vis_ty:ident| $block:block) => {
191-
#[allow(unused_parens, non_local_definitions)]
192-
impl<$($K: $Kb,)? $vis_ty: MutVisitor> MutWalkable<$vis_ty> for $self_ty {
175+
impl<$vis_ty: MutVisitor> MutWalkable<$vis_ty> for $self_ty {
193176
fn walk_mut(&mut $self, $vis: &mut $vis_ty) -> V::Result {
194177
$block
195178
}
@@ -198,15 +181,15 @@ macro_rules! impl_walkable {
198181
}
199182

200183
macro_rules! impl_visitable_noop {
201-
(<mut> $($ty:ty,)*) => {
184+
($($ty:ty,)*) => {
202185
$(
203186
impl_visitable!(|&mut self: $ty, _vis: &mut V, _extra: ()| {});
204187
)*
205188
};
206189
}
207190

208191
macro_rules! impl_visitable_list {
209-
(<mut> $($ty:ty,)*) => {
192+
($($ty:ty,)*) => {
210193
$(impl<V: MutVisitor, T> MutVisitable<V> for $ty
211194
where
212195
for<'a> &'a mut $ty: IntoIterator<Item = &'a mut T>,
@@ -225,7 +208,7 @@ macro_rules! impl_visitable_list {
225208
}
226209

227210
macro_rules! impl_visitable_direct {
228-
(<mut> $($ty:ty,)*) => {
211+
($($ty:ty,)*) => {
229212
$(impl_visitable!(
230213
|&mut self: $ty, visitor: &mut V, _extra: ()| {
231214
MutWalkable::walk_mut(self, visitor)
@@ -235,75 +218,61 @@ macro_rules! impl_visitable_direct {
235218
}
236219

237220
macro_rules! impl_visitable_calling_walkable {
238-
(<mut>
221+
(
239222
$( fn $method:ident($ty:ty $(, $extra_name:ident: $extra_ty:ty)?); )*
240223
) => {
241224
$(fn $method(&mut self, node: &mut $ty $(, $extra_name:$extra_ty)?) {
242225
impl_visitable!(|&mut self: $ty, visitor: &mut V, extra: ($($extra_ty)?)| {
243226
let ($($extra_name)?) = extra;
244227
visitor.$method(self $(, $extra_name)?);
245228
});
246-
walk_walkable!(self, node, mut)
229+
MutWalkable::walk_mut(node, self)
247230
})*
248231
}
249232
}
250233

251234
macro_rules! define_named_walk {
252-
((mut) $Visitor:ident
235+
($Visitor:ident
253236
$( pub fn $method:ident($ty:ty); )*
254237
) => {
255238
$(pub fn $method<V: $Visitor>(visitor: &mut V, node: &mut $ty) {
256-
walk_walkable!(visitor, node, mut)
239+
MutWalkable::walk_mut(node, visitor)
257240
})*
258241
};
259242
}
260243

261244
super::common_visitor_and_walkers!((mut) MutVisitor);
262245

263246
macro_rules! generate_flat_map_visitor_fns {
264-
($($name:ident, $Ty:ty, $flat_map_fn:ident$(, $param:ident: $ParamTy:ty)*;)+) => {
247+
($($flat_map_fn:ident, $Ty:ty $(, $param:ident: $ParamTy:ty)?;)+) => {
265248
$(
266249
#[allow(unused_parens)]
267250
impl<V: MutVisitor> MutVisitable<V> for ThinVec<$Ty> {
268-
type Extra = ($($ParamTy),*);
251+
type Extra = ($($ParamTy)?);
269252

270253
#[inline]
271-
fn visit_mut(
272-
&mut self,
273-
visitor: &mut V,
274-
($($param),*): Self::Extra,
275-
) -> V::Result {
276-
$name(visitor, self $(, $param)*)
254+
fn visit_mut(&mut self, visitor: &mut V, ($($param)?): Self::Extra) -> V::Result {
255+
self.flat_map_in_place(|value| visitor.$flat_map_fn(value $(, $param)?));
277256
}
278257
}
279-
280-
fn $name<V: MutVisitor>(
281-
vis: &mut V,
282-
values: &mut ThinVec<$Ty>,
283-
$(
284-
$param: $ParamTy,
285-
)*
286-
) {
287-
values.flat_map_in_place(|value| vis.$flat_map_fn(value$(,$param)*));
288-
}
289258
)+
290259
}
291260
}
292261

293262
generate_flat_map_visitor_fns! {
294-
visit_items, Box<Item>, flat_map_item;
295-
visit_foreign_items, Box<ForeignItem>, flat_map_foreign_item;
296-
visit_generic_params, GenericParam, flat_map_generic_param;
297-
visit_stmts, Stmt, flat_map_stmt;
298-
visit_exprs, Box<Expr>, filter_map_expr;
299-
visit_expr_fields, ExprField, flat_map_expr_field;
300-
visit_pat_fields, PatField, flat_map_pat_field;
301-
visit_variants, Variant, flat_map_variant;
302-
visit_assoc_items, Box<AssocItem>, flat_map_assoc_item, ctxt: AssocCtxt;
303-
visit_where_predicates, WherePredicate, flat_map_where_predicate;
304-
visit_params, Param, flat_map_param;
305-
visit_field_defs, FieldDef, flat_map_field_def;
306-
visit_arms, Arm, flat_map_arm;
263+
flat_map_item, Box<Item>;
264+
flat_map_foreign_item, Box<ForeignItem>;
265+
flat_map_generic_param, GenericParam;
266+
flat_map_stmt, Stmt;
267+
filter_map_expr, Box<Expr>; // the odd one out; it works because `Option` impls `IntoIterator`
268+
flat_map_expr_field, ExprField;
269+
flat_map_pat_field, PatField;
270+
flat_map_variant, Variant;
271+
flat_map_assoc_item, Box<AssocItem>, ctxt: AssocCtxt;
272+
flat_map_where_predicate, WherePredicate;
273+
flat_map_param, Param;
274+
flat_map_field_def, FieldDef;
275+
flat_map_arm, Arm;
307276
}
308277

309278
pub fn walk_flat_map_pat_field<T: MutVisitor>(
@@ -316,7 +285,11 @@ pub fn walk_flat_map_pat_field<T: MutVisitor>(
316285

317286
macro_rules! generate_walk_flat_map_fns {
318287
($($fn_name:ident($Ty:ty$(,$extra_name:ident: $ExtraTy:ty)*) => $visit_fn_name:ident;)+) => {$(
319-
pub fn $fn_name<V: MutVisitor>(vis: &mut V, mut value: $Ty$(,$extra_name: $ExtraTy)*) -> SmallVec<[$Ty; 1]> {
288+
pub fn $fn_name<V: MutVisitor>(
289+
vis: &mut V,
290+
mut value: $Ty
291+
$(,$extra_name: $ExtraTy)*
292+
) -> SmallVec<[$Ty; 1]> {
320293
vis.$visit_fn_name(&mut value$(,$extra_name)*);
321294
smallvec![value]
322295
}

0 commit comments

Comments
 (0)