summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHirokazu Hata <h.hata.ai.t@gmail.com>2019-02-04 00:17:27 +0900
committerHirokazu Hata <h.hata.ai.t@gmail.com>2019-02-04 00:17:27 +0900
commitc0292f355fd345cc239e948199b7aab3678dfbd3 (patch)
treea71a400b051be21ac2c8d6a7a4b2a258c03060d7
parent27dec6cae3a8132d8a073aad6775425c85095c99 (diff)
downloadrust-installer-c0292f355fd345cc239e948199b7aab3678dfbd3.tar.gz
Transition to 2018 edition
-rw-r--r--Cargo.toml1
-rw-r--r--src/combiner.rs8
-rw-r--r--src/generator.rs6
-rw-r--r--src/lib.rs20
-rw-r--r--src/main.rs12
-rw-r--r--src/remove_dir_all.rs44
-rw-r--r--src/scripter.rs6
-rw-r--r--src/tarballer.rs4
-rw-r--r--src/util.rs4
9 files changed, 53 insertions, 52 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1b2c4b9..8626211 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "installer"
version = "0.0.0"
+edition = "2018"
[[bin]]
doc = false
diff --git a/src/combiner.rs b/src/combiner.rs
index 675ed8f..67779d0 100644
--- a/src/combiner.rs
+++ b/src/combiner.rs
@@ -13,10 +13,10 @@ use std::path::Path;
use flate2::read::GzDecoder;
use tar::Archive;
-use errors::*;
+use crate::errors::*;
use super::Scripter;
use super::Tarballer;
-use util::*;
+use crate::util::*;
actor!{
#[derive(Debug)]
@@ -79,7 +79,7 @@ impl Combiner {
open_file(pkg_dir.join("rust-installer-version"))
.and_then(|mut file| file.read_to_string(&mut version).map_err(Error::from))
.chain_err(|| format!("failed to read version in '{}'", input_tarball))?;
- if version.trim().parse() != Ok(::RUST_INSTALLER_VERSION) {
+ if version.trim().parse() != Ok(crate::RUST_INSTALLER_VERSION) {
bail!("incorrect installer version in {}", input_tarball);
}
@@ -105,7 +105,7 @@ impl Combiner {
// Write the installer version
let version = package_dir.join("rust-installer-version");
- writeln!(create_new_file(version)?, "{}", ::RUST_INSTALLER_VERSION)
+ writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
.chain_err(|| "failed to write new installer version")?;
// Copy the overlay
diff --git a/src/generator.rs b/src/generator.rs
index a20e963..90d647e 100644
--- a/src/generator.rs
+++ b/src/generator.rs
@@ -11,10 +11,10 @@
use std::io::Write;
use std::path::Path;
-use errors::*;
+use crate::errors::*;
use super::Scripter;
use super::Tarballer;
-use util::*;
+use crate::util::*;
actor!{
#[derive(Debug)]
@@ -76,7 +76,7 @@ impl Generator {
// Write the installer version (only used by combine-installers.sh)
let version = package_dir.join("rust-installer-version");
- writeln!(create_new_file(version)?, "{}", ::RUST_INSTALLER_VERSION)
+ writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
.chain_err(|| "failed to write new installer version")?;
// Copy the overlay
diff --git a/src/lib.rs b/src/lib.rs
index ff0495b..3ad2a79 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,11 +10,11 @@
#[macro_use]
extern crate error_chain;
-extern crate flate2;
-extern crate rayon;
-extern crate tar;
-extern crate walkdir;
-extern crate xz2;
+use flate2;
+use rayon;
+
+
+
#[cfg(windows)]
extern crate winapi;
@@ -43,11 +43,11 @@ mod generator;
mod scripter;
mod tarballer;
-pub use errors::{Result, Error, ErrorKind};
-pub use combiner::Combiner;
-pub use generator::Generator;
-pub use scripter::Scripter;
-pub use tarballer::Tarballer;
+pub use crate::errors::{Result, Error, ErrorKind};
+pub use crate::combiner::Combiner;
+pub use crate::generator::Generator;
+pub use crate::scripter::Scripter;
+pub use crate::tarballer::Tarballer;
/// The installer version, output only to be used by combine-installers.sh.
/// (should match `SOURCE_DIRECTORY/rust_installer_version`)
diff --git a/src/main.rs b/src/main.rs
index cabffb8..bc6025c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,9 +2,9 @@
extern crate clap;
#[macro_use]
extern crate error_chain;
-extern crate installer;
+use installer;
-use errors::*;
+use crate::errors::*;
use clap::{App, ArgMatches};
mod errors {
@@ -41,7 +41,7 @@ macro_rules! parse(
}
);
-fn combine(matches: &ArgMatches) -> Result<()> {
+fn combine(matches: &ArgMatches<'_>) -> Result<()> {
let combiner = parse!(matches => installer::Combiner {
"product-name" => product_name,
"package-name" => package_name,
@@ -57,7 +57,7 @@ fn combine(matches: &ArgMatches) -> Result<()> {
combiner.run().chain_err(|| "failed to combine installers")
}
-fn generate(matches: &ArgMatches) -> Result<()> {
+fn generate(matches: &ArgMatches<'_>) -> Result<()> {
let generator = parse!(matches => installer::Generator {
"product-name" => product_name,
"component-name" => component_name,
@@ -75,7 +75,7 @@ fn generate(matches: &ArgMatches) -> Result<()> {
generator.run().chain_err(|| "failed to generate installer")
}
-fn script(matches: &ArgMatches) -> Result<()> {
+fn script(matches: &ArgMatches<'_>) -> Result<()> {
let scripter = parse!(matches => installer::Scripter {
"product-name" => product_name,
"rel-manifest-dir" => rel_manifest_dir,
@@ -87,7 +87,7 @@ fn script(matches: &ArgMatches) -> Result<()> {
scripter.run().chain_err(|| "failed to generate installation script")
}
-fn tarball(matches: &ArgMatches) -> Result<()> {
+fn tarball(matches: &ArgMatches<'_>) -> Result<()> {
let tarballer = parse!(matches => installer::Tarballer {
"input" => input,
"output" => output,
diff --git a/src/remove_dir_all.rs b/src/remove_dir_all.rs
index e06016c..202ac36 100644
--- a/src/remove_dir_all.rs
+++ b/src/remove_dir_all.rs
@@ -103,8 +103,8 @@ mod win {
opts.access_mode(FILE_READ_ATTRIBUTES);
opts.custom_flags(FILE_FLAG_BACKUP_SEMANTICS |
FILE_FLAG_OPEN_REPARSE_POINT);
- let file = try!(File::open(path, &opts));
- (try!(get_path(&file)), try!(file.file_attr()))
+ let file = r#try!(File::open(path, &opts));
+ (r#try!(get_path(&file)), r#try!(file.file_attr()))
};
let mut ctx = RmdirContext {
@@ -131,7 +131,7 @@ mod win {
fn readdir(p: &Path) -> io::Result<ReadDir> {
let root = p.to_path_buf();
let star = p.join("*");
- let path = try!(to_u16s(&star));
+ let path = r#try!(to_u16s(&star));
unsafe {
let mut wfd = mem::zeroed();
@@ -157,14 +157,14 @@ mod win {
fn remove_dir_all_recursive(path: &Path, ctx: &mut RmdirContext)
-> io::Result<()> {
let dir_readonly = ctx.readonly;
- for child in try!(readdir(path)) {
- let child = try!(child);
- let child_type = try!(child.file_type());
- ctx.readonly = try!(child.metadata()).perm().readonly();
+ for child in r#try!(readdir(path)) {
+ let child = r#try!(child);
+ let child_type = r#try!(child.file_type());
+ ctx.readonly = r#try!(child.metadata()).perm().readonly();
if child_type.is_dir() {
- try!(remove_dir_all_recursive(&child.path(), ctx));
+ r#try!(remove_dir_all_recursive(&child.path(), ctx));
} else {
- try!(remove_item(&child.path().as_ref(), ctx));
+ r#try!(remove_item(&child.path().as_ref(), ctx));
}
}
ctx.readonly = dir_readonly;
@@ -178,11 +178,11 @@ mod win {
opts.custom_flags(FILE_FLAG_BACKUP_SEMANTICS | // delete directory
FILE_FLAG_OPEN_REPARSE_POINT | // delete symlink
FILE_FLAG_DELETE_ON_CLOSE);
- let file = try!(File::open(path, &opts));
+ let file = r#try!(File::open(path, &opts));
move_item(&file, ctx)
} else {
// remove read-only permision
- try!(set_perm(&path, FilePermissions::new()));
+ r#try!(set_perm(&path, FilePermissions::new()));
// move and delete file, similar to !readonly.
// only the access mode is different.
let mut opts = OpenOptions::new();
@@ -190,8 +190,8 @@ mod win {
opts.custom_flags(FILE_FLAG_BACKUP_SEMANTICS |
FILE_FLAG_OPEN_REPARSE_POINT |
FILE_FLAG_DELETE_ON_CLOSE);
- let file = try!(File::open(path, &opts));
- try!(move_item(&file, ctx));
+ let file = r#try!(File::open(path, &opts));
+ r#try!(move_item(&file, ctx));
// restore read-only flag just in case there are other hard links
let mut perm = FilePermissions::new();
perm.set_readonly(true);
@@ -445,13 +445,13 @@ mod win {
impl File {
fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
- let path = try!(to_u16s(path));
+ let path = r#try!(to_u16s(path));
let handle = unsafe {
CreateFileW(path.as_ptr(),
- try!(opts.get_access_mode()),
+ r#try!(opts.get_access_mode()),
opts.share_mode,
opts.security_attributes as *mut _,
- try!(opts.get_creation_mode()),
+ r#try!(opts.get_creation_mode()),
opts.get_flags_and_attributes(),
ptr::null_mut())
};
@@ -465,7 +465,7 @@ mod win {
fn file_attr(&self) -> io::Result<FileAttr> {
unsafe {
let mut info: BY_HANDLE_FILE_INFORMATION = mem::zeroed();
- try!(cvt(GetFileInformationByHandle(self.handle.raw(),
+ r#try!(cvt(GetFileInformationByHandle(self.handle.raw(),
&mut info)));
let mut attr = FileAttr {
attributes: info.dwFileAttributes,
@@ -498,7 +498,7 @@ mod win {
FileAttributes: attr,
};
let size = mem::size_of_val(&info);
- try!(cvt(unsafe {
+ r#try!(cvt(unsafe {
SetFileInformationByHandle(self.handle.raw(),
FileBasicInfo,
&mut info as *mut _ as *mut _,
@@ -531,7 +531,7 @@ mod win {
(*info).ReplaceIfExists = if replace { -1 } else { FALSE };
(*info).RootDirectory = ptr::null_mut();
(*info).FileNameLength = (size - STRUCT_SIZE) as DWORD;
- try!(cvt(SetFileInformationByHandle(self.handle().raw(),
+ r#try!(cvt(SetFileInformationByHandle(self.handle().raw(),
FileRenameInfo,
data.as_mut_ptr() as *mut _ as *mut _,
size as DWORD)));
@@ -539,7 +539,7 @@ mod win {
}
}
fn set_perm(&self, perm: FilePermissions) -> io::Result<()> {
- let attr = try!(self.file_attr()).attributes;
+ let attr = r#try!(self.file_attr()).attributes;
if perm.readonly == (attr & FILE_ATTRIBUTE_READONLY != 0) {
Ok(())
} else if perm.readonly {
@@ -556,7 +556,7 @@ mod win {
-> io::Result<(DWORD, &'a REPARSE_DATA_BUFFER)> {
unsafe {
let mut bytes = 0;
- try!(cvt({
+ r#try!(cvt({
DeviceIoControl(self.handle.raw(),
FSCTL_GET_REPARSE_POINT,
ptr::null_mut(),
@@ -792,7 +792,7 @@ mod win {
let mut opts = OpenOptions::new();
opts.access_mode(FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES);
opts.custom_flags(FILE_FLAG_BACKUP_SEMANTICS);
- let file = try!(File::open(path, &opts));
+ let file = r#try!(File::open(path, &opts));
file.set_perm(perm)
}
diff --git a/src/scripter.rs b/src/scripter.rs
index 66d7ba5..3b11efa 100644
--- a/src/scripter.rs
+++ b/src/scripter.rs
@@ -10,8 +10,8 @@
use std::io::Write;
-use errors::*;
-use util::*;
+use crate::errors::*;
+use crate::util::*;
const TEMPLATE: &'static str = include_str!("../install-template.sh");
@@ -52,7 +52,7 @@ impl Scripter {
.replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir)
.replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message))
.replace("%%TEMPLATE_LEGACY_MANIFEST_DIRS%%", &sh_quote(&self.legacy_manifest_dirs))
- .replace("%%TEMPLATE_RUST_INSTALLER_VERSION%%", &sh_quote(&::RUST_INSTALLER_VERSION));
+ .replace("%%TEMPLATE_RUST_INSTALLER_VERSION%%", &sh_quote(&crate::RUST_INSTALLER_VERSION));
create_new_executable(&self.output_script)?
.write_all(script.as_ref())
diff --git a/src/tarballer.rs b/src/tarballer.rs
index caee556..03c4729 100644
--- a/src/tarballer.rs
+++ b/src/tarballer.rs
@@ -19,8 +19,8 @@ use tar::{Builder, Header};
use walkdir::WalkDir;
use xz2::write::XzEncoder;
-use errors::*;
-use util::*;
+use crate::errors::*;
+use crate::util::*;
actor!{
#[derive(Debug)]
diff --git a/src/util.rs b/src/util.rs
index a5ae36c..1678973 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -23,7 +23,7 @@ use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
-use errors::*;
+use crate::errors::*;
/// Convert a `&Path` to a UTF-8 `&str`
pub fn path_to_str(path: &Path) -> Result<&str> {
@@ -80,7 +80,7 @@ pub fn open_file<P: AsRef<Path>>(path: P) -> Result<fs::File> {
/// Wrap `remove_dir_all` with a nicer error message
pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> Result<()> {
- ::remove_dir_all::remove_dir_all(path.as_ref())
+ crate::remove_dir_all::remove_dir_all(path.as_ref())
.chain_err(|| format!("failed to remove dir '{}'", path.as_ref().display()))
}