]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_expand/src/module.rs
Rollup merge of #84871 - richkadel:no-coverage-unstable-only, r=nagisa
[rust.git] / compiler / rustc_expand / src / module.rs
index c5ce0baaa8f6a13d33eeca78cc2cb02252ccf5af..4d777049f0d627614d9d322fa7b47d0f175c7753 100644 (file)
@@ -36,8 +36,8 @@ pub struct ModulePathSuccess {
 pub enum ModError<'a> {
     CircularInclusion(Vec<PathBuf>),
     ModInBlock(Option<Ident>),
-    FileNotFound(Ident, PathBuf),
-    MultipleCandidates(Ident, String, String),
+    FileNotFound(Ident, PathBuf, PathBuf),
+    MultipleCandidates(Ident, PathBuf, PathBuf),
     ParserError(DiagnosticBuilder<'a>),
 }
 
@@ -219,10 +219,8 @@ pub fn default_submod_path<'a>(
             file_path: secondary_path,
             dir_ownership: DirOwnership::Owned { relative: None },
         }),
-        (false, false) => Err(ModError::FileNotFound(ident, default_path)),
-        (true, true) => {
-            Err(ModError::MultipleCandidates(ident, default_path_str, secondary_path_str))
-        }
+        (false, false) => Err(ModError::FileNotFound(ident, default_path, secondary_path)),
+        (true, true) => Err(ModError::MultipleCandidates(ident, default_path, secondary_path)),
     }
 }
 
@@ -249,7 +247,7 @@ fn report(self, sess: &Session, span: Span) {
                 }
                 err
             }
-            ModError::FileNotFound(ident, default_path) => {
+            ModError::FileNotFound(ident, default_path, secondary_path) => {
                 let mut err = struct_span_err!(
                     diag,
                     span,
@@ -258,21 +256,22 @@ fn report(self, sess: &Session, span: Span) {
                     ident,
                 );
                 err.help(&format!(
-                    "to create the module `{}`, create file \"{}\"",
+                    "to create the module `{}`, create file \"{}\" or \"{}\"",
                     ident,
                     default_path.display(),
+                    secondary_path.display(),
                 ));
                 err
             }
-            ModError::MultipleCandidates(ident, default_path_short, secondary_path_short) => {
+            ModError::MultipleCandidates(ident, default_path, secondary_path) => {
                 let mut err = struct_span_err!(
                     diag,
                     span,
                     E0761,
-                    "file for module `{}` found at both {} and {}",
+                    "file for module `{}` found at both \"{}\" and \"{}\"",
                     ident,
-                    default_path_short,
-                    secondary_path_short,
+                    default_path.display(),
+                    secondary_path.display(),
                 );
                 err.help("delete or rename one of them to remove the ambiguity");
                 err