File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
33
33
}
34
34
35
35
fn has_type_flags ( & self , flags : TypeFlags ) -> bool {
36
+ // N.B. Even though this uses a visitor, the visitor does not actually
37
+ // recurse through the whole `TypeVisitable` implementor type.
38
+ //
39
+ // Instead it stops on the first "level", visiting types, regions,
40
+ // consts and predicates just fetches their type flags.
41
+ //
42
+ // Thus this is a lot faster than it might seem and should be
43
+ // optimized to a simple field access.
36
44
let res =
37
45
self . visit_with ( & mut HasTypeFlagsVisitor { flags } ) . break_value ( ) == Some ( FoundFlags ) ;
38
46
trace ! ( ?self , ?flags, ?res, "has_type_flags" ) ;
You can’t perform that action at this time.
0 commit comments