Use dyn Trait to fix build on Rust beta
diff mbox series

Message ID 20190710013029.8104-1-ajd@linux.ibm.com
State Accepted
Headers show
Series
  • Use dyn Trait to fix build on Rust beta
Related show

Commit Message

Andrew Donnellan July 10, 2019, 1:30 a.m. UTC
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
---
 src/ci.rs       |  6 +++---
 src/jenkins.rs  | 10 +++++-----
 src/main.rs     |  4 ++--
 src/settings.rs |  4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

Comments

Andrew Donnellan July 10, 2019, 7:47 a.m. UTC | #1
On 10/7/19 11:30 am, Andrew Donnellan wrote:
> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>

Applied to master: 01e1c7010fb476fd92c5ded90aa2e08cd247e826

Patch
diff mbox series

diff --git a/src/ci.rs b/src/ci.rs
index 82af1594f2c7..c455721aec36 100644
--- a/src/ci.rs
+++ b/src/ci.rs
@@ -28,10 +28,10 @@  pub enum BuildStatus {
 pub trait CIBackend {
     fn start_test(&self, job_name: &str, params: Vec<(&str, &str)>)
         -> Result<String, &'static str>;
-    fn get_build_handle(&self, build_queue_entry: &str) -> Result<String, Box<Error>>;
-    fn get_build_result(&self, build_handle: &str) -> Result<TestState, Box<Error>>;
+    fn get_build_handle(&self, build_queue_entry: &str) -> Result<String, Box<dyn Error>>;
+    fn get_build_result(&self, build_handle: &str) -> Result<TestState, Box<dyn Error>>;
     fn get_results_url(&self, build_handle: &str, job: &BTreeMap<String, String>) -> String;
     fn get_description(&self, build_handle: &str, job: &BTreeMap<String, String>)
         -> Option<String>;
-    fn wait_build(&self, build_handle: &str) -> Result<BuildStatus, Box<Error>>;
+    fn wait_build(&self, build_handle: &str) -> Result<BuildStatus, Box<dyn Error>>;
 }
diff --git a/src/jenkins.rs b/src/jenkins.rs
index b367e0db3a7a..d500fafb8afa 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -74,7 +74,7 @@  impl CIBackend for JenkinsBackend {
         }
     }
 
-    fn get_build_handle(&self, build_queue_entry: &str) -> Result<String, Box<Error>> {
+    fn get_build_handle(&self, build_queue_entry: &str) -> Result<String, Box<dyn Error>> {
         loop {
             let entry = self.get_api_json_object(build_queue_entry)?;
             match entry.get("executable") {
@@ -95,7 +95,7 @@  impl CIBackend for JenkinsBackend {
         }
     }
 
-    fn get_build_result(&self, build_handle: &str) -> Result<TestState, Box<Error>> {
+    fn get_build_result(&self, build_handle: &str) -> Result<TestState, Box<dyn Error>> {
         match self
             .get_api_json_object(build_handle)?
             .get("result")
@@ -157,7 +157,7 @@  impl CIBackend for JenkinsBackend {
         }
     }
 
-    fn wait_build(&self, build_handle: &str) -> Result<BuildStatus, Box<Error>> {
+    fn wait_build(&self, build_handle: &str) -> Result<BuildStatus, Box<dyn Error>> {
         // TODO: Implement a timeout?
         while self.get_build_status(build_handle)? != BuildStatus::Done {
             sleep(Duration::from_millis(JENKINS_POLLING_INTERVAL));
@@ -193,7 +193,7 @@  impl JenkinsBackend {
         self.reqwest_client.post(url).headers(self.headers()).send()
     }
 
-    fn get_api_json_object(&self, base_url: &str) -> Result<Value, Box<Error>> {
+    fn get_api_json_object(&self, base_url: &str) -> Result<Value, Box<dyn Error>> {
         let url = format!("{}api/json", base_url);
         let mut result_str = String::new();
         loop {
@@ -220,7 +220,7 @@  impl JenkinsBackend {
             .map_err(|e| format!("Couldn't parse JSON from Jenkins: {}", e).into())
     }
 
-    pub fn get_build_status(&self, build_handle: &str) -> Result<BuildStatus, Box<Error>> {
+    pub fn get_build_status(&self, build_handle: &str) -> Result<BuildStatus, Box<dyn Error>> {
         match self.get_api_json_object(build_handle)?["building"].as_bool() {
             Some(true) => Ok(BuildStatus::Running),
             Some(false) => Ok(BuildStatus::Done),
diff --git a/src/main.rs b/src/main.rs
index ea09b07969ba..af5459a12cd4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -103,7 +103,7 @@  struct Args {
 }
 
 fn run_test(
-    backend: &CIBackend,
+    backend: &dyn CIBackend,
     project: &Project,
     tag: &str,
     branch_name: &str,
@@ -329,7 +329,7 @@  fn test_patch(
     feature = "cargo-clippy",
     allow(clippy::cyclomatic_complexity, clippy::cognitive_complexity)
 )]
-fn run() -> Result<(), Box<Error>> {
+fn run() -> Result<(), Box<dyn Error>> {
     // TODO: env_logger probably has a neater way to set defaults
     let mut log_builder = Builder::new();
     // By default, log at the "info" level for every module
diff --git a/src/settings.rs b/src/settings.rs
index 40ac67cccf58..e20d2e856834 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -197,7 +197,7 @@  pub struct Config {
     pub projects: BTreeMap<String, Project>,
 }
 
-pub fn parse(path: &str) -> Result<Config, Box<Error>> {
+pub fn parse(path: &str) -> Result<Config, Box<dyn Error>> {
     let mut toml_config = String::new();
 
     File::open(&path)
@@ -224,7 +224,7 @@  mod test {
     }
 
     #[test]
-    fn parse_example_openpower() -> Result<(), Box<Error>> {
+    fn parse_example_openpower() -> Result<(), Box<dyn Error>> {
         parse("examples/openpower.toml").map(|_| ())
     }