summaryrefslogtreecommitdiff
path: root/core/module_specifier.rs
diff options
context:
space:
mode:
author扩散性百万甜面包 <himself65@outlook.com>2020-05-17 23:33:44 +0800
committerGitHub <noreply@github.com>2020-05-17 11:33:44 -0400
commit2c71780cfbba0b2de1682196114c80be641187b0 (patch)
treeb63f07d26cddd823add3c80a6c99ff0949a8e770 /core/module_specifier.rs
parent4d3bcd807df3e60dc30b891d6efe896711f8cad3 (diff)
Simplify fmt::Display for ModuleResolutionError (#5550)
Diffstat (limited to 'core/module_specifier.rs')
-rw-r--r--core/module_specifier.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/core/module_specifier.rs b/core/module_specifier.rs
index 2457262c1..9cf449302 100644
--- a/core/module_specifier.rs
+++ b/core/module_specifier.rs
@@ -32,19 +32,15 @@ impl fmt::Display for ModuleResolutionError {
write!(f, "invalid base URL for relative import: {}", err)
}
InvalidPath(ref path) => write!(f, "invalid module path: {:?}", path),
- ImportPrefixMissing(ref specifier, ref maybe_referrer) => {
- let msg = format!(
- "relative import path \"{}\" not prefixed with / or ./ or ../",
- specifier
- );
- let msg = if let Some(referrer) = maybe_referrer {
- format!("{} Imported from \"{}\"", msg, referrer)
- } else {
- msg
- };
-
- write!(f, "{}", msg)
- }
+ ImportPrefixMissing(ref specifier, ref maybe_referrer) => write!(
+ f,
+ "relative import path \"{}\" not prefixed with / or ./ or ../{}",
+ specifier,
+ match maybe_referrer {
+ Some(referrer) => format!(" Imported from \"{}\"", referrer),
+ None => format!(""),
+ }
+ ),
}
}
}