Skip to content

Commit de6eb2b

Browse files
committed
librustc: De-@mut ImportResolution::outstanding_references
1 parent ccb18f4 commit de6eb2b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/librustc/middle/resolve.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ struct ImportResolution {
351351
// The number of outstanding references to this name. When this reaches
352352
// zero, outside modules can count on the targets being correct. Before
353353
// then, all bets are off; future imports could override this name.
354-
outstanding_references: uint,
354+
outstanding_references: Cell<uint>,
355355

356356
/// The value that this `use` directive names, if there is one.
357357
value_target: Option<Target>,
@@ -371,7 +371,7 @@ impl ImportResolution {
371371
ImportResolution {
372372
type_id: id,
373373
value_id: id,
374-
outstanding_references: 0,
374+
outstanding_references: Cell::new(0),
375375
value_target: None,
376376
type_target: None,
377377
is_public: is_public,
@@ -1968,7 +1968,8 @@ impl Resolver {
19681968
Some(&resolution) => {
19691969
debug!("(building import directive) bumping \
19701970
reference");
1971-
resolution.outstanding_references += 1;
1971+
resolution.outstanding_references.set(
1972+
resolution.outstanding_references.get() + 1);
19721973

19731974
// the source of this name is different now
19741975
resolution.type_id = id;
@@ -1977,7 +1978,7 @@ impl Resolver {
19771978
None => {
19781979
debug!("(building import directive) creating new");
19791980
let resolution = @mut ImportResolution::new(id, is_public);
1980-
resolution.outstanding_references = 1;
1981+
resolution.outstanding_references.set(1);
19811982
import_resolutions.get().insert(target.name,
19821983
resolution);
19831984
}
@@ -2328,7 +2329,7 @@ impl Resolver {
23282329
}
23292330
}
23302331
Some(import_resolution)
2331-
if import_resolution.outstanding_references
2332+
if import_resolution.outstanding_references.get()
23322333
== 0 => {
23332334

23342335
fn get_binding(this: &mut Resolver,
@@ -2453,8 +2454,9 @@ impl Resolver {
24532454
}
24542455
let used_public = used_reexport || used_public;
24552456

2456-
assert!(import_resolution.outstanding_references >= 1);
2457-
import_resolution.outstanding_references -= 1;
2457+
assert!(import_resolution.outstanding_references.get() >= 1);
2458+
import_resolution.outstanding_references.set(
2459+
import_resolution.outstanding_references.get() - 1);
24582460

24592461
// record what this import resolves to for later uses in documentation,
24602462
// this may resolve to either a value or a type, but for documentation
@@ -3181,7 +3183,7 @@ impl Resolver {
31813183
match import_resolutions.get().find(&name.name) {
31823184
Some(import_resolution) => {
31833185
if import_resolution.is_public &&
3184-
import_resolution.outstanding_references != 0 {
3186+
import_resolution.outstanding_references.get() != 0 {
31853187
debug!("(resolving name in module) import \
31863188
unresolved; bailing out");
31873189
return Indeterminate;

0 commit comments

Comments
 (0)