about summary refs log tree commit diff
path: root/library/test/src/term
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-17 06:37:37 +0100
committerGitHub <noreply@github.com>2025-02-17 06:37:37 +0100
commitc04801dbb971eb401d4dc75b493228e38e6d44f3 (patch)
tree44a656bc419508d10ff4e8eff89d9da8d159525f /library/test/src/term
parent767ec0a8ad548807b30f19619a29727661712276 (diff)
parent9e390b299565c7c9054e3dd9189eb1ab76f9f4dd (diff)
downloadrust-c04801dbb971eb401d4dc75b493228e38e6d44f3.tar.gz
rust-c04801dbb971eb401d4dc75b493228e38e6d44f3.zip
Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDenton
Use `const_error!` when possible

Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
Diffstat (limited to 'library/test/src/term')
-rw-r--r--library/test/src/term/terminfo/mod.rs2
-rw-r--r--library/test/src/term/terminfo/parser/compiled.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/library/test/src/term/terminfo/mod.rs b/library/test/src/term/terminfo/mod.rs
index 974b8afd598..75fa594908d 100644
--- a/library/test/src/term/terminfo/mod.rs
+++ b/library/test/src/term/terminfo/mod.rs
@@ -90,7 +90,7 @@ impl TermInfo {
 
         get_dbpath_for_term(name)
             .ok_or_else(|| {
-                Error::IoError(io::Error::new(io::ErrorKind::NotFound, "terminfo file not found"))
+                Error::IoError(io::const_error!(io::ErrorKind::NotFound, "terminfo file not found"))
             })
             .and_then(|p| TermInfo::from_path(&(*p)))
     }
diff --git a/library/test/src/term/terminfo/parser/compiled.rs b/library/test/src/term/terminfo/parser/compiled.rs
index e687b3be41f..d1dd0f10d86 100644
--- a/library/test/src/term/terminfo/parser/compiled.rs
+++ b/library/test/src/term/terminfo/parser/compiled.rs
@@ -173,7 +173,7 @@ fn read_le_u32(r: &mut dyn io::Read) -> io::Result<u32> {
 fn read_byte(r: &mut dyn io::Read) -> io::Result<u8> {
     match r.bytes().next() {
         Some(s) => s,
-        None => Err(io::Error::new(io::ErrorKind::Other, "end of file")),
+        None => Err(io::const_error!(io::ErrorKind::Other, "end of file")),
     }
 }