We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
has_type_flags
1 parent e49122f commit c960a04Copy full SHA for c960a04
compiler/rustc_middle/src/ty/visit.rs
@@ -33,6 +33,14 @@ pub trait TypeVisitableExt<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
33
}
34
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.
44
let res =
45
self.visit_with(&mut HasTypeFlagsVisitor { flags }).break_value() == Some(FoundFlags);
46
trace!(?self, ?flags, ?res, "has_type_flags");
0 commit comments