Skip to content

Commit 5eae778

Browse files
committed
FIXME Fallout from changes to rules for lifetimes and Drop.
It would be good revisit all of these changes after I get the whole PR into a good state, to see if some/all of them can be returned to their prior state. Also, a real FIXME: the current spans being generated for the borrow-check errors related to this are terrible; they tend to point one at a sub-expression of the actual expression that needs to be factored out (or, in some cases, an earlier expression entirely? Need to double check that).
1 parent 5230f86 commit 5eae778

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

src/librustc/middle/resolve.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,8 @@ impl<'a> Resolver<'a> {
14031403
// a trait and the name of an impl of that trait.
14041404
let mod_name = path.segments.last().unwrap().identifier.name;
14051405

1406-
let parent_opt = parent.module().children.borrow()
1406+
let parent_mod = parent.module();
1407+
let parent_opt = parent_mod.children.borrow()
14071408
.get(&mod_name).cloned();
14081409
let new_parent = match parent_opt {
14091410
// It already exists
@@ -1767,11 +1768,12 @@ impl<'a> Resolver<'a> {
17671768
true));
17681769
debug!("(build reduced graph for item) found extern `{}`",
17691770
self.module_to_string(&*external_module));
1771+
let parent_mod = parent.module();
17701772
self.check_for_conflicts_between_external_crates(
1771-
&*parent.module(),
1773+
&*parent_mod,
17721774
name.name,
17731775
view_item.span);
1774-
parent.module().external_module_children.borrow_mut()
1776+
parent_mod.external_module_children.borrow_mut()
17751777
.insert(name.name, external_module.clone());
17761778
self.build_reduced_graph_for_external_crate(external_module);
17771779
}
@@ -2301,7 +2303,8 @@ impl<'a> Resolver<'a> {
23012303
}
23022304
}
23032305

2304-
for (_, child_module) in module_.anonymous_children.borrow().iter() {
2306+
let children = module_.anonymous_children.borrow();
2307+
for (_, child_module) in children.iter() {
23052308
self.resolve_imports_for_module_subtree(child_module.clone());
23062309
}
23072310
}
@@ -3458,7 +3461,8 @@ impl<'a> Resolver<'a> {
34583461

34593462
// Search for external modules.
34603463
if namespace == TypeNS {
3461-
match module_.external_module_children.borrow().get(&name).cloned() {
3464+
let children = module_.external_module_children.borrow().get(&name).cloned();
3465+
match children {
34623466
None => {}
34633467
Some(module) => {
34643468
let name_bindings =
@@ -3743,7 +3747,8 @@ impl<'a> Resolver<'a> {
37433747

37443748
// Finally, search through external children.
37453749
if namespace == TypeNS {
3746-
match module_.external_module_children.borrow().get(&name).cloned() {
3750+
let children = module_.external_module_children.borrow().get(&name).cloned();
3751+
match children {
37473752
None => {}
37483753
Some(module) => {
37493754
let name_bindings =
@@ -3795,7 +3800,8 @@ impl<'a> Resolver<'a> {
37953800
}
37963801
}
37973802

3798-
for (_, module_) in module_.anonymous_children.borrow().iter() {
3803+
let children = module_.anonymous_children.borrow();
3804+
for (_, module_) in children.iter() {
37993805
self.report_unresolved_imports(module_.clone());
38003806
}
38013807
}
@@ -3855,7 +3861,8 @@ impl<'a> Resolver<'a> {
38553861
}
38563862
}
38573863

3858-
for (_, child_module) in module_.anonymous_children.borrow().iter() {
3864+
let children = module_.anonymous_children.borrow();
3865+
for (_, child_module) in children.iter() {
38593866
self.record_exports_for_module_subtree(child_module.clone());
38603867
}
38613868
}

src/librustc/middle/typeck/check/method/probe.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,14 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
486486
trait_def_id);
487487

488488
let trait_impls = self.tcx().trait_impls.borrow();
489-
let impl_def_ids = match trait_impls.get(&trait_def_id) {
489+
let impl_for_def = trait_impls.get(&trait_def_id);
490+
let impl_def_ids = match impl_for_def {
490491
None => { return; }
491492
Some(impls) => impls,
492493
};
493494

494-
for &impl_def_id in impl_def_ids.borrow().iter() {
495+
let impl_def_ids = impl_def_ids.borrow();
496+
for &impl_def_id in impl_def_ids.iter() {
495497
debug!("assemble_extension_candidates_for_trait_impl: trait_def_id={} impl_def_id={}",
496498
trait_def_id.repr(self.tcx()),
497499
impl_def_id.repr(self.tcx()));
@@ -901,8 +903,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
901903
// if there are any.
902904
assert_eq!(substs.types.len(subst::FnSpace), 0);
903905
assert_eq!(substs.regions().len(subst::FnSpace), 0);
904-
let mut substs = substs;
905906
let placeholder;
907+
let mut substs = substs;
906908
if
907909
!method.generics.types.is_empty_in(subst::FnSpace) ||
908910
!method.generics.regions.is_empty_in(subst::FnSpace)

src/librustc/middle/typeck/coherence/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
432432
Some(found_impls) => found_impls
433433
};
434434

435-
for &impl_did in trait_impls.borrow().iter() {
435+
let trait_impls = trait_impls.borrow();
436+
for &impl_did in trait_impls.iter() {
436437
let items = &(*impl_items)[impl_did];
437438
if items.len() < 1 {
438439
// We'll error out later. For now, just don't ICE.

src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
867867
let scope_id = same_regions[0].scope_id;
868868
let parent = self.tcx.map.get_parent(scope_id);
869869
let parent_node = self.tcx.map.find(parent);
870+
let taken = lifetimes_in_scope(self.tcx, scope_id);
871+
let life_giver = LifeGiver::with_taken(taken.as_slice());
870872
let node_inner = match parent_node {
871873
Some(ref node) => match *node {
872874
ast_map::NodeItem(ref item) => {
@@ -909,8 +911,6 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
909911
};
910912
let (fn_decl, generics, fn_style, ident, expl_self, span)
911913
= node_inner.expect("expect item fn");
912-
let taken = lifetimes_in_scope(self.tcx, scope_id);
913-
let life_giver = LifeGiver::with_taken(taken.as_slice());
914914
let rebuilder = Rebuilder::new(self.tcx, fn_decl, expl_self,
915915
generics, same_regions, &life_giver);
916916
let (fn_decl, expl_self, generics) = rebuilder.rebuild();

0 commit comments

Comments
 (0)