From ca3867b89f4ef58c155d99c83538f20d8681faf5 Mon Sep 17 00:00:00 2001 From: Aleksandr Antonov <109909821+AbstractiveNord@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:06:21 +0000 Subject: [PATCH 1/2] Remove redundant clone --- compiler/rustc_parse/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 1502e5ef5496f..d239be6074c91 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -118,14 +118,14 @@ pub fn new_parser_from_file<'a>( let msg = format!("couldn't read `{}`: {}", path.display(), e); let mut err = psess.dcx().struct_fatal(msg); if let Ok(contents) = std::fs::read(path) - && let Err(utf8err) = String::from_utf8(contents.clone()) + && let Err(utf8err) = std::str::from_utf8(&contents) { utf8_error( sm, &path.display().to_string(), sp, &mut err, - utf8err.utf8_error(), + utf8err, &contents, ); } From c97f2c3e5990d59607017c92c0d57e6f3c7cc32c Mon Sep 17 00:00:00 2001 From: Aleksandr Antonov <109909821+AbstractiveNord@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:24:49 +0000 Subject: [PATCH 2/2] Apply tidy suggest --- compiler/rustc_parse/src/lib.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index d239be6074c91..fa9ec01233b6e 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -120,14 +120,7 @@ pub fn new_parser_from_file<'a>( if let Ok(contents) = std::fs::read(path) && let Err(utf8err) = std::str::from_utf8(&contents) { - utf8_error( - sm, - &path.display().to_string(), - sp, - &mut err, - utf8err, - &contents, - ); + utf8_error(sm, &path.display().to_string(), sp, &mut err, utf8err, &contents); } if let Some(sp) = sp { err.span(sp);