@@ -14,6 +14,7 @@ use rustc_hash::FxHashMap;
1414use rustc_hash:: FxHashSet ;
1515
1616use crate :: { RelativePath , RelativePathBuf } ;
17+ use fmt:: Display ;
1718
1819/// `FileId` is an integer which uniquely identifies a file. File paths are
1920/// messy and system-dependent, so most of the code should work directly with
@@ -83,6 +84,7 @@ pub struct CrateGraph {
8384#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
8485pub struct CrateId ( pub u32 ) ;
8586
87+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
8688pub struct CrateName ( SmolStr ) ;
8789
8890impl CrateName {
@@ -103,14 +105,20 @@ impl CrateName {
103105 }
104106}
105107
108+ impl Display for CrateName {
109+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
110+ write ! ( f, "{}" , self . 0 )
111+ }
112+ }
113+
106114#[ derive( Debug , Clone , PartialEq , Eq ) ]
107115pub struct CrateData {
108116 pub root_file_id : FileId ,
109117 pub edition : Edition ,
110118 /// The name to display to the end user.
111119 /// This actual crate name can be different in a particular dependent crate
112120 /// or may even be missing for some cases, such as a dummy crate for the code snippet.
113- pub display_name : Option < String > ,
121+ pub display_name : Option < CrateName > ,
114122 pub cfg_options : CfgOptions ,
115123 pub env : Env ,
116124 pub extern_source : ExternSource ,
@@ -150,7 +158,7 @@ impl CrateGraph {
150158 & mut self ,
151159 file_id : FileId ,
152160 edition : Edition ,
153- display_name : Option < String > ,
161+ display_name : Option < CrateName > ,
154162 cfg_options : CfgOptions ,
155163 env : Env ,
156164 extern_source : ExternSource ,
0 commit comments