From 686077e0f3a7f98529bd0693f960c29f720d977e Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 26 Jan 2024 21:14:47 +0100 Subject: [PATCH] Fix non local definition in rustfmt --- src/tools/rustfmt/src/source_file.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tools/rustfmt/src/source_file.rs b/src/tools/rustfmt/src/source_file.rs index 958f9b0154f70..0a77b8f2fb953 100644 --- a/src/tools/rustfmt/src/source_file.rs +++ b/src/tools/rustfmt/src/source_file.rs @@ -16,6 +16,17 @@ use crate::formatting::FileRecord; use rustc_data_structures::sync::Lrc; +impl From<&FileName> for rustc_span::FileName { + fn from(filename: &FileName) -> rustc_span::FileName { + match filename { + FileName::Real(path) => { + rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(path.to_owned())) + } + FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()), + } + } +} + // Append a newline to the end of each file. pub(crate) fn append_newline(s: &mut String) { s.push('\n'); @@ -66,17 +77,6 @@ where } } - impl From<&FileName> for rustc_span::FileName { - fn from(filename: &FileName) -> rustc_span::FileName { - match filename { - FileName::Real(path) => { - rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(path.to_owned())) - } - FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()), - } - } - } - // SourceFile's in the SourceMap will always have Unix-style line endings // See: https://github.com/rust-lang/rustfmt/issues/3850 // So if the user has explicitly overridden the rustfmt `newline_style`