@@ -24,7 +24,6 @@ use {resolve_error, resolve_struct_error, ResolutionError};
24
24
use rustc:: middle:: cstore:: LoadedMacroKind ;
25
25
use rustc:: hir:: def:: * ;
26
26
use rustc:: hir:: def_id:: { CRATE_DEF_INDEX , DefId } ;
27
- use rustc:: hir:: map:: DefPathData ;
28
27
use rustc:: ty;
29
28
30
29
use std:: cell:: Cell ;
@@ -398,15 +397,9 @@ impl<'b> Resolver<'b> {
398
397
/// Builds the reduced graph for a single item in an external crate.
399
398
fn build_reduced_graph_for_external_crate_def ( & mut self , parent : Module < ' b > ,
400
399
child : Export ) {
401
- let def_id = child. def_id ;
402
400
let name = child. name ;
403
-
404
- let def = if let Some ( def) = self . session . cstore . describe_def ( def_id) {
405
- def
406
- } else {
407
- return ;
408
- } ;
409
-
401
+ let def = child. def ;
402
+ let def_id = def. def_id ( ) ;
410
403
let vis = if parent. is_trait ( ) {
411
404
ty:: Visibility :: Public
412
405
} else {
@@ -424,14 +417,15 @@ impl<'b> Resolver<'b> {
424
417
debug ! ( "(building reduced graph for external crate) building variant {}" , name) ;
425
418
// All variants are defined in both type and value namespaces as future-proofing.
426
419
let vkind = self . session . cstore . variant_kind ( def_id) . unwrap ( ) ;
427
- let ctor_def = Def :: VariantCtor ( def_id, vkind. ctor_kind ( ) ) ;
428
420
let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
429
- let _ = self . try_define ( parent, name, ValueNS , ( ctor_def, DUMMY_SP , vis) ) ;
430
421
if vkind == ty:: VariantKind :: Struct {
431
422
// Not adding fields for variants as they are not accessed with a self receiver
432
423
self . structs . insert ( def_id, Vec :: new ( ) ) ;
433
424
}
434
425
}
426
+ Def :: VariantCtor ( ..) => {
427
+ let _ = self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
428
+ }
435
429
Def :: Fn ( ..) |
436
430
Def :: Static ( ..) |
437
431
Def :: Const ( ..) |
@@ -468,33 +462,25 @@ impl<'b> Resolver<'b> {
468
462
debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
469
463
let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
470
464
}
471
- Def :: Struct ( ..)
472
- if self . session . cstore . def_key ( def_id) . disambiguated_data . data !=
473
- DefPathData :: StructCtor
474
- => {
465
+ Def :: Struct ( ..) => {
475
466
debug ! ( "(building reduced graph for external crate) building type and value for {}" ,
476
467
name) ;
477
468
let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
478
- if let Some ( ctor_def_id) = self . session . cstore . struct_ctor_def_id ( def_id) {
479
- let vkind = self . session . cstore . variant_kind ( def_id) . unwrap ( ) ;
480
- let ctor_def = Def :: StructCtor ( ctor_def_id, vkind. ctor_kind ( ) ) ;
481
- let _ = self . try_define ( parent, name, ValueNS , ( ctor_def, DUMMY_SP , vis) ) ;
482
- }
483
469
484
470
// Record the def ID and fields of this struct.
485
471
let fields = self . session . cstore . struct_field_names ( def_id) ;
486
472
self . structs . insert ( def_id, fields) ;
487
473
}
474
+ Def :: StructCtor ( ..) => {
475
+ let _ = self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
476
+ }
488
477
Def :: Union ( _) => {
489
478
let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
490
479
491
480
// Record the def ID and fields of this union.
492
481
let fields = self . session . cstore . struct_field_names ( def_id) ;
493
482
self . structs . insert ( def_id, fields) ;
494
483
}
495
- Def :: Struct ( ..) => { }
496
- Def :: VariantCtor ( ..) |
497
- Def :: StructCtor ( ..) |
498
484
Def :: Local ( ..) |
499
485
Def :: PrimTy ( ..) |
500
486
Def :: TyParam ( ..) |
0 commit comments