(
&mut self,
resolve: &Resolve,
key: Option<&WorldKey>,
name: &str,
base: &mut FunctionFlags,
)
| 107 | } |
| 108 | |
| 109 | fn add_function_flags( |
| 110 | &mut self, |
| 111 | resolve: &Resolve, |
| 112 | key: Option<&WorldKey>, |
| 113 | name: &str, |
| 114 | base: &mut FunctionFlags, |
| 115 | ) { |
| 116 | let mut apply_rules = |name: &str, is_exact: bool| { |
| 117 | for rule in self.rules.iter_mut() { |
| 118 | if name != rule.filter { |
| 119 | continue; |
| 120 | } |
| 121 | if !is_exact && rule.flags.contains(FunctionFlags::EXACT) { |
| 122 | continue; |
| 123 | } |
| 124 | rule.used = true; |
| 125 | *base |= rule.flags; |
| 126 | |
| 127 | // only the first rule is used. |
| 128 | return true; |
| 129 | } |
| 130 | |
| 131 | false |
| 132 | }; |
| 133 | match key { |
| 134 | Some(key) => { |
| 135 | for (lookup, projection) in lookup_keys(resolve, key, LookupItem::Name(name)) { |
| 136 | if apply_rules(&lookup, projection.is_empty()) { |
| 137 | return; |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | None => { |
| 142 | if apply_rules(name, true) { |
| 143 | return; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | *base |= self.default; |
| 149 | } |
| 150 | |
| 151 | pub(crate) fn assert_all_rules_used(&self, kind: &str) -> Result<()> { |
| 152 | let mut unused = Vec::new(); |
no test coverage detected