Skip to content

Commit a6e8f3b

Browse files
committed
Add type Determinacy.
1 parent 951d3d6 commit a6e8f3b

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/librustc_resolve/resolve_imports.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use self::Determinacy::*;
1112
use self::ImportDirectiveSubclass::*;
1213

1314
use Module;
@@ -36,14 +37,20 @@ impl<'a> Resolver<'a> {
3637
}
3738
}
3839

40+
#[derive(Copy, Clone, Debug)]
41+
pub enum Determinacy {
42+
Determined,
43+
Undetermined,
44+
}
45+
3946
/// Contains data for specific types of import directives.
4047
#[derive(Clone, Debug)]
4148
pub enum ImportDirectiveSubclass<'a> {
4249
SingleImport {
4350
target: Name,
4451
source: Name,
45-
value_result: Cell<Result<&'a NameBinding<'a>, bool /* determined? */>>,
46-
type_result: Cell<Result<&'a NameBinding<'a>, bool /* determined? */>>,
52+
value_result: Cell<Result<&'a NameBinding<'a>, Determinacy>>,
53+
type_result: Cell<Result<&'a NameBinding<'a>, Determinacy>>,
4754
},
4855
GlobImport { is_prelude: bool },
4956
}
@@ -53,8 +60,8 @@ impl<'a> ImportDirectiveSubclass<'a> {
5360
SingleImport {
5461
target: target,
5562
source: source,
56-
type_result: Cell::new(Err(false)),
57-
value_result: Cell::new(Err(false)),
63+
type_result: Cell::new(Err(Undetermined)),
64+
value_result: Cell::new(Err(Undetermined)),
5865
}
5966
}
6067
}
@@ -497,21 +504,21 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
497504

498505
let mut indeterminate = false;
499506
for &(ns, result) in &[(ValueNS, value_result), (TypeNS, type_result)] {
500-
if let Err(false) = result.get() {
507+
if let Err(Undetermined) = result.get() {
501508
result.set({
502509
match self.resolve_name_in_module(module, source, ns, false, None) {
503510
Success(binding) => Ok(binding),
504-
Indeterminate => Err(false),
505-
Failed(_) => Err(true),
511+
Indeterminate => Err(Undetermined),
512+
Failed(_) => Err(Determined),
506513
}
507514
});
508515
} else {
509516
continue
510517
};
511518

512519
match result.get() {
513-
Err(false) => indeterminate = true,
514-
Err(true) => {
520+
Err(Undetermined) => indeterminate = true,
521+
Err(Determined) => {
515522
self.update_resolution(directive.parent, target, ns, |_, resolution| {
516523
resolution.single_imports.directive_failed()
517524
});

0 commit comments

Comments
 (0)