Skip to content

Commit 840fa61

Browse files
Add visit_trait
1 parent d4a4097 commit 840fa61

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

source/vir/src/ast_visitor.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::ast::{
33
Datatype, DatatypeX, Expr, ExprX, Exprs, Field, Function, FunctionKind, FunctionX,
44
GenericBound, GenericBoundX, LoopInvariant, LoopInvariants, MaskSpec, NullaryOpr, Param,
55
ParamX, Params, Pattern, PatternBinding, PatternX, Place, PlaceX, SpannedTyped, Stmt, StmtX,
6-
TraitImpl, TraitImplX, Typ, TypDecorationArg, TypX, Typs, UnaryOpr, UnwindSpec, VarBinder,
7-
VarBinderX, VarBinders, VarIdent, Variant, VirErr,
6+
Trait, TraitImpl, TraitImplX, TraitX, Typ, TypDecorationArg, TypX, Typs, UnaryOpr, UnwindSpec,
7+
VarBinder, VarBinderX, VarBinders, VarIdent, Variant, VirErr,
88
};
99
use crate::def::Spanned;
1010
use crate::messages::Span;
@@ -1151,6 +1151,38 @@ pub(crate) trait AstVisitor<R: Returner, Err, Scope: Scoper> {
11511151
})
11521152
}
11531153

1154+
#[allow(dead_code)]
1155+
fn visit_trait(&mut self, tr: &Trait) -> Result<R::Ret<Trait>, Err> {
1156+
let TraitX {
1157+
name,
1158+
proxy,
1159+
visibility,
1160+
typ_params,
1161+
typ_bounds,
1162+
assoc_typs,
1163+
assoc_typs_bounds,
1164+
methods,
1165+
is_unsafe,
1166+
external_trait_extension,
1167+
} = &tr.x;
1168+
let type_bounds = self.visit_generic_bounds(typ_bounds)?;
1169+
let assoc_typs_bounds = self.visit_generic_bounds(assoc_typs_bounds)?;
1170+
R::ret(|| {
1171+
tr.new_x(TraitX {
1172+
name: name.clone(),
1173+
proxy: proxy.clone(),
1174+
visibility: visibility.clone(),
1175+
typ_params: typ_params.clone(),
1176+
typ_bounds: R::get_vec_a(type_bounds),
1177+
assoc_typs: assoc_typs.clone(),
1178+
assoc_typs_bounds: R::get_vec_a(assoc_typs_bounds),
1179+
methods: methods.clone(),
1180+
is_unsafe: *is_unsafe,
1181+
external_trait_extension: external_trait_extension.clone(),
1182+
})
1183+
})
1184+
}
1185+
11541186
fn visit_assoc_type_impl(&mut self, imp: &AssocTypeImpl) -> Result<R::Ret<AssocTypeImpl>, Err> {
11551187
let AssocTypeImplX {
11561188
name,

0 commit comments

Comments
 (0)