@@ -135,8 +135,12 @@ impl ops::Deref for CrateName {
135
135
/// Origin of the crates. It is used in emitting monikers.
136
136
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
137
137
pub enum CrateOrigin {
138
- /// Crates that are from crates.io official registry,
139
- CratesIo { repo : Option < String > , name : Option < String > } ,
138
+ /// Crates that are from the rustc workspace
139
+ Rustc { name : String } ,
140
+ /// Crates that are workspace members,
141
+ Local { repo : Option < String > , name : Option < String > } ,
142
+ /// Crates that are non member libraries.
143
+ Library { repo : Option < String > , name : String } ,
140
144
/// Crates that are provided by the language, like std, core, proc-macro, ...
141
145
Lang ( LangCrateOrigin ) ,
142
146
}
@@ -257,6 +261,32 @@ pub struct ProcMacro {
257
261
pub expander : Arc < dyn ProcMacroExpander > ,
258
262
}
259
263
264
+ #[ derive( Debug , Copy , Clone ) ]
265
+ pub enum ReleaseChannel {
266
+ Stable ,
267
+ Beta ,
268
+ Nightly ,
269
+ }
270
+
271
+ impl ReleaseChannel {
272
+ pub fn as_str ( self ) -> & ' static str {
273
+ match self {
274
+ ReleaseChannel :: Stable => "stable" ,
275
+ ReleaseChannel :: Beta => "beta" ,
276
+ ReleaseChannel :: Nightly => "nightly" ,
277
+ }
278
+ }
279
+
280
+ pub fn from_str ( str : & str ) -> Option < Self > {
281
+ Some ( match str {
282
+ "stable" => ReleaseChannel :: Stable ,
283
+ "beta" => ReleaseChannel :: Beta ,
284
+ "nightly" => ReleaseChannel :: Nightly ,
285
+ _ => return None ,
286
+ } )
287
+ }
288
+ }
289
+
260
290
#[ derive( Debug , Clone ) ]
261
291
pub struct CrateData {
262
292
pub root_file_id : FileId ,
@@ -271,11 +301,13 @@ pub struct CrateData {
271
301
pub display_name : Option < CrateDisplayName > ,
272
302
pub cfg_options : CfgOptions ,
273
303
pub potential_cfg_options : CfgOptions ,
274
- pub target_layout : TargetLayoutLoadResult ,
275
304
pub env : Env ,
276
305
pub dependencies : Vec < Dependency > ,
277
306
pub origin : CrateOrigin ,
278
307
pub is_proc_macro : bool ,
308
+ // FIXME: These things should not be per crate! These are more per workspace crate graph level things
309
+ pub target_layout : TargetLayoutLoadResult ,
310
+ pub channel : Option < ReleaseChannel > ,
279
311
}
280
312
281
313
#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
@@ -329,6 +361,7 @@ impl CrateGraph {
329
361
is_proc_macro : bool ,
330
362
origin : CrateOrigin ,
331
363
target_layout : Result < Arc < str > , Arc < str > > ,
364
+ channel : Option < ReleaseChannel > ,
332
365
) -> CrateId {
333
366
let data = CrateData {
334
367
root_file_id,
@@ -342,6 +375,7 @@ impl CrateGraph {
342
375
origin,
343
376
target_layout,
344
377
is_proc_macro,
378
+ channel,
345
379
} ;
346
380
let crate_id = CrateId ( self . arena . len ( ) as u32 ) ;
347
381
let prev = self . arena . insert ( crate_id, data) ;
@@ -653,8 +687,9 @@ mod tests {
653
687
CfgOptions :: default ( ) ,
654
688
Env :: default ( ) ,
655
689
false ,
656
- CrateOrigin :: CratesIo { repo : None , name : None } ,
690
+ CrateOrigin :: Local { repo : None , name : None } ,
657
691
Err ( "" . into ( ) ) ,
692
+ None ,
658
693
) ;
659
694
let crate2 = graph. add_crate_root (
660
695
FileId ( 2u32 ) ,
@@ -665,8 +700,9 @@ mod tests {
665
700
CfgOptions :: default ( ) ,
666
701
Env :: default ( ) ,
667
702
false ,
668
- CrateOrigin :: CratesIo { repo : None , name : None } ,
703
+ CrateOrigin :: Local { repo : None , name : None } ,
669
704
Err ( "" . into ( ) ) ,
705
+ None ,
670
706
) ;
671
707
let crate3 = graph. add_crate_root (
672
708
FileId ( 3u32 ) ,
@@ -677,8 +713,9 @@ mod tests {
677
713
CfgOptions :: default ( ) ,
678
714
Env :: default ( ) ,
679
715
false ,
680
- CrateOrigin :: CratesIo { repo : None , name : None } ,
716
+ CrateOrigin :: Local { repo : None , name : None } ,
681
717
Err ( "" . into ( ) ) ,
718
+ None ,
682
719
) ;
683
720
assert ! ( graph
684
721
. add_dep( crate1, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2) )
@@ -703,8 +740,9 @@ mod tests {
703
740
CfgOptions :: default ( ) ,
704
741
Env :: default ( ) ,
705
742
false ,
706
- CrateOrigin :: CratesIo { repo : None , name : None } ,
743
+ CrateOrigin :: Local { repo : None , name : None } ,
707
744
Err ( "" . into ( ) ) ,
745
+ None ,
708
746
) ;
709
747
let crate2 = graph. add_crate_root (
710
748
FileId ( 2u32 ) ,
@@ -715,8 +753,9 @@ mod tests {
715
753
CfgOptions :: default ( ) ,
716
754
Env :: default ( ) ,
717
755
false ,
718
- CrateOrigin :: CratesIo { repo : None , name : None } ,
756
+ CrateOrigin :: Local { repo : None , name : None } ,
719
757
Err ( "" . into ( ) ) ,
758
+ None ,
720
759
) ;
721
760
assert ! ( graph
722
761
. add_dep( crate1, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2) )
@@ -738,8 +777,9 @@ mod tests {
738
777
CfgOptions :: default ( ) ,
739
778
Env :: default ( ) ,
740
779
false ,
741
- CrateOrigin :: CratesIo { repo : None , name : None } ,
780
+ CrateOrigin :: Local { repo : None , name : None } ,
742
781
Err ( "" . into ( ) ) ,
782
+ None ,
743
783
) ;
744
784
let crate2 = graph. add_crate_root (
745
785
FileId ( 2u32 ) ,
@@ -750,8 +790,9 @@ mod tests {
750
790
CfgOptions :: default ( ) ,
751
791
Env :: default ( ) ,
752
792
false ,
753
- CrateOrigin :: CratesIo { repo : None , name : None } ,
793
+ CrateOrigin :: Local { repo : None , name : None } ,
754
794
Err ( "" . into ( ) ) ,
795
+ None ,
755
796
) ;
756
797
let crate3 = graph. add_crate_root (
757
798
FileId ( 3u32 ) ,
@@ -762,8 +803,9 @@ mod tests {
762
803
CfgOptions :: default ( ) ,
763
804
Env :: default ( ) ,
764
805
false ,
765
- CrateOrigin :: CratesIo { repo : None , name : None } ,
806
+ CrateOrigin :: Local { repo : None , name : None } ,
766
807
Err ( "" . into ( ) ) ,
808
+ None ,
767
809
) ;
768
810
assert ! ( graph
769
811
. add_dep( crate1, Dependency :: new( CrateName :: new( "crate2" ) . unwrap( ) , crate2) )
@@ -785,8 +827,9 @@ mod tests {
785
827
CfgOptions :: default ( ) ,
786
828
Env :: default ( ) ,
787
829
false ,
788
- CrateOrigin :: CratesIo { repo : None , name : None } ,
830
+ CrateOrigin :: Local { repo : None , name : None } ,
789
831
Err ( "" . into ( ) ) ,
832
+ None ,
790
833
) ;
791
834
let crate2 = graph. add_crate_root (
792
835
FileId ( 2u32 ) ,
@@ -797,8 +840,9 @@ mod tests {
797
840
CfgOptions :: default ( ) ,
798
841
Env :: default ( ) ,
799
842
false ,
800
- CrateOrigin :: CratesIo { repo : None , name : None } ,
843
+ CrateOrigin :: Local { repo : None , name : None } ,
801
844
Err ( "" . into ( ) ) ,
845
+ None ,
802
846
) ;
803
847
assert ! ( graph
804
848
. add_dep(
0 commit comments