|
1 | 1 | #![warn(rust_2018_idioms)] // while we're getting used to 2018
|
2 | 2 | #![allow(clippy::all)]
|
3 | 3 |
|
4 |
| -use cargo::util::config::{ConfigError, ConfigErrorKind, Value}; |
| 4 | +use cargo::util::config::{ConfigError, ConfigErrorKind}; |
5 | 5 | use cargo::util::toml::StringOrVec;
|
6 | 6 | use cargo::util::CliError;
|
7 | 7 | use cargo::util::{self, closest_msg, command_prelude, CargoResult, CliResult, Config};
|
@@ -63,22 +63,26 @@ fn builtin_aliases_execs(cmd: &str) -> Option<&(&str, &str, &str)> {
|
63 | 63 | /// 4. If still no command is found, return `None`.
|
64 | 64 | fn aliased_command(config: &Config, command: &str) -> CargoResult<Option<Vec<String>>> {
|
65 | 65 | let alias_name = format!("alias.{command}");
|
66 |
| - let user_alias = match config.get::<Value<String>>(&alias_name) { |
67 |
| - Ok(record) => Some( |
| 66 | + let user_alias = match config.get_string(&alias_name) { |
| 67 | + Ok(Some(record)) => Some( |
68 | 68 | record
|
69 | 69 | .val
|
70 | 70 | .split_whitespace()
|
71 | 71 | .map(|s| s.to_string())
|
72 | 72 | .collect(),
|
73 | 73 | ),
|
74 |
| - Err(e) => match e.downcast_ref::<ConfigError>().map(|e| e.kind()) { |
75 |
| - // Just report we cannot find anything. |
76 |
| - Some(ConfigErrorKind::MissingKey) => None, |
77 |
| - // Alias might be set as an toml array, fallback and try it. |
78 |
| - Some(ConfigErrorKind::UnexpectedValue) => config.get::<Option<_>>(&alias_name)?, |
79 |
| - // A unrecoverable error, e.g. TOML parsing error. Relay it to the user. |
80 |
| - Some(ConfigErrorKind::Custom) | None => return Err(e), |
81 |
| - }, |
| 74 | + // Just report we cannot find anything. |
| 75 | + Ok(None) => None, |
| 76 | + // Alias might be set as an toml array, fallback and try it. |
| 77 | + Err(e) |
| 78 | + if e.downcast_ref::<ConfigError>() |
| 79 | + .map(|e| matches!(e.kind(), ConfigErrorKind::UnexpectedValue)) |
| 80 | + .unwrap_or_default() => |
| 81 | + { |
| 82 | + config.get::<Option<_>>(&alias_name)? |
| 83 | + } |
| 84 | + // A unrecoverable error, e.g. TOML parsing error. Relay it to the user. |
| 85 | + Err(e) => return Err(e), |
82 | 86 | };
|
83 | 87 |
|
84 | 88 | let result = user_alias.or_else(|| {
|
|
0 commit comments