Skip to content

Commit ac9209d

Browse files
djcrami3l
authored andcommitted
Upgrade thiserror to 2
1 parent 92f84fd commit ac9209d

File tree

6 files changed

+44
-24
lines changed

6 files changed

+44
-24
lines changed

Cargo.lock

+29-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ platforms = "3.4"
151151
proptest = "1.1.0"
152152
tempfile = "3.8"
153153
termcolor = "1.2"
154-
thiserror = "1.0"
154+
thiserror = "2"
155155
tokio = { version = "1.26.0", default-features = false, features = ["macros", "rt-multi-thread"] }
156156
tokio-retry = { version = "0.3.0" }
157157
tokio-stream = { version = "0.1.14" }

src/cli/rustup_mode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ async fn update(
858858
d.update_extra(&components, &targets, profile, force, allow_downgrade)
859859
.await?
860860
}
861-
Err(RustupError::ToolchainNotInstalled(_)) => {
861+
Err(RustupError::ToolchainNotInstalled { .. }) => {
862862
DistributableToolchain::install(
863863
cfg,
864864
&desc,
@@ -1341,7 +1341,7 @@ async fn override_add(
13411341
let toolchain_name = toolchain.resolve(&cfg.get_default_host_triple()?)?;
13421342
match Toolchain::new(cfg, (&toolchain_name).into()) {
13431343
Ok(_) => {}
1344-
Err(e @ RustupError::ToolchainNotInstalled(_)) => match &toolchain_name {
1344+
Err(e @ RustupError::ToolchainNotInstalled { .. }) => match &toolchain_name {
13451345
ToolchainName::Custom(_) => Err(e)?,
13461346
ToolchainName::Official(desc) => {
13471347
let status =

src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl<'a> Cfg<'a> {
646646
// XXX: this awkwardness deals with settings file being locked already
647647
let toolchain_name = toolchain_name.resolve(&default_host_triple)?;
648648
match Toolchain::new(self, (&toolchain_name).into()) {
649-
Err(RustupError::ToolchainNotInstalled(_)) => {
649+
Err(RustupError::ToolchainNotInstalled { .. }) => {
650650
if matches!(toolchain_name, ToolchainName::Custom(_)) {
651651
bail!(
652652
"custom toolchain specified in override file '{}' is not installed",
@@ -815,7 +815,7 @@ impl<'a> Cfg<'a> {
815815
None => self.get_profile()?,
816816
};
817817
let (status, toolchain) = match DistributableToolchain::new(self, toolchain.clone()) {
818-
Err(RustupError::ToolchainNotInstalled(_)) => {
818+
Err(RustupError::ToolchainNotInstalled { .. }) => {
819819
DistributableToolchain::install(
820820
self,
821821
toolchain,

src/errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ pub enum RustupError {
9696
#[error("toolchain '{0}' is not installable")]
9797
ToolchainNotInstallable(String),
9898
#[error(
99-
"toolchain '{0}' is not installed{}",
100-
if let ToolchainName::Official(t) = .0 {
99+
"toolchain '{name}' is not installed{}",
100+
if let ToolchainName::Official(t) = name {
101101
format!("\nhelp: run `rustup toolchain install {t}` to install it")
102102
} else {
103103
String::new()
104104
},
105105
)]
106-
ToolchainNotInstalled(ToolchainName),
106+
ToolchainNotInstalled { name: ToolchainName },
107107
#[error("path '{0}' not found")]
108108
PathToolchainNotInstalled(PathBasedToolchainName),
109109
#[error(
110-
"rustup could not choose a version of {0} to run, because one wasn't specified explicitly, and no default is configured.\n{}",
111-
"help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain."
110+
"rustup could not choose a version of {0} to run, because one wasn't specified explicitly, and no default is configured.\n\
111+
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain."
112112
)]
113113
ToolchainNotSelected(String),
114114
#[error("toolchain '{}' does not contain component {}{}{}", .desc, .component, suggest_message(.suggestion), if .component.contains("rust-std") {

src/toolchain.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ impl<'a> Toolchain<'a> {
5050
) -> anyhow::Result<Toolchain<'a>> {
5151
match Self::new(cfg, name) {
5252
Ok(tc) => Ok(tc),
53-
Err(RustupError::ToolchainNotInstalled(ToolchainName::Official(desc)))
54-
if install_if_missing =>
55-
{
53+
Err(RustupError::ToolchainNotInstalled {
54+
name: ToolchainName::Official(desc),
55+
}) if install_if_missing => {
5656
Ok(
5757
DistributableToolchain::install(cfg, &desc, &[], &[], cfg.get_profile()?, true)
5858
.await?
@@ -72,7 +72,7 @@ impl<'a> Toolchain<'a> {
7272
reason: &ActiveReason,
7373
) -> anyhow::Result<Self> {
7474
match Self::new(cfg, name.clone()) {
75-
Err(RustupError::ToolchainNotInstalled(_)) => (),
75+
Err(RustupError::ToolchainNotInstalled { .. }) => (),
7676
result => {
7777
return Ok(result?);
7878
}
@@ -106,7 +106,7 @@ impl<'a> Toolchain<'a> {
106106
let path = cfg.toolchain_path(&name);
107107
if !Toolchain::exists(cfg, &name)? {
108108
return Err(match name {
109-
LocalToolchainName::Named(name) => RustupError::ToolchainNotInstalled(name),
109+
LocalToolchainName::Named(name) => RustupError::ToolchainNotInstalled { name },
110110
LocalToolchainName::Path(name) => RustupError::PathToolchainNotInstalled(name),
111111
});
112112
}

0 commit comments

Comments
 (0)