ast: Generalize item kind visiting
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
This commit is contained in:
parent
38dd569150
commit
5be9fdd636
18 changed files with 410 additions and 382 deletions
|
@ -34,6 +34,10 @@ impl<A: Array> ExpectOne<A> for SmallVec<A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait NoopVisitItemKind {
|
||||||
|
fn noop_visit(&mut self, visitor: &mut impl MutVisitor);
|
||||||
|
}
|
||||||
|
|
||||||
pub trait MutVisitor: Sized {
|
pub trait MutVisitor: Sized {
|
||||||
/// Mutable token visiting only exists for the `macro_rules` token marker and should not be
|
/// Mutable token visiting only exists for the `macro_rules` token marker and should not be
|
||||||
/// used otherwise. Token visitor would be entirely separate from the regular visitor if
|
/// used otherwise. Token visitor would be entirely separate from the regular visitor if
|
||||||
|
@ -90,7 +94,7 @@ pub trait MutVisitor: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_foreign_item(&mut self, ni: P<ForeignItem>) -> SmallVec<[P<ForeignItem>; 1]> {
|
fn flat_map_foreign_item(&mut self, ni: P<ForeignItem>) -> SmallVec<[P<ForeignItem>; 1]> {
|
||||||
noop_flat_map_foreign_item(ni, self)
|
noop_flat_map_item(ni, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_item(&mut self, i: P<Item>) -> SmallVec<[P<Item>; 1]> {
|
fn flat_map_item(&mut self, i: P<Item>) -> SmallVec<[P<Item>; 1]> {
|
||||||
|
@ -105,16 +109,12 @@ pub trait MutVisitor: Sized {
|
||||||
noop_flat_map_field_def(fd, self)
|
noop_flat_map_field_def(fd, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_item_kind(&mut self, i: &mut ItemKind) {
|
|
||||||
noop_visit_item_kind(i, self);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn flat_map_trait_item(&mut self, i: P<AssocItem>) -> SmallVec<[P<AssocItem>; 1]> {
|
fn flat_map_trait_item(&mut self, i: P<AssocItem>) -> SmallVec<[P<AssocItem>; 1]> {
|
||||||
noop_flat_map_assoc_item(i, self)
|
noop_flat_map_item(i, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_impl_item(&mut self, i: P<AssocItem>) -> SmallVec<[P<AssocItem>; 1]> {
|
fn flat_map_impl_item(&mut self, i: P<AssocItem>) -> SmallVec<[P<AssocItem>; 1]> {
|
||||||
noop_flat_map_assoc_item(i, self)
|
noop_flat_map_item(i, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_fn_decl(&mut self, d: &mut P<FnDecl>) {
|
fn visit_fn_decl(&mut self, d: &mut P<FnDecl>) {
|
||||||
|
@ -1068,8 +1068,13 @@ pub fn noop_visit_block<T: MutVisitor>(block: &mut P<Block>, vis: &mut T) {
|
||||||
visit_lazy_tts(tokens, vis);
|
visit_lazy_tts(tokens, vis);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
|
pub fn noop_visit_item_kind(kind: &mut impl NoopVisitItemKind, vis: &mut impl MutVisitor) {
|
||||||
match kind {
|
kind.noop_visit(vis)
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NoopVisitItemKind for ItemKind {
|
||||||
|
fn noop_visit(&mut self, vis: &mut impl MutVisitor) {
|
||||||
|
match self {
|
||||||
ItemKind::ExternCrate(_orig_name) => {}
|
ItemKind::ExternCrate(_orig_name) => {}
|
||||||
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
|
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
|
||||||
ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => {
|
ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => {
|
||||||
|
@ -1099,7 +1104,12 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
|
||||||
ItemKind::ForeignMod(nm) => vis.visit_foreign_mod(nm),
|
ItemKind::ForeignMod(nm) => vis.visit_foreign_mod(nm),
|
||||||
ItemKind::GlobalAsm(asm) => vis.visit_inline_asm(asm),
|
ItemKind::GlobalAsm(asm) => vis.visit_inline_asm(asm),
|
||||||
ItemKind::TyAlias(box TyAlias {
|
ItemKind::TyAlias(box TyAlias {
|
||||||
defaultness, generics, where_clauses, bounds, ty, ..
|
defaultness,
|
||||||
|
generics,
|
||||||
|
where_clauses,
|
||||||
|
bounds,
|
||||||
|
ty,
|
||||||
|
..
|
||||||
}) => {
|
}) => {
|
||||||
visit_defaultness(defaultness, vis);
|
visit_defaultness(defaultness, vis);
|
||||||
vis.visit_generics(generics);
|
vis.visit_generics(generics);
|
||||||
|
@ -1160,17 +1170,11 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn noop_flat_map_assoc_item<T: MutVisitor>(
|
impl NoopVisitItemKind for AssocItemKind {
|
||||||
mut item: P<AssocItem>,
|
fn noop_visit(&mut self, visitor: &mut impl MutVisitor) {
|
||||||
visitor: &mut T,
|
match self {
|
||||||
) -> SmallVec<[P<AssocItem>; 1]> {
|
|
||||||
let Item { id, ident, vis, attrs, kind, span, tokens } = item.deref_mut();
|
|
||||||
visitor.visit_id(id);
|
|
||||||
visitor.visit_ident(ident);
|
|
||||||
visitor.visit_vis(vis);
|
|
||||||
visit_attrs(attrs, visitor);
|
|
||||||
match kind {
|
|
||||||
AssocItemKind::Const(item) => {
|
AssocItemKind::Const(item) => {
|
||||||
visit_const_item(item, visitor);
|
visit_const_item(item, visitor);
|
||||||
}
|
}
|
||||||
|
@ -1208,9 +1212,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visitor.visit_span(span);
|
}
|
||||||
visit_lazy_tts(tokens, visitor);
|
|
||||||
smallvec![item]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_const_item<T: MutVisitor>(
|
fn visit_const_item<T: MutVisitor>(
|
||||||
|
@ -1241,32 +1243,24 @@ pub fn noop_visit_crate<T: MutVisitor>(krate: &mut Crate, vis: &mut T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutates one item into possibly many items.
|
// Mutates one item into possibly many items.
|
||||||
pub fn noop_flat_map_item<T: MutVisitor>(
|
pub fn noop_flat_map_item<K: NoopVisitItemKind>(
|
||||||
mut item: P<Item>,
|
mut item: P<Item<K>>,
|
||||||
visitor: &mut T,
|
visitor: &mut impl MutVisitor,
|
||||||
) -> SmallVec<[P<Item>; 1]> {
|
) -> SmallVec<[P<Item<K>>; 1]> {
|
||||||
let Item { ident, attrs, id, kind, vis, span, tokens } = item.deref_mut();
|
let Item { ident, attrs, id, kind, vis, span, tokens } = item.deref_mut();
|
||||||
visitor.visit_ident(ident);
|
visitor.visit_ident(ident);
|
||||||
visit_attrs(attrs, visitor);
|
visit_attrs(attrs, visitor);
|
||||||
visitor.visit_id(id);
|
visitor.visit_id(id);
|
||||||
visitor.visit_item_kind(kind);
|
kind.noop_visit(visitor);
|
||||||
visitor.visit_vis(vis);
|
visitor.visit_vis(vis);
|
||||||
visitor.visit_span(span);
|
visitor.visit_span(span);
|
||||||
visit_lazy_tts(tokens, visitor);
|
visit_lazy_tts(tokens, visitor);
|
||||||
|
|
||||||
smallvec![item]
|
smallvec![item]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_flat_map_foreign_item<T: MutVisitor>(
|
impl NoopVisitItemKind for ForeignItemKind {
|
||||||
mut item: P<ForeignItem>,
|
fn noop_visit(&mut self, visitor: &mut impl MutVisitor) {
|
||||||
visitor: &mut T,
|
match self {
|
||||||
) -> SmallVec<[P<ForeignItem>; 1]> {
|
|
||||||
let Item { ident, attrs, id, kind, vis, span, tokens } = item.deref_mut();
|
|
||||||
visitor.visit_id(id);
|
|
||||||
visitor.visit_ident(ident);
|
|
||||||
visitor.visit_vis(vis);
|
|
||||||
visit_attrs(attrs, visitor);
|
|
||||||
match kind {
|
|
||||||
ForeignItemKind::Static(ty, _, expr) => {
|
ForeignItemKind::Static(ty, _, expr) => {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
visit_opt(expr, |expr| visitor.visit_expr(expr));
|
visit_opt(expr, |expr| visitor.visit_expr(expr));
|
||||||
|
@ -1294,9 +1288,7 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>(
|
||||||
}
|
}
|
||||||
ForeignItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
|
ForeignItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
|
||||||
}
|
}
|
||||||
visitor.visit_span(span);
|
}
|
||||||
visit_lazy_tts(tokens, visitor);
|
|
||||||
smallvec![item]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
|
pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
|
||||||
|
|
|
@ -102,6 +102,15 @@ pub enum LifetimeCtxt {
|
||||||
GenericArg,
|
GenericArg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait WalkItemKind: Sized {
|
||||||
|
fn walk<'a, V: Visitor<'a>>(
|
||||||
|
&'a self,
|
||||||
|
item: &'a Item<Self>,
|
||||||
|
ctxt: AssocCtxt,
|
||||||
|
visitor: &mut V,
|
||||||
|
) -> V::Result;
|
||||||
|
}
|
||||||
|
|
||||||
/// Each method of the `Visitor` trait is a hook to be potentially
|
/// Each method of the `Visitor` trait is a hook to be potentially
|
||||||
/// overridden. Each method's default implementation recursively visits
|
/// overridden. Each method's default implementation recursively visits
|
||||||
/// the substructure of the input via the corresponding `walk` method;
|
/// the substructure of the input via the corresponding `walk` method;
|
||||||
|
@ -120,7 +129,7 @@ pub trait Visitor<'ast>: Sized {
|
||||||
Self::Result::output()
|
Self::Result::output()
|
||||||
}
|
}
|
||||||
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) -> Self::Result {
|
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) -> Self::Result {
|
||||||
walk_foreign_item(self, i)
|
walk_item(self, i)
|
||||||
}
|
}
|
||||||
fn visit_item(&mut self, i: &'ast Item) -> Self::Result {
|
fn visit_item(&mut self, i: &'ast Item) -> Self::Result {
|
||||||
walk_item(self, i)
|
walk_item(self, i)
|
||||||
|
@ -312,10 +321,14 @@ pub fn walk_trait_ref<'a, V: Visitor<'a>>(visitor: &mut V, trait_ref: &'a TraitR
|
||||||
visitor.visit_path(&trait_ref.path, trait_ref.ref_id)
|
visitor.visit_path(&trait_ref.path, trait_ref.ref_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) -> V::Result {
|
impl WalkItemKind for ItemKind {
|
||||||
try_visit!(visitor.visit_vis(&item.vis));
|
fn walk<'a, V: Visitor<'a>>(
|
||||||
try_visit!(visitor.visit_ident(item.ident));
|
&'a self,
|
||||||
match &item.kind {
|
item: &'a Item<Self>,
|
||||||
|
_ctxt: AssocCtxt,
|
||||||
|
visitor: &mut V,
|
||||||
|
) -> V::Result {
|
||||||
|
match self {
|
||||||
ItemKind::ExternCrate(_) => {}
|
ItemKind::ExternCrate(_) => {}
|
||||||
ItemKind::Use(use_tree) => try_visit!(visitor.visit_use_tree(use_tree, item.id, false)),
|
ItemKind::Use(use_tree) => try_visit!(visitor.visit_use_tree(use_tree, item.id, false)),
|
||||||
ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => {
|
ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => {
|
||||||
|
@ -391,9 +404,16 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) -> V::Resu
|
||||||
visit_opt!(visitor, visit_block, body);
|
visit_opt!(visitor, visit_block, body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
walk_list!(visitor, visit_attribute, &item.attrs);
|
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn walk_item<'a, V: Visitor<'a>>(
|
||||||
|
visitor: &mut V,
|
||||||
|
item: &'a Item<impl WalkItemKind>,
|
||||||
|
) -> V::Result {
|
||||||
|
walk_assoc_item(visitor, item, AssocCtxt::Trait /*ignored*/)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn walk_enum_def<'a, V: Visitor<'a>>(
|
pub fn walk_enum_def<'a, V: Visitor<'a>>(
|
||||||
visitor: &mut V,
|
visitor: &mut V,
|
||||||
|
@ -613,12 +633,15 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignItem) -> V::Result {
|
impl WalkItemKind for ForeignItemKind {
|
||||||
let &Item { id, span, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
|
fn walk<'a, V: Visitor<'a>>(
|
||||||
try_visit!(visitor.visit_vis(vis));
|
&'a self,
|
||||||
try_visit!(visitor.visit_ident(ident));
|
item: &'a Item<Self>,
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
_ctxt: AssocCtxt,
|
||||||
match kind {
|
visitor: &mut V,
|
||||||
|
) -> V::Result {
|
||||||
|
let &Item { id, span, ident, ref vis, .. } = item;
|
||||||
|
match self {
|
||||||
ForeignItemKind::Static(ty, _, expr) => {
|
ForeignItemKind::Static(ty, _, expr) => {
|
||||||
try_visit!(visitor.visit_ty(ty));
|
try_visit!(visitor.visit_ty(ty));
|
||||||
visit_opt!(visitor, visit_expr, expr);
|
visit_opt!(visitor, visit_expr, expr);
|
||||||
|
@ -638,6 +661,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
|
||||||
}
|
}
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) -> V::Result {
|
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) -> V::Result {
|
||||||
match bound {
|
match bound {
|
||||||
|
@ -756,23 +780,23 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Resu
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_assoc_item<'a, V: Visitor<'a>>(
|
impl WalkItemKind for AssocItemKind {
|
||||||
visitor: &mut V,
|
fn walk<'a, V: Visitor<'a>>(
|
||||||
item: &'a AssocItem,
|
&'a self,
|
||||||
|
item: &'a Item<Self>,
|
||||||
ctxt: AssocCtxt,
|
ctxt: AssocCtxt,
|
||||||
|
visitor: &mut V,
|
||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
let &Item { id, span, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
|
let &Item { id, span, ident, ref vis, .. } = item;
|
||||||
try_visit!(visitor.visit_vis(vis));
|
match self {
|
||||||
try_visit!(visitor.visit_ident(ident));
|
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
|
||||||
match kind {
|
|
||||||
AssocItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => {
|
AssocItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => {
|
||||||
try_visit!(visitor.visit_generics(generics));
|
try_visit!(visitor.visit_generics(generics));
|
||||||
try_visit!(visitor.visit_ty(ty));
|
try_visit!(visitor.visit_ty(ty));
|
||||||
visit_opt!(visitor, visit_expr, expr);
|
visit_opt!(visitor, visit_expr, expr);
|
||||||
}
|
}
|
||||||
AssocItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
|
AssocItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
|
||||||
let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref());
|
let kind =
|
||||||
|
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref());
|
||||||
try_visit!(visitor.visit_fn(kind, span, id));
|
try_visit!(visitor.visit_fn(kind, span, id));
|
||||||
}
|
}
|
||||||
AssocItemKind::Type(box TyAlias { generics, bounds, ty, .. }) => {
|
AssocItemKind::Type(box TyAlias { generics, bounds, ty, .. }) => {
|
||||||
|
@ -794,6 +818,20 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(
|
||||||
}
|
}
|
||||||
V::Result::output()
|
V::Result::output()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn walk_assoc_item<'a, V: Visitor<'a>>(
|
||||||
|
visitor: &mut V,
|
||||||
|
item: &'a Item<impl WalkItemKind>,
|
||||||
|
ctxt: AssocCtxt,
|
||||||
|
) -> V::Result {
|
||||||
|
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
|
||||||
|
try_visit!(visitor.visit_vis(vis));
|
||||||
|
try_visit!(visitor.visit_ident(ident));
|
||||||
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
|
try_visit!(kind.walk(item, ctxt, visitor));
|
||||||
|
V::Result::output()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn walk_struct_def<'a, V: Visitor<'a>>(
|
pub fn walk_struct_def<'a, V: Visitor<'a>>(
|
||||||
visitor: &mut V,
|
visitor: &mut V,
|
||||||
|
|
|
@ -394,7 +394,7 @@ fn index_crate<'a>(
|
||||||
let def_id = self.node_id_to_def_id[&item.id];
|
let def_id = self.node_id_to_def_id[&item.id];
|
||||||
*self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner) =
|
*self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner) =
|
||||||
AstOwner::ForeignItem(item);
|
AstOwner::ForeignItem(item);
|
||||||
visit::walk_foreign_item(self, item);
|
visit::walk_item(self, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1192,7 +1192,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
ForeignItemKind::MacCall(..) => {}
|
ForeignItemKind::MacCall(..) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
visit::walk_foreign_item(self, fi)
|
visit::walk_item(self, fi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirrors `visit::walk_generic_args`, but tracks relevant state.
|
// Mirrors `visit::walk_generic_args`, but tracks relevant state.
|
||||||
|
|
|
@ -319,7 +319,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
ast::ForeignItemKind::MacCall(..) => {}
|
ast::ForeignItemKind::MacCall(..) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
visit::walk_foreign_item(self, i)
|
visit::walk_item(self, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, ty: &'a ast::Ty) {
|
fn visit_ty(&mut self, ty: &'a ast::Ty) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
|
||||||
}
|
}
|
||||||
fn visit_foreign_item(&mut self, i: &ForeignItem) {
|
fn visit_foreign_item(&mut self, i: &ForeignItem) {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
walk_foreign_item(self, i)
|
walk_item(self, i)
|
||||||
}
|
}
|
||||||
fn visit_item(&mut self, i: &Item) {
|
fn visit_item(&mut self, i: &Item) {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
|
|
|
@ -246,18 +246,18 @@ impl MutVisitor for CfgEval<'_, '_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_impl_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
fn flat_map_impl_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
||||||
mut_visit::noop_flat_map_assoc_item(configure!(self, item), self)
|
mut_visit::noop_flat_map_item(configure!(self, item), self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
||||||
mut_visit::noop_flat_map_assoc_item(configure!(self, item), self)
|
mut_visit::noop_flat_map_item(configure!(self, item), self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_foreign_item(
|
fn flat_map_foreign_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
foreign_item: P<ast::ForeignItem>,
|
foreign_item: P<ast::ForeignItem>,
|
||||||
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
|
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
|
||||||
mut_visit::noop_flat_map_foreign_item(configure!(self, foreign_item), self)
|
mut_visit::noop_flat_map_item(configure!(self, foreign_item), self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
|
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
|
||||||
|
|
|
@ -1218,7 +1218,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
|
||||||
fragment.make_trait_items()
|
fragment.make_trait_items()
|
||||||
}
|
}
|
||||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||||
noop_flat_map_assoc_item(self.wrapped, visitor)
|
noop_flat_map_item(self.wrapped, visitor)
|
||||||
}
|
}
|
||||||
fn is_mac_call(&self) -> bool {
|
fn is_mac_call(&self) -> bool {
|
||||||
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
||||||
|
@ -1243,7 +1243,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
|
||||||
fragment.make_impl_items()
|
fragment.make_impl_items()
|
||||||
}
|
}
|
||||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||||
noop_flat_map_assoc_item(self.wrapped, visitor)
|
noop_flat_map_item(self.wrapped, visitor)
|
||||||
}
|
}
|
||||||
fn is_mac_call(&self) -> bool {
|
fn is_mac_call(&self) -> bool {
|
||||||
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
|
||||||
|
@ -1266,7 +1266,7 @@ impl InvocationCollectorNode for P<ast::ForeignItem> {
|
||||||
fragment.make_foreign_items()
|
fragment.make_foreign_items()
|
||||||
}
|
}
|
||||||
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
fn noop_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
|
||||||
noop_flat_map_foreign_item(self, visitor)
|
noop_flat_map_item(self, visitor)
|
||||||
}
|
}
|
||||||
fn is_mac_call(&self) -> bool {
|
fn is_mac_call(&self) -> bool {
|
||||||
matches!(self.kind, ForeignItemKind::MacCall(..))
|
matches!(self.kind, ForeignItemKind::MacCall(..))
|
||||||
|
|
|
@ -271,14 +271,14 @@ impl MutVisitor for PlaceholderExpander {
|
||||||
fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ast::AssocItemKind::MacCall(_) => self.remove(item.id).make_trait_items(),
|
ast::AssocItemKind::MacCall(_) => self.remove(item.id).make_trait_items(),
|
||||||
_ => noop_flat_map_assoc_item(item, self),
|
_ => noop_flat_map_item(item, self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_impl_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
fn flat_map_impl_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ast::AssocItemKind::MacCall(_) => self.remove(item.id).make_impl_items(),
|
ast::AssocItemKind::MacCall(_) => self.remove(item.id).make_impl_items(),
|
||||||
_ => noop_flat_map_assoc_item(item, self),
|
_ => noop_flat_map_item(item, self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ impl MutVisitor for PlaceholderExpander {
|
||||||
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
|
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
ast::ForeignItemKind::MacCall(_) => self.remove(item.id).make_foreign_items(),
|
ast::ForeignItemKind::MacCall(_) => self.remove(item.id).make_foreign_items(),
|
||||||
_ => noop_flat_map_foreign_item(item, self),
|
_ => noop_flat_map_item(item, self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
|
||||||
|
|
||||||
fn visit_foreign_item(&mut self, it: &'a ast::ForeignItem) {
|
fn visit_foreign_item(&mut self, it: &'a ast::ForeignItem) {
|
||||||
self.with_lint_attrs(it.id, &it.attrs, |cx| {
|
self.with_lint_attrs(it.id, &it.attrs, |cx| {
|
||||||
ast_visit::walk_foreign_item(cx, it);
|
ast_visit::walk_item(cx, it);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -498,7 +498,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
|
||||||
(self, i, i.kind, Id::None, ast, ForeignItem, ForeignItemKind),
|
(self, i, i.kind, Id::None, ast, ForeignItem, ForeignItemKind),
|
||||||
[Static, Fn, TyAlias, MacCall]
|
[Static, Fn, TyAlias, MacCall]
|
||||||
);
|
);
|
||||||
ast_visit::walk_foreign_item(self, i)
|
ast_visit::walk_item(self, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_item(&mut self, i: &'v ast::Item) {
|
fn visit_item(&mut self, i: &'v ast::Item) {
|
||||||
|
|
|
@ -1339,7 +1339,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.build_reduced_graph_for_foreign_item(foreign_item);
|
self.build_reduced_graph_for_foreign_item(foreign_item);
|
||||||
visit::walk_foreign_item(self, foreign_item);
|
visit::walk_item(self, foreign_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_block(&mut self, block: &'b Block) {
|
fn visit_block(&mut self, block: &'b Block) {
|
||||||
|
|
|
@ -224,7 +224,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
||||||
|
|
||||||
let def = self.create_def(fi.id, fi.ident.name, def_kind, fi.span);
|
let def = self.create_def(fi.id, fi.ident.name, def_kind, fi.span);
|
||||||
|
|
||||||
self.with_parent(def, |this| visit::walk_foreign_item(this, fi));
|
self.with_parent(def, |this| visit::walk_item(this, fi));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_variant(&mut self, v: &'a Variant) {
|
fn visit_variant(&mut self, v: &'a Variant) {
|
||||||
|
|
|
@ -886,7 +886,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
||||||
kind: LifetimeBinderKind::Item,
|
kind: LifetimeBinderKind::Item,
|
||||||
span: generics.span,
|
span: generics.span,
|
||||||
},
|
},
|
||||||
|this| visit::walk_foreign_item(this, foreign_item),
|
|this| visit::walk_item(this, foreign_item),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ForeignItemKind::Fn(box Fn { ref generics, .. }) => {
|
ForeignItemKind::Fn(box Fn { ref generics, .. }) => {
|
||||||
|
@ -898,13 +898,11 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
||||||
kind: LifetimeBinderKind::Function,
|
kind: LifetimeBinderKind::Function,
|
||||||
span: generics.span,
|
span: generics.span,
|
||||||
},
|
},
|
||||||
|this| visit::walk_foreign_item(this, foreign_item),
|
|this| visit::walk_item(this, foreign_item),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ForeignItemKind::Static(..) => {
|
ForeignItemKind::Static(..) => {
|
||||||
self.with_static_rib(def_kind, |this| {
|
self.with_static_rib(def_kind, |this| visit::walk_item(this, foreign_item))
|
||||||
visit::walk_foreign_item(this, foreign_item);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
ForeignItemKind::MacCall(..) => {
|
ForeignItemKind::MacCall(..) => {
|
||||||
panic!("unexpanded macro in resolve!")
|
panic!("unexpanded macro in resolve!")
|
||||||
|
|
|
@ -1,35 +1,11 @@
|
||||||
error: using tabs in doc comments is not recommended
|
|
||||||
--> tests/ui/tabs_in_doc_comments.rs:10:9
|
|
||||||
|
|
|
||||||
LL | /// - First String:
|
|
||||||
| ^^^^ help: consider using four spaces per tab
|
|
||||||
|
|
|
||||||
= note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings`
|
|
||||||
= help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]`
|
|
||||||
|
|
||||||
error: using tabs in doc comments is not recommended
|
|
||||||
--> tests/ui/tabs_in_doc_comments.rs:11:9
|
|
||||||
|
|
|
||||||
LL | /// - needs to be inside here
|
|
||||||
| ^^^^^^^^ help: consider using four spaces per tab
|
|
||||||
|
|
||||||
error: using tabs in doc comments is not recommended
|
|
||||||
--> tests/ui/tabs_in_doc_comments.rs:14:9
|
|
||||||
|
|
|
||||||
LL | /// - Second String:
|
|
||||||
| ^^^^ help: consider using four spaces per tab
|
|
||||||
|
|
||||||
error: using tabs in doc comments is not recommended
|
|
||||||
--> tests/ui/tabs_in_doc_comments.rs:15:9
|
|
||||||
|
|
|
||||||
LL | /// - needs to be inside here
|
|
||||||
| ^^^^^^^^ help: consider using four spaces per tab
|
|
||||||
|
|
||||||
error: using tabs in doc comments is not recommended
|
error: using tabs in doc comments is not recommended
|
||||||
--> tests/ui/tabs_in_doc_comments.rs:6:5
|
--> tests/ui/tabs_in_doc_comments.rs:6:5
|
||||||
|
|
|
|
||||||
LL | /// - first one
|
LL | /// - first one
|
||||||
| ^^^^ help: consider using four spaces per tab
|
| ^^^^ help: consider using four spaces per tab
|
||||||
|
|
|
||||||
|
= note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings`
|
||||||
|
= help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]`
|
||||||
|
|
||||||
error: using tabs in doc comments is not recommended
|
error: using tabs in doc comments is not recommended
|
||||||
--> tests/ui/tabs_in_doc_comments.rs:6:13
|
--> tests/ui/tabs_in_doc_comments.rs:6:13
|
||||||
|
@ -49,5 +25,29 @@ error: using tabs in doc comments is not recommended
|
||||||
LL | /// - second one
|
LL | /// - second one
|
||||||
| ^^^^ help: consider using four spaces per tab
|
| ^^^^ help: consider using four spaces per tab
|
||||||
|
|
||||||
|
error: using tabs in doc comments is not recommended
|
||||||
|
--> tests/ui/tabs_in_doc_comments.rs:10:9
|
||||||
|
|
|
||||||
|
LL | /// - First String:
|
||||||
|
| ^^^^ help: consider using four spaces per tab
|
||||||
|
|
||||||
|
error: using tabs in doc comments is not recommended
|
||||||
|
--> tests/ui/tabs_in_doc_comments.rs:11:9
|
||||||
|
|
|
||||||
|
LL | /// - needs to be inside here
|
||||||
|
| ^^^^^^^^ help: consider using four spaces per tab
|
||||||
|
|
||||||
|
error: using tabs in doc comments is not recommended
|
||||||
|
--> tests/ui/tabs_in_doc_comments.rs:14:9
|
||||||
|
|
|
||||||
|
LL | /// - Second String:
|
||||||
|
| ^^^^ help: consider using four spaces per tab
|
||||||
|
|
||||||
|
error: using tabs in doc comments is not recommended
|
||||||
|
--> tests/ui/tabs_in_doc_comments.rs:15:9
|
||||||
|
|
|
||||||
|
LL | /// - needs to be inside here
|
||||||
|
| ^^^^^^^^ help: consider using four spaces per tab
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
error[E0658]: the `#[optimize]` attribute is an experimental feature
|
||||||
|
--> $DIR/feature-gate-optimize_attribute.rs:4:1
|
||||||
|
|
|
||||||
|
LL | #[optimize(size)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
|
||||||
|
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: the `#[optimize]` attribute is an experimental feature
|
error[E0658]: the `#[optimize]` attribute is an experimental feature
|
||||||
--> $DIR/feature-gate-optimize_attribute.rs:7:1
|
--> $DIR/feature-gate-optimize_attribute.rs:7:1
|
||||||
|
|
|
|
||||||
|
@ -28,16 +38,6 @@ LL | #[optimize(banana)]
|
||||||
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
|
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
error[E0658]: the `#[optimize]` attribute is an experimental feature
|
|
||||||
--> $DIR/feature-gate-optimize_attribute.rs:4:1
|
|
||||||
|
|
|
||||||
LL | #[optimize(size)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
|
|
||||||
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error[E0658]: the `#[optimize]` attribute is an experimental feature
|
error[E0658]: the `#[optimize]` attribute is an experimental feature
|
||||||
--> $DIR/feature-gate-optimize_attribute.rs:2:1
|
--> $DIR/feature-gate-optimize_attribute.rs:2:1
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
|
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
||||||
|
|
|
||||||
|
LL | #[stable()]
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0734]: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:14:9
|
--> $DIR/issue-43106-gating-of-stable.rs:14:9
|
||||||
|
|
|
|
||||||
|
@ -28,12 +34,6 @@ error[E0734]: stability attributes may not be used outside of the standard libra
|
||||||
LL | #[stable()]
|
LL | #[stable()]
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0734]: stability attributes may not be used outside of the standard library
|
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
|
||||||
|
|
|
||||||
LL | #[stable()]
|
|
||||||
| ^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0734]: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
|
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
||||||
|
|
|
||||||
|
LL | #[unstable()]
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0734]: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:14:9
|
--> $DIR/issue-43106-gating-of-unstable.rs:14:9
|
||||||
|
|
|
|
||||||
|
@ -28,12 +34,6 @@ error[E0734]: stability attributes may not be used outside of the standard libra
|
||||||
LL | #[unstable()]
|
LL | #[unstable()]
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0734]: stability attributes may not be used outside of the standard library
|
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
|
||||||
|
|
|
||||||
LL | #[unstable()]
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0734]: stability attributes may not be used outside of the standard library
|
error[E0734]: stability attributes may not be used outside of the standard library
|
||||||
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue