Simplify fmt::Display for ModuleResolutionError (#5550)

This commit is contained in:
扩散性百万甜面包 2020-05-17 23:33:44 +08:00 committed by GitHub
parent 4d3bcd807d
commit 2c71780cfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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!(""),
}
),
}
}
}