From c9b27b484edbf6fd1a100c7f07013c0d396b3d2e Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 28 Apr 2020 17:54:41 -0700 Subject: [PATCH] filecheck: Use `std::fs::read_to_string` instead of hand-rolled copy (#1627) --- cranelift/filetests/src/runone.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cranelift/filetests/src/runone.rs b/cranelift/filetests/src/runone.rs index 8d1c36dff8..531179164d 100644 --- a/cranelift/filetests/src/runone.rs +++ b/cranelift/filetests/src/runone.rs @@ -12,18 +12,9 @@ use cranelift_reader::{parse_test, IsaSpec, ParseOptions}; use log::info; use std::borrow::Cow; use std::fs; -use std::io::{self, Read}; use std::path::Path; use std::time; -/// Read an entire file into a string. -fn read_to_string>(path: P) -> io::Result { - let mut file = fs::File::open(path)?; - let mut buffer = String::new(); - file.read_to_string(&mut buffer)?; - Ok(buffer) -} - /// Load `path` and run the test in it. /// /// If running this test causes a panic, it will propagate as normal. @@ -31,7 +22,7 @@ pub fn run(path: &Path, passes: Option<&[String]>, target: Option<&str>) -> Test let _tt = timing::process_file(); info!("---\nFile: {}", path.to_string_lossy()); let started = time::Instant::now(); - let buffer = read_to_string(path).map_err(|e| e.to_string())?; + let buffer = fs::read_to_string(path).map_err(|e| e.to_string())?; let options = ParseOptions { target, passes,