@@ -392,19 +392,17 @@ pub struct ImportResolution {
392
392
/// The type that this `use` directive names, if there is one.
393
393
mut type_target: Option<Target>,
394
394
395
- /// There exists one state per import statement
396
- state: @mut ImportState,
395
+ mut used: bool,
397
396
}
398
397
399
- pub fn ImportResolution(privacy: Privacy, span: span,
400
- state: @mut ImportState) -> ImportResolution {
398
+ pub fn ImportResolution(privacy: Privacy, span: span) -> ImportResolution {
401
399
ImportResolution {
402
400
privacy: privacy,
403
401
span: span,
404
402
outstanding_references: 0,
405
403
value_target: None,
406
404
type_target: None,
407
- state: state,
405
+ used: false
408
406
}
409
407
}
410
408
@@ -417,15 +415,6 @@ pub impl ImportResolution {
417
415
}
418
416
}
419
417
420
- pub struct ImportState {
421
- used: bool,
422
- warned: bool
423
- }
424
-
425
- pub fn ImportState() -> ImportState {
426
- ImportState{ used: false, warned: false }
427
- }
428
-
429
418
/// The link from a module up to its nearest parent node.
430
419
pub enum ParentLink {
431
420
NoParentLink,
@@ -1426,7 +1415,6 @@ pub impl Resolver {
1426
1415
1427
1416
// Build up the import directives.
1428
1417
let module_ = self.get_module_from_parent(parent);
1429
- let state = @mut ImportState();
1430
1418
match view_path.node {
1431
1419
view_path_simple(binding, full_path, ns, _) => {
1432
1420
let ns = match ns {
@@ -1442,8 +1430,7 @@ pub impl Resolver {
1442
1430
module_,
1443
1431
module_path,
1444
1432
subclass,
1445
- view_path.span,
1446
- state);
1433
+ view_path.span);
1447
1434
}
1448
1435
view_path_list(_, ref source_idents, _) => {
1449
1436
for (*source_idents).each |source_ident| {
@@ -1455,17 +1442,15 @@ pub impl Resolver {
1455
1442
module_,
1456
1443
module_path,
1457
1444
subclass,
1458
- view_path.span,
1459
- state);
1445
+ view_path.span);
1460
1446
}
1461
1447
}
1462
1448
view_path_glob(_, _) => {
1463
1449
self.build_import_directive(privacy,
1464
1450
module_,
1465
1451
module_path,
1466
1452
@GlobImport,
1467
- view_path.span,
1468
- state);
1453
+ view_path.span);
1469
1454
}
1470
1455
}
1471
1456
}
@@ -1588,8 +1573,7 @@ pub impl Resolver {
1588
1573
// avoid creating cycles in the
1589
1574
// module graph.
1590
1575
1591
- let resolution = @ImportResolution(Public, dummy_sp(),
1592
- @mut ImportState());
1576
+ let resolution = @ImportResolution(Public, dummy_sp());
1593
1577
resolution.outstanding_references = 0;
1594
1578
1595
1579
match existing_module.parent_link {
@@ -1842,8 +1826,7 @@ pub impl Resolver {
1842
1826
module_ : @Module ,
1843
1827
module_path : @DVec < ident > ,
1844
1828
subclass : @ImportDirectiveSubclass ,
1845
- span : span ,
1846
- state : @mut ImportState ) {
1829
+ span : span ) {
1847
1830
let directive = @ImportDirective ( privacy, module_path,
1848
1831
subclass, span) ;
1849
1832
module_. imports . push ( directive) ;
@@ -1867,14 +1850,7 @@ pub impl Resolver {
1867
1850
}
1868
1851
None => {
1869
1852
debug ! ( "(building import directive) creating new" ) ;
1870
- let resolution = @ImportResolution ( privacy, span,
1871
- state) ;
1872
- let name = self . idents_to_str ( module_path. get ( ) ) ;
1873
- // Don't warn about unused intrinsics because they're
1874
- // automatically appended to all files
1875
- if name == ~"intrinsic:: rusti" {
1876
- resolution. state . warned = true ;
1877
- }
1853
+ let resolution = @ImportResolution ( privacy, span) ;
1878
1854
resolution. outstanding_references = 1 ;
1879
1855
module_. import_resolutions . insert ( target, resolution) ;
1880
1856
}
@@ -2207,7 +2183,7 @@ pub impl Resolver {
2207
2183
return UnboundResult ;
2208
2184
}
2209
2185
Some ( target) => {
2210
- import_resolution. state . used = true ;
2186
+ import_resolution. used = true ;
2211
2187
return BoundResult ( target. target_module ,
2212
2188
target. bindings ) ;
2213
2189
}
@@ -2376,7 +2352,7 @@ pub impl Resolver {
2376
2352
module_result = UnboundResult ;
2377
2353
}
2378
2354
Some ( target) => {
2379
- import_resolution. state . used = true ;
2355
+ import_resolution. used = true ;
2380
2356
module_result = BoundResult
2381
2357
( target. target_module ,
2382
2358
target. bindings ) ;
@@ -2443,7 +2419,6 @@ pub impl Resolver {
2443
2419
// everything it can to the list of import resolutions of the module
2444
2420
// node.
2445
2421
debug!(" ( resolving glob import) resolving %? glob import", privacy);
2446
- let state = @mut ImportState();
2447
2422
2448
2423
// We must bail out if the node has unresolved imports of any kind
2449
2424
// (including globs).
@@ -2470,8 +2445,7 @@ pub impl Resolver {
2470
2445
// Simple: just copy the old import resolution.
2471
2446
let new_import_resolution =
2472
2447
@ImportResolution ( privacy,
2473
- target_import_resolution. span ,
2474
- state) ;
2448
+ target_import_resolution. span ) ;
2475
2449
new_import_resolution. value_target =
2476
2450
copy target_import_resolution. value_target ;
2477
2451
new_import_resolution. type_target =
@@ -2512,8 +2486,7 @@ pub impl Resolver {
2512
2486
match module_. import_resolutions. find( & ident) {
2513
2487
None => {
2514
2488
// Create a new import resolution from this child.
2515
- dest_import_resolution = @ImportResolution ( privacy, span,
2516
- state) ;
2489
+ dest_import_resolution = @ImportResolution ( privacy, span) ;
2517
2490
module_. import_resolutions . insert
2518
2491
( ident, dest_import_resolution) ;
2519
2492
}
@@ -2740,7 +2713,7 @@ pub impl Resolver {
2740
2713
namespace) ;
2741
2714
}
2742
2715
Some ( target) => {
2743
- import_resolution. state . used = true ;
2716
+ import_resolution. used = true ;
2744
2717
return Success ( copy target) ;
2745
2718
}
2746
2719
}
@@ -2989,7 +2962,7 @@ pub impl Resolver {
2989
2962
Some ( target) => {
2990
2963
debug ! ( "(resolving name in module) resolved to \
2991
2964
import") ;
2992
- import_resolution. state . used = true ;
2965
+ import_resolution. used = true ;
2993
2966
return Success ( copy target) ;
2994
2967
}
2995
2968
}
@@ -4587,7 +4560,7 @@ pub impl Resolver {
4587
4560
namespace)) {
4588
4561
(Some(def), Some(Public)) => {
4589
4562
// Found it.
4590
- import_resolution.state. used = true;
4563
+ import_resolution.used = true;
4591
4564
return ImportNameDefinition(def);
4592
4565
}
4593
4566
(Some(_), _) | (None, _) => {
@@ -5061,13 +5034,9 @@ pub impl Resolver {
5061
5034
Some ( def) => {
5062
5035
match def {
5063
5036
def_ty( trait_def_id) => {
5064
- let added = self .
5037
+ self .
5065
5038
add_trait_info_if_containing_method(
5066
5039
found_traits, trait_def_id, name) ;
5067
- if added {
5068
- import_resolution. state. used =
5069
- true;
5070
- }
5071
5040
}
5072
5041
_ => {
5073
5042
// Continue.
@@ -5100,7 +5069,7 @@ pub impl Resolver {
5100
5069
5101
5070
fn add_trait_info_if_containing_method( found_traits: @DVec <def_id>,
5102
5071
trait_def_id: def_id,
5103
- name: ident) -> bool {
5072
+ name: ident) {
5104
5073
5105
5074
debug!( "( adding trait info if containing method) trying trait %d: %d \
5106
5075
for method ' %s' ",
@@ -5116,10 +5085,9 @@ pub impl Resolver {
5116
5085
trait_def_id. node,
5117
5086
self . session. str_of( name) ) ;
5118
5087
( * found_traits) . push( trait_def_id) ;
5119
- true
5120
5088
}
5121
5089
Some ( _) | None => {
5122
- false
5090
+ // Continue.
5123
5091
}
5124
5092
}
5125
5093
}
@@ -5236,13 +5204,7 @@ pub impl Resolver {
5236
5204
5237
5205
fn check_for_unused_imports_in_module( module_: @Module ) {
5238
5206
for module_. import_resolutions. each_value_ref |& import_resolution| {
5239
- // Ignore dummy spans for things like automatically injected
5240
- // imports for the prelude, and also don't warn about the same
5241
- // import statement being unused more than once.
5242
- if !import_resolution. state. used &&
5243
- !import_resolution. state. warned &&
5244
- import_resolution. span != dummy_sp( ) {
5245
- import_resolution. state. warned = true ;
5207
+ if !import_resolution. used {
5246
5208
match self. unused_import_lint_level {
5247
5209
warn => {
5248
5210
self . session. span_warn( import_resolution. span,
0 commit comments