Skip to content

Commit a5d9762

Browse files
committed
librustc: De-@mut impl_dups in method checking
1 parent d9c87c7 commit a5d9762

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig;
9595
use util::common::indenter;
9696
use util::ppaux::Repr;
9797

98+
use std::cell::RefCell;
9899
use std::hashmap::HashSet;
99100
use std::result;
100101
use std::vec;
@@ -132,7 +133,7 @@ pub fn lookup(
132133
check_traits: CheckTraitsFlag, // Whether we check traits only.
133134
autoderef_receiver: AutoderefReceiverFlag)
134135
-> Option<method_map_entry> {
135-
let impl_dups = @mut HashSet::new();
136+
let impl_dups = @RefCell::new(HashSet::new());
136137
let lcx = LookupContext {
137138
fcx: fcx,
138139
expr: expr,
@@ -174,7 +175,7 @@ pub struct LookupContext<'a> {
174175
callee_id: NodeId,
175176
m_name: ast::Name,
176177
supplied_tps: &'a [ty::t],
177-
impl_dups: @mut HashSet<DefId>,
178+
impl_dups: @RefCell<HashSet<DefId>>,
178179
inherent_candidates: @mut ~[Candidate],
179180
extension_candidates: @mut ~[Candidate],
180181
deref_args: check::DerefArgs,
@@ -540,8 +541,11 @@ impl<'a> LookupContext<'a> {
540541
fn push_candidates_from_impl(&self,
541542
candidates: &mut ~[Candidate],
542543
impl_info: &ty::Impl) {
543-
if !self.impl_dups.insert(impl_info.did) {
544-
return; // already visited
544+
{
545+
let mut impl_dups = self.impl_dups.borrow_mut();
546+
if !impl_dups.get().insert(impl_info.did) {
547+
return; // already visited
548+
}
545549
}
546550
debug!("push_candidates_from_impl: {} {} {}",
547551
token::interner_get(self.m_name),

0 commit comments

Comments
 (0)