| ... | ... | @@ -1148,10 +1148,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1148 | 1148 | ignore_import: Option<Import<'ra>>, |
| 1149 | 1149 | ) -> Result<Decl<'ra>, ControlFlow<Determinacy, Determinacy>> { |
| 1150 | 1150 | let key = BindingKey::new(ident, ns); |
| 1151 | | let resolution_ref = self.resolution_or_default(module.to_module(), key, orig_ident_span); |
| 1152 | | let resolution = resolution_ref.borrow(); |
| 1151 | let resolution = self.resolution(module.to_module(), key); |
| 1153 | 1152 | |
| 1154 | | let binding = resolution.non_glob_decl.filter(|b| Some(*b) != ignore_decl); |
| 1153 | let binding = |
| 1154 | resolution.as_ref().and_then(|r| r.non_glob_decl).filter(|b| Some(*b) != ignore_decl); |
| 1155 | 1155 | |
| 1156 | 1156 | if let Some(finalize) = finalize { |
| 1157 | 1157 | return self.get_mut().finalize_module_binding( |
| ... | ... | @@ -1170,21 +1170,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1170 | 1170 | return if accessible { Ok(binding) } else { Err(ControlFlow::Break(Determined)) }; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | | // We need to detect resolution cycles to avoid infinite recursion. The guard ensures |
| 1174 | | // the resolution is removed when this resolve call ends. |
| 1175 | | let _cycle_guard = cycle_detection::enter_cycle_detector(resolution_ref) |
| 1176 | | .map_err(|_| ControlFlow::Continue(Determined))?; |
| 1173 | if let Some(resolution) = resolution { |
| 1174 | // We need to detect resolution cycles to avoid infinite recursion. The guard ensures |
| 1175 | // the resolution is removed when this resolve call ends. |
| 1176 | let _cycle_guard = cycle_detection::enter_cycle_detector(module, key) |
| 1177 | .map_err(|_| ControlFlow::Continue(Determined))?; |
| 1177 | 1178 | |
| 1178 | | // Check if one of single imports can still define the name, block if it can. |
| 1179 | | if self.reborrow().single_import_can_define_name( |
| 1180 | | &resolution, |
| 1181 | | None, |
| 1182 | | ns, |
| 1183 | | ignore_import, |
| 1184 | | ignore_decl, |
| 1185 | | parent_scope, |
| 1186 | | ) { |
| 1187 | | return Err(ControlFlow::Break(Undetermined)); |
| 1179 | // Check if one of single imports can still define the name, block if it can. |
| 1180 | if self.reborrow().single_import_can_define_name( |
| 1181 | &resolution, |
| 1182 | None, |
| 1183 | ns, |
| 1184 | ignore_import, |
| 1185 | ignore_decl, |
| 1186 | parent_scope, |
| 1187 | ) { |
| 1188 | return Err(ControlFlow::Break(Undetermined)); |
| 1189 | } |
| 1188 | 1190 | } |
| 1189 | 1191 | |
| 1190 | 1192 | // Check if one of unexpanded macros can still define the name. |
| ... | ... | @@ -1210,10 +1212,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1210 | 1212 | ignore_import: Option<Import<'ra>>, |
| 1211 | 1213 | ) -> Result<Decl<'ra>, ControlFlow<Determinacy, Determinacy>> { |
| 1212 | 1214 | let key = BindingKey::new(ident, ns); |
| 1213 | | let resolution_ref = self.resolution_or_default(module.to_module(), key, orig_ident_span); |
| 1214 | | let resolution = resolution_ref.borrow(); |
| 1215 | let resolution = self.resolution(module.to_module(), key); |
| 1215 | 1216 | |
| 1216 | | let binding = resolution.glob_decl.filter(|b| Some(*b) != ignore_decl); |
| 1217 | let binding = |
| 1218 | resolution.as_ref().and_then(|r| r.glob_decl).filter(|b| Some(*b) != ignore_decl); |
| 1217 | 1219 | |
| 1218 | 1220 | if let Some(finalize) = finalize { |
| 1219 | 1221 | return self.get_mut().finalize_module_binding( |
| ... | ... | @@ -1228,20 +1230,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1228 | 1230 | |
| 1229 | 1231 | // We need to detect resolution cycles to avoid infinite recursion. The guard ensures |
| 1230 | 1232 | // the resolution is removed when this resolve call ends. |
| 1231 | | let _cycle_guard = cycle_detection::enter_cycle_detector(resolution_ref) |
| 1233 | let _cycle_guard = cycle_detection::enter_cycle_detector(module, key) |
| 1232 | 1234 | .map_err(|_| ControlFlow::Continue(Determined))?; |
| 1233 | 1235 | |
| 1234 | 1236 | // Check if one of single imports can still define the name, |
| 1235 | 1237 | // if it can then our result is not determined and can be invalidated. |
| 1236 | | if self.reborrow().single_import_can_define_name( |
| 1237 | | &resolution, |
| 1238 | | binding, |
| 1239 | | ns, |
| 1240 | | ignore_import, |
| 1241 | | ignore_decl, |
| 1242 | | parent_scope, |
| 1243 | | ) { |
| 1244 | | return Err(ControlFlow::Break(Undetermined)); |
| 1238 | if let Some(resolution) = resolution { |
| 1239 | if self.reborrow().single_import_can_define_name( |
| 1240 | &resolution, |
| 1241 | binding, |
| 1242 | ns, |
| 1243 | ignore_import, |
| 1244 | ignore_decl, |
| 1245 | parent_scope, |
| 1246 | ) { |
| 1247 | return Err(ControlFlow::Break(Undetermined)); |
| 1248 | } |
| 1245 | 1249 | } |
| 1246 | 1250 | |
| 1247 | 1251 | // So we have a resolution that's from a glob import. This resolution is determined |