Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eebd1da

Browse files
committedJun 20, 2019
Auto merge of #7048 - jeremystucki:into_url, r=Eh2406
Rename to_url → into_url I think it should be `into_url` as it consumes itself. [Relevant clippy lint](https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention)
2 parents 92427df + 2415a29 commit eebd1da

File tree

18 files changed

+77
-77
lines changed

18 files changed

+77
-77
lines changed
 

‎crates/resolver-tests/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use cargo::core::resolver::{self, Method};
99
use cargo::core::source::{GitReference, SourceId};
1010
use cargo::core::Resolve;
1111
use cargo::core::{Dependency, PackageId, Registry, Summary};
12-
use cargo::util::{CargoResult, Config, Graph, ToUrl};
12+
use cargo::util::{CargoResult, Config, Graph, IntoUrl};
1313

1414
use proptest::collection::{btree_map, vec};
1515
use proptest::prelude::*;
@@ -504,7 +504,7 @@ macro_rules! pkg {
504504
fn registry_loc() -> SourceId {
505505
lazy_static::lazy_static! {
506506
static ref EXAMPLE_DOT_COM: SourceId =
507-
SourceId::for_registry(&"https://example.com".to_url().unwrap()).unwrap();
507+
SourceId::for_registry(&"https://example.com".into_url().unwrap()).unwrap();
508508
}
509509
*EXAMPLE_DOT_COM
510510
}
@@ -535,7 +535,7 @@ pub fn pkg_id(name: &str) -> PackageId {
535535
}
536536

537537
fn pkg_id_loc(name: &str, loc: &str) -> PackageId {
538-
let remote = loc.to_url();
538+
let remote = loc.into_url();
539539
let master = GitReference::Branch("master".to_string());
540540
let source_id = SourceId::for_git(&remote.unwrap(), master).unwrap();
541541

@@ -586,7 +586,7 @@ pub fn dep_req_kind(name: &str, req: &str, kind: Kind, public: bool) -> Dependen
586586
}
587587

588588
pub fn dep_loc(name: &str, location: &str) -> Dependency {
589-
let url = location.to_url().unwrap();
589+
let url = location.into_url().unwrap();
590590
let master = GitReference::Branch("master".to_string());
591591
let source_id = SourceId::for_git(&url, master).unwrap();
592592
Dependency::parse_no_deprecated(name, Some("1.0.0"), source_id).unwrap()

‎src/bin/cargo/commands/git_checkout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::command_prelude::*;
22

33
use cargo::core::{GitReference, Source, SourceId};
44
use cargo::sources::GitSource;
5-
use cargo::util::ToUrl;
5+
use cargo::util::IntoUrl;
66

77
pub fn cli() -> App {
88
subcommand("git-checkout")
@@ -23,7 +23,7 @@ pub fn cli() -> App {
2323
}
2424

2525
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
26-
let url = args.value_of("url").unwrap().to_url()?;
26+
let url = args.value_of("url").unwrap().into_url()?;
2727
let reference = args.value_of("reference").unwrap();
2828

2929
let reference = GitReference::Branch(reference.to_string());

‎src/bin/cargo/commands/install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::command_prelude::*;
22

33
use cargo::core::{GitReference, SourceId};
44
use cargo::ops;
5-
use cargo::util::ToUrl;
5+
use cargo::util::IntoUrl;
66

77
pub fn cli() -> App {
88
subcommand("install")
@@ -127,7 +127,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
127127
let mut from_cwd = false;
128128

129129
let source = if let Some(url) = args.value_of("git") {
130-
let url = url.to_url()?;
130+
let url = url.into_url()?;
131131
let gitref = if let Some(branch) = args.value_of("branch") {
132132
GitReference::Branch(branch.to_string())
133133
} else if let Some(tag) = args.value_of("tag") {

‎src/cargo/core/package_id.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl ser::Serialize for PackageId {
5959
"{} {} ({})",
6060
self.inner.name,
6161
self.inner.version,
62-
self.inner.source_id.to_url()
62+
self.inner.source_id.into_url()
6363
))
6464
}
6565
}
@@ -205,11 +205,11 @@ mod tests {
205205
use super::PackageId;
206206
use crate::core::source::SourceId;
207207
use crate::sources::CRATES_IO_INDEX;
208-
use crate::util::ToUrl;
208+
use crate::util::IntoUrl;
209209

210210
#[test]
211211
fn invalid_version_handled_nicely() {
212-
let loc = CRATES_IO_INDEX.to_url().unwrap();
212+
let loc = CRATES_IO_INDEX.into_url().unwrap();
213213
let repo = SourceId::for_registry(&loc).unwrap();
214214

215215
assert!(PackageId::new("foo", "1.0", repo).is_err());
@@ -220,7 +220,7 @@ mod tests {
220220

221221
#[test]
222222
fn debug() {
223-
let loc = CRATES_IO_INDEX.to_url().unwrap();
223+
let loc = CRATES_IO_INDEX.into_url().unwrap();
224224
let pkg_id = PackageId::new("foo", "1.0.0", SourceId::for_registry(&loc).unwrap()).unwrap();
225225
assert_eq!(r#"PackageId { name: "foo", version: "1.0.0", source: "registry `https://github.com/rust-lang/crates.io-index`" }"#, format!("{:?}", pkg_id));
226226

@@ -254,7 +254,7 @@ PackageId {
254254

255255
#[test]
256256
fn display() {
257-
let loc = CRATES_IO_INDEX.to_url().unwrap();
257+
let loc = CRATES_IO_INDEX.into_url().unwrap();
258258
let pkg_id = PackageId::new("foo", "1.0.0", SourceId::for_registry(&loc).unwrap()).unwrap();
259259
assert_eq!("foo v1.0.0", pkg_id.to_string());
260260
}

‎src/cargo/core/package_id_spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use url::Url;
88
use crate::core::interning::InternedString;
99
use crate::core::PackageId;
1010
use crate::util::errors::{CargoResult, CargoResultExt};
11-
use crate::util::{validate_package_name, ToSemver, ToUrl};
11+
use crate::util::{validate_package_name, IntoUrl, ToSemver};
1212

1313
/// Some or all of the data required to identify a package:
1414
///
@@ -50,7 +50,7 @@ impl PackageIdSpec {
5050
/// }
5151
pub fn parse(spec: &str) -> CargoResult<PackageIdSpec> {
5252
if spec.contains('/') {
53-
if let Ok(url) = spec.to_url() {
53+
if let Ok(url) = spec.into_url() {
5454
return PackageIdSpec::from_url(url);
5555
}
5656
if !spec.contains("://") {

‎src/cargo/core/resolver/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl fmt::Display for EncodablePackageId {
269269
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
270270
write!(f, "{} {}", self.name, self.version)?;
271271
if let Some(ref s) = self.source {
272-
write!(f, " ({})", s.to_url())?;
272+
write!(f, " ({})", s.into_url())?;
273273
}
274274
Ok(())
275275
}

‎src/cargo/core/source/source_id.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::ops;
1818
use crate::sources::git;
1919
use crate::sources::DirectorySource;
2020
use crate::sources::{GitSource, PathSource, RegistrySource, CRATES_IO_INDEX};
21-
use crate::util::{CargoResult, Config, ToUrl};
21+
use crate::util::{CargoResult, Config, IntoUrl};
2222

2323
lazy_static::lazy_static! {
2424
static ref SOURCE_ID_CACHE: Mutex<HashSet<&'static SourceIdInner>> = Mutex::new(HashSet::new());
@@ -117,7 +117,7 @@ impl SourceId {
117117

118118
match kind {
119119
"git" => {
120-
let mut url = url.to_url()?;
120+
let mut url = url.into_url()?;
121121
let mut reference = GitReference::Branch("master".to_string());
122122
for (k, v) in url.query_pairs() {
123123
match &k[..] {
@@ -135,11 +135,11 @@ impl SourceId {
135135
Ok(SourceId::for_git(&url, reference)?.with_precise(precise))
136136
}
137137
"registry" => {
138-
let url = url.to_url()?;
138+
let url = url.into_url()?;
139139
Ok(SourceId::new(Kind::Registry, url)?.with_precise(Some("locked".to_string())))
140140
}
141141
"path" => {
142-
let url = url.to_url()?;
142+
let url = url.into_url()?;
143143
SourceId::new(Kind::Path, url)
144144
}
145145
kind => Err(failure::format_err!(
@@ -150,8 +150,8 @@ impl SourceId {
150150
}
151151

152152
/// A view of the `SourceId` that can be `Display`ed as a URL.
153-
pub fn to_url(&self) -> SourceIdToUrl<'_> {
154-
SourceIdToUrl {
153+
pub fn into_url(&self) -> SourceIdIntoUrl<'_> {
154+
SourceIdIntoUrl {
155155
inner: &*self.inner,
156156
}
157157
}
@@ -160,7 +160,7 @@ impl SourceId {
160160
///
161161
/// `path`: an absolute path.
162162
pub fn for_path(path: &Path) -> CargoResult<SourceId> {
163-
let url = path.to_url()?;
163+
let url = path.into_url()?;
164164
SourceId::new(Kind::Path, url)
165165
}
166166

@@ -176,13 +176,13 @@ impl SourceId {
176176

177177
/// Creates a SourceId from a local registry path.
178178
pub fn for_local_registry(path: &Path) -> CargoResult<SourceId> {
179-
let url = path.to_url()?;
179+
let url = path.into_url()?;
180180
SourceId::new(Kind::LocalRegistry, url)
181181
}
182182

183183
/// Creates a `SourceId` from a directory path.
184184
pub fn for_directory(path: &Path) -> CargoResult<SourceId> {
185-
let url = path.to_url()?;
185+
let url = path.into_url()?;
186186
SourceId::new(Kind::Directory, url)
187187
}
188188

@@ -207,7 +207,7 @@ impl SourceId {
207207
} else {
208208
CRATES_IO_INDEX
209209
};
210-
let url = url.to_url()?;
210+
let url = url.into_url()?;
211211
SourceId::for_registry(&url)
212212
})
213213
}
@@ -390,7 +390,7 @@ impl ser::Serialize for SourceId {
390390
if self.is_path() {
391391
None::<String>.serialize(s)
392392
} else {
393-
s.collect_str(&self.to_url())
393+
s.collect_str(&self.into_url())
394394
}
395395
}
396396
}
@@ -504,11 +504,11 @@ impl Hash for SourceId {
504504
}
505505

506506
/// A `Display`able view into a `SourceId` that will write it as a url
507-
pub struct SourceIdToUrl<'a> {
507+
pub struct SourceIdIntoUrl<'a> {
508508
inner: &'a SourceIdInner,
509509
}
510510

511-
impl<'a> fmt::Display for SourceIdToUrl<'a> {
511+
impl<'a> fmt::Display for SourceIdIntoUrl<'a> {
512512
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
513513
match *self.inner {
514514
SourceIdInner {
@@ -579,15 +579,15 @@ impl<'a> fmt::Display for PrettyRef<'a> {
579579
#[cfg(test)]
580580
mod tests {
581581
use super::{GitReference, Kind, SourceId};
582-
use crate::util::ToUrl;
582+
use crate::util::IntoUrl;
583583

584584
#[test]
585585
fn github_sources_equal() {
586-
let loc = "https://github.com/foo/bar".to_url().unwrap();
586+
let loc = "https://github.com/foo/bar".into_url().unwrap();
587587
let master = Kind::Git(GitReference::Branch("master".to_string()));
588588
let s1 = SourceId::new(master.clone(), loc).unwrap();
589589

590-
let loc = "git://github.com/foo/bar".to_url().unwrap();
590+
let loc = "git://github.com/foo/bar".into_url().unwrap();
591591
let s2 = SourceId::new(master, loc.clone()).unwrap();
592592

593593
assert_eq!(s1, s2);

‎src/cargo/ops/registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::sources::{RegistrySource, SourceConfigMap, CRATES_IO_REGISTRY};
2121
use crate::util::config::{self, Config};
2222
use crate::util::errors::{CargoResult, CargoResultExt};
2323
use crate::util::important_paths::find_root_manifest_for_wd;
24-
use crate::util::ToUrl;
24+
use crate::util::IntoUrl;
2525
use crate::util::{paths, validate_package_name};
2626
use crate::version;
2727

@@ -696,7 +696,7 @@ fn get_source_id(
696696
) -> CargoResult<SourceId> {
697697
match (reg, index) {
698698
(Some(r), _) => SourceId::alt_registry(config, &r),
699-
(_, Some(i)) => SourceId::for_registry(&i.to_url()?),
699+
(_, Some(i)) => SourceId::for_registry(&i.into_url()?),
700700
_ => {
701701
let map = SourceConfigMap::new(config)?;
702702
let src = map.load(SourceId::crates_io(config)?, &HashSet::new())?;

‎src/cargo/sources/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::core::{GitReference, PackageId, Source, SourceId};
1414
use crate::sources::{ReplacedSource, CRATES_IO_REGISTRY};
1515
use crate::util::config::ConfigValue;
1616
use crate::util::errors::{CargoResult, CargoResultExt};
17-
use crate::util::{Config, ToUrl};
17+
use crate::util::{Config, IntoUrl};
1818

1919
#[derive(Clone)]
2020
pub struct SourceConfigMap<'cfg> {
@@ -242,7 +242,7 @@ restore the source replacement configuration to continue the build
242242

243243
fn url(cfg: &ConfigValue, key: &str) -> CargoResult<Url> {
244244
let (url, path) = cfg.string(key)?;
245-
let url = url.to_url().chain_err(|| {
245+
let url = url.into_url().chain_err(|| {
246246
format!(
247247
"configuration key `{}` specified an invalid \
248248
URL (in {})",

‎src/cargo/sources/git/source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'cfg> Source for GitSource<'cfg> {
241241
#[cfg(test)]
242242
mod test {
243243
use super::ident;
244-
use crate::util::ToUrl;
244+
use crate::util::IntoUrl;
245245
use url::Url;
246246

247247
#[test]
@@ -291,6 +291,6 @@ mod test {
291291
}
292292

293293
fn url(s: &str) -> Url {
294-
s.to_url().unwrap()
294+
s.into_url().unwrap()
295295
}
296296
}

‎src/cargo/sources/git/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::core::GitReference;
1616
use crate::util::errors::{CargoResult, CargoResultExt};
1717
use crate::util::paths;
1818
use crate::util::process_builder::process;
19-
use crate::util::{internal, network, Config, Progress, ToUrl};
19+
use crate::util::{internal, network, Config, IntoUrl, Progress};
2020

2121
#[derive(PartialEq, Clone, Debug)]
2222
pub struct GitRevision(git2::Oid);
@@ -274,7 +274,7 @@ impl<'a> GitCheckout<'a> {
274274
//
275275
// Note that we still use the same fetch options because while we don't
276276
// need authentication information we may want progress bars and such.
277-
let url = database.path.to_url()?;
277+
let url = database.path.into_url()?;
278278
let mut repo = None;
279279
with_fetch_options(&git_config, &url, config, &mut |fopts| {
280280
let mut checkout = git2::build::CheckoutBuilder::new();
@@ -310,7 +310,7 @@ impl<'a> GitCheckout<'a> {
310310

311311
fn fetch(&mut self, cargo_config: &Config) -> CargoResult<()> {
312312
info!("fetch {}", self.repo.path().display());
313-
let url = self.database.path.to_url()?;
313+
let url = self.database.path.into_url()?;
314314
let refspec = "refs/heads/*:refs/heads/*";
315315
fetch(&mut self.repo, &url, refspec, cargo_config)?;
316316
Ok(())
@@ -396,7 +396,7 @@ impl<'a> GitCheckout<'a> {
396396

397397
// Fetch data from origin and reset to the head commit
398398
let refspec = "refs/heads/*:refs/heads/*";
399-
let url = url.to_url()?;
399+
let url = url.into_url()?;
400400
fetch(&mut repo, &url, refspec, cargo_config).chain_err(|| {
401401
internal(format!(
402402
"failed to fetch submodule `{}` from {}",

‎src/cargo/sources/registry/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ use crate::core::{InternedString, Package, PackageId, Source, SourceId, Summary}
177177
use crate::sources::PathSource;
178178
use crate::util::errors::CargoResultExt;
179179
use crate::util::hex;
180-
use crate::util::to_url::ToUrl;
180+
use crate::util::into_url::IntoUrl;
181181
use crate::util::{internal, CargoResult, Config, Filesystem};
182182

183183
const PACKAGE_SOURCE_LOCK: &str = ".cargo-ok";
@@ -304,7 +304,7 @@ impl<'a> RegistryDependency<'a> {
304304
} = self;
305305

306306
let id = if let Some(registry) = &registry {
307-
SourceId::for_registry(&registry.to_url()?)?
307+
SourceId::for_registry(&registry.into_url()?)?
308308
} else {
309309
default
310310
};

‎src/cargo/util/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::util::toml as cargo_toml;
3030
use crate::util::Filesystem;
3131
use crate::util::Rustc;
3232
use crate::util::{paths, validate_package_name, FileLock};
33-
use crate::util::{ToUrl, ToUrlWithBase};
33+
use crate::util::{IntoUrl, IntoUrlWithBase};
3434

3535
/// Configuration information for cargo. This is not specific to a build, it is information
3636
/// relating to cargo itself.
@@ -714,8 +714,8 @@ impl Config {
714714
.root(self)
715715
.join("truncated-by-url_with_base");
716716
// Parse val to check it is a URL, not a relative path without a protocol.
717-
let _parsed = index.val.to_url()?;
718-
let url = index.val.to_url_with_base(Some(&*base))?;
717+
let _parsed = index.val.into_url()?;
718+
let url = index.val.into_url_with_base(Some(&*base))?;
719719
if url.password().is_some() {
720720
failure::bail!("Registry URLs may not contain passwords");
721721
}

‎src/cargo/util/to_url.rs renamed to ‎src/cargo/util/into_url.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ use url::Url;
55
use crate::util::CargoResult;
66

77
/// A type that can be converted to a Url
8-
pub trait ToUrl {
8+
pub trait IntoUrl {
99
/// Performs the conversion
10-
fn to_url(self) -> CargoResult<Url>;
10+
fn into_url(self) -> CargoResult<Url>;
1111
}
1212

13-
impl<'a> ToUrl for &'a str {
14-
fn to_url(self) -> CargoResult<Url> {
13+
impl<'a> IntoUrl for &'a str {
14+
fn into_url(self) -> CargoResult<Url> {
1515
Url::parse(self).map_err(|s| failure::format_err!("invalid url `{}`: {}", self, s))
1616
}
1717
}
1818

19-
impl<'a> ToUrl for &'a Path {
20-
fn to_url(self) -> CargoResult<Url> {
19+
impl<'a> IntoUrl for &'a Path {
20+
fn into_url(self) -> CargoResult<Url> {
2121
Url::from_file_path(self)
2222
.map_err(|()| failure::format_err!("invalid path url `{}`", self.display()))
2323
}
2424
}
2525

26-
impl<'a> ToUrl for &'a PathBuf {
27-
fn to_url(self) -> CargoResult<Url> {
28-
self.as_path().to_url()
26+
impl<'a> IntoUrl for &'a PathBuf {
27+
fn into_url(self) -> CargoResult<Url> {
28+
self.as_path().into_url()
2929
}
3030
}

‎src/cargo/util/to_url_with_base.rs renamed to ‎src/cargo/util/into_url_with_base.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
use crate::util::{CargoResult, ToUrl};
1+
use crate::util::{CargoResult, IntoUrl};
22

33
use url::Url;
44

55
/// A type that can be interpreted as a relative Url and converted to
66
/// a Url.
7-
pub trait ToUrlWithBase {
7+
pub trait IntoUrlWithBase {
88
/// Performs the conversion
9-
fn to_url_with_base<U: ToUrl>(self, base: Option<U>) -> CargoResult<Url>;
9+
fn into_url_with_base<U: IntoUrl>(self, base: Option<U>) -> CargoResult<Url>;
1010
}
1111

12-
impl<'a> ToUrlWithBase for &'a str {
13-
fn to_url_with_base<U: ToUrl>(self, base: Option<U>) -> CargoResult<Url> {
12+
impl<'a> IntoUrlWithBase for &'a str {
13+
fn into_url_with_base<U: IntoUrl>(self, base: Option<U>) -> CargoResult<Url> {
1414
let base_url = match base {
1515
Some(base) => Some(
16-
base.to_url()
16+
base.into_url()
1717
.map_err(|s| failure::format_err!("invalid url `{}`: {}", self, s))?,
1818
),
1919
None => None,
@@ -28,20 +28,20 @@ impl<'a> ToUrlWithBase for &'a str {
2828

2929
#[cfg(test)]
3030
mod tests {
31-
use crate::util::ToUrlWithBase;
31+
use crate::util::IntoUrlWithBase;
3232

3333
#[test]
34-
fn to_url_with_base() {
34+
fn into_url_with_base() {
3535
assert_eq!(
3636
"rel/path"
37-
.to_url_with_base(Some("file:///abs/path/"))
37+
.into_url_with_base(Some("file:///abs/path/"))
3838
.unwrap()
3939
.to_string(),
4040
"file:///abs/path/rel/path"
4141
);
4242
assert_eq!(
4343
"rel/path"
44-
.to_url_with_base(Some("file:///abs/path/popped-file"))
44+
.into_url_with_base(Some("file:///abs/path/popped-file"))
4545
.unwrap()
4646
.to_string(),
4747
"file:///abs/path/rel/path"

‎src/cargo/util/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub use self::errors::{CargoTestError, CliError, ProcessError};
1010
pub use self::flock::{FileLock, Filesystem};
1111
pub use self::graph::Graph;
1212
pub use self::hex::{hash_u64, short_hash, to_hex};
13+
pub use self::into_url::IntoUrl;
14+
pub use self::into_url_with_base::IntoUrlWithBase;
1315
pub use self::lev_distance::lev_distance;
1416
pub use self::lockserver::{LockServer, LockServerClient, LockServerStarted};
1517
pub use self::paths::{bytes2path, dylib_path, join_paths, path2bytes};
@@ -20,8 +22,6 @@ pub use self::read2::read2;
2022
pub use self::rustc::Rustc;
2123
pub use self::sha256::Sha256;
2224
pub use self::to_semver::ToSemver;
23-
pub use self::to_url::ToUrl;
24-
pub use self::to_url_with_base::ToUrlWithBase;
2525
pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo};
2626
pub use self::workspace::{
2727
print_available_benches, print_available_binaries, print_available_examples,
@@ -38,6 +38,8 @@ mod flock;
3838
pub mod graph;
3939
pub mod hex;
4040
pub mod important_paths;
41+
pub mod into_url;
42+
mod into_url_with_base;
4143
pub mod job;
4244
pub mod lev_distance;
4345
mod lockserver;
@@ -51,8 +53,6 @@ mod read2;
5153
pub mod rustc;
5254
mod sha256;
5355
pub mod to_semver;
54-
pub mod to_url;
55-
mod to_url_with_base;
5656
pub mod toml;
5757
mod vcs;
5858
mod workspace;

‎src/cargo/util/toml/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::core::{GitReference, PackageIdSpec, SourceId, WorkspaceConfig, Worksp
2222
use crate::sources::{CRATES_IO_INDEX, CRATES_IO_REGISTRY};
2323
use crate::util::errors::{CargoResult, CargoResultExt, ManifestError};
2424
use crate::util::paths;
25-
use crate::util::{self, validate_package_name, Config, ToUrl};
25+
use crate::util::{self, validate_package_name, Config, IntoUrl};
2626

2727
mod targets;
2828
use self::targets::targets;
@@ -1231,7 +1231,7 @@ impl TomlManifest {
12311231
_ => cx
12321232
.config
12331233
.get_registry_index(url)
1234-
.or_else(|_| url.to_url())
1234+
.or_else(|_| url.into_url())
12351235
.chain_err(|| {
12361236
format!("[patch] entry `{}` should be a URL or registry name", url)
12371237
})?,
@@ -1403,7 +1403,7 @@ impl DetailedTomlDependency {
14031403
.or_else(|| self.tag.clone().map(GitReference::Tag))
14041404
.or_else(|| self.rev.clone().map(GitReference::Rev))
14051405
.unwrap_or_else(|| GitReference::Branch("master".to_string()));
1406-
let loc = git.to_url()?;
1406+
let loc = git.into_url()?;
14071407
SourceId::for_git(&loc, reference)?
14081408
}
14091409
(None, Some(path), _, _) => {
@@ -1426,7 +1426,7 @@ impl DetailedTomlDependency {
14261426
}
14271427
(None, None, Some(registry), None) => SourceId::alt_registry(cx.config, registry)?,
14281428
(None, None, None, Some(registry_index)) => {
1429-
let url = registry_index.to_url()?;
1429+
let url = registry_index.into_url()?;
14301430
SourceId::for_registry(&url)?
14311431
}
14321432
(None, None, None, None) => SourceId::crates_io(cx.config)?,
@@ -1455,7 +1455,7 @@ impl DetailedTomlDependency {
14551455
dep.set_registry_id(registry_id);
14561456
}
14571457
if let Some(registry_index) = &self.registry_index {
1458-
let url = registry_index.to_url()?;
1458+
let url = registry_index.into_url()?;
14591459
let registry_id = SourceId::for_registry(&url)?;
14601460
dep.set_registry_id(registry_id);
14611461
}

‎tests/testsuite/alt_registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::support::publish::validate_alt_upload;
22
use crate::support::registry::{self, Package};
33
use crate::support::{basic_manifest, git, paths, project};
4-
use cargo::util::ToUrl;
4+
use cargo::util::IntoUrl;
55
use std::fs::{self, File};
66
use std::io::Write;
77

@@ -249,7 +249,7 @@ fn registry_incompatible_with_git() {
249249
#[cargo_test]
250250
fn cannot_publish_to_crates_io_with_registry_dependency() {
251251
let fakeio_path = paths::root().join("fake.io");
252-
let fakeio_url = fakeio_path.to_url().unwrap();
252+
let fakeio_url = fakeio_path.into_url().unwrap();
253253
let p = project()
254254
.file(
255255
"Cargo.toml",

0 commit comments

Comments
 (0)
Please sign in to comment.