@@ -24,7 +24,6 @@ use {resolve_error, resolve_struct_error, ResolutionError};
2424use rustc:: middle:: cstore:: LoadedMacroKind ;
2525use rustc:: hir:: def:: * ;
2626use rustc:: hir:: def_id:: { CRATE_DEF_INDEX , DefId } ;
27- use rustc:: hir:: map:: DefPathData ;
2827use rustc:: ty;
2928
3029use std:: cell:: Cell ;
@@ -398,15 +397,9 @@ impl<'b> Resolver<'b> {
398397 /// Builds the reduced graph for a single item in an external crate.
399398 fn build_reduced_graph_for_external_crate_def ( & mut self , parent : Module < ' b > ,
400399 child : Export ) {
401- let def_id = child. def_id ;
402400 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 ( ) ;
410403 let vis = if parent. is_trait ( ) {
411404 ty:: Visibility :: Public
412405 } else {
@@ -424,14 +417,15 @@ impl<'b> Resolver<'b> {
424417 debug ! ( "(building reduced graph for external crate) building variant {}" , name) ;
425418 // All variants are defined in both type and value namespaces as future-proofing.
426419 let vkind = self . session . cstore . variant_kind ( def_id) . unwrap ( ) ;
427- let ctor_def = Def :: VariantCtor ( def_id, vkind. ctor_kind ( ) ) ;
428420 let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
429- let _ = self . try_define ( parent, name, ValueNS , ( ctor_def, DUMMY_SP , vis) ) ;
430421 if vkind == ty:: VariantKind :: Struct {
431422 // Not adding fields for variants as they are not accessed with a self receiver
432423 self . structs . insert ( def_id, Vec :: new ( ) ) ;
433424 }
434425 }
426+ Def :: VariantCtor ( ..) => {
427+ let _ = self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
428+ }
435429 Def :: Fn ( ..) |
436430 Def :: Static ( ..) |
437431 Def :: Const ( ..) |
@@ -468,33 +462,25 @@ impl<'b> Resolver<'b> {
468462 debug ! ( "(building reduced graph for external crate) building type {}" , name) ;
469463 let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
470464 }
471- Def :: Struct ( ..)
472- if self . session . cstore . def_key ( def_id) . disambiguated_data . data !=
473- DefPathData :: StructCtor
474- => {
465+ Def :: Struct ( ..) => {
475466 debug ! ( "(building reduced graph for external crate) building type and value for {}" ,
476467 name) ;
477468 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- }
483469
484470 // Record the def ID and fields of this struct.
485471 let fields = self . session . cstore . struct_field_names ( def_id) ;
486472 self . structs . insert ( def_id, fields) ;
487473 }
474+ Def :: StructCtor ( ..) => {
475+ let _ = self . try_define ( parent, name, ValueNS , ( def, DUMMY_SP , vis) ) ;
476+ }
488477 Def :: Union ( _) => {
489478 let _ = self . try_define ( parent, name, TypeNS , ( def, DUMMY_SP , vis) ) ;
490479
491480 // Record the def ID and fields of this union.
492481 let fields = self . session . cstore . struct_field_names ( def_id) ;
493482 self . structs . insert ( def_id, fields) ;
494483 }
495- Def :: Struct ( ..) => { }
496- Def :: VariantCtor ( ..) |
497- Def :: StructCtor ( ..) |
498484 Def :: Local ( ..) |
499485 Def :: PrimTy ( ..) |
500486 Def :: TyParam ( ..) |
0 commit comments