File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ pub struct Dependency {
34
34
pub default_features : bool ,
35
35
pub target : Option < String > ,
36
36
pub kind : Option < DependencyKind > ,
37
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
38
+ pub package : Option < String > ,
37
39
}
38
40
39
41
fn index_file ( base : & Path , name : & str ) -> PathBuf {
Original file line number Diff line number Diff line change @@ -96,15 +96,26 @@ pub fn add_dependencies(
96
96
) ) ;
97
97
}
98
98
99
+ // If this dependency has an explicit name in `Cargo.toml` that
100
+ // means that the `name` we have listed is actually the package name
101
+ // that we're depending on. The `name` listed in the index is the
102
+ // Cargo.toml-written-name which is what cargo uses for
103
+ // `--extern foo=...`
104
+ let ( name, package) = match & dep. explicit_name_in_toml {
105
+ Some ( explicit) => ( explicit. to_string ( ) , Some ( dep. name . to_string ( ) ) ) ,
106
+ None => ( dep. name . to_string ( ) , None ) ,
107
+ } ;
108
+
99
109
Ok ( (
100
110
git:: Dependency {
101
- name : dep . name . to_string ( ) ,
111
+ name,
102
112
req : dep. version_req . to_string ( ) ,
103
113
features : dep. features . iter ( ) . map ( |s| s. to_string ( ) ) . collect ( ) ,
104
114
optional : dep. optional ,
105
115
default_features : dep. default_features ,
106
116
target : dep. target . clone ( ) ,
107
117
kind : dep. kind . or ( Some ( DependencyKind :: Normal ) ) ,
118
+ package,
108
119
} ,
109
120
(
110
121
version_id. eq ( target_version_id) ,
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ pub struct CrateDependency {
63
63
pub version_req : CrateVersionReq ,
64
64
pub target : Option < String > ,
65
65
pub kind : Option < DependencyKind > ,
66
+ pub explicit_name_in_toml : Option < CrateName > ,
66
67
}
67
68
68
69
impl < ' de > Deserialize < ' de > for CrateName {
You can’t perform that action at this time.
0 commit comments