Skip to content

Commit cc02c16

Browse files
build(deps): bump error-stack from 0.5.0 to 0.6.0 (#355)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent dbb92ad commit cc02c16

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cargo-config2 = "0.1.39"
1818
cargo_metadata = "0.23.1"
1919
clap = { version = "4.5.53", features = ["derive"] }
2020
clap-cargo = { version = "0.18.3", features = ["cargo_metadata"] }
21-
error-stack = "0.5.0"
21+
error-stack = "0.6.0"
2222
serde = { version = "1.0.217", features = ["derive"] }
2323
serde_json = "1.0.145"
2424

@@ -38,7 +38,7 @@ checked_conversions = "warn"
3838
dbg_macro = "warn"
3939
debug_assert_with_mut_call = "warn"
4040
doc_markdown = "warn"
41-
empty_enum = "warn"
41+
empty_enums = "warn"
4242
enum_glob_use = "warn"
4343
exit = "warn"
4444
expl_impl_clone_on_copy = "warn"
@@ -88,7 +88,6 @@ single_match_else = "warn"
8888
string_add_assign = "warn"
8989
string_add = "warn"
9090
string_lit_as_bytes = "warn"
91-
string_to_string = "warn"
9291
todo = "warn"
9392
trait_duplication_in_bounds = "warn"
9493
unimplemented = "warn"

src/main.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::borrow::Borrow;
2+
use std::error::Error;
23
use std::ffi::OsString;
34
use std::path::Path;
45
use std::process::{Command, ExitCode};
56
use std::{env, fmt, path};
67

78
use anstream::eprintln;
8-
use error_stack::{Context, Result, ResultExt, ensure, report};
9+
use error_stack::{IntoReport, Report, ResultExt, ensure};
910

1011
use crate::cli::Cli;
1112
use crate::color::{note, warn};
@@ -27,28 +28,28 @@ impl fmt::Display for RuntimeError {
2728
}
2829
}
2930

30-
impl Context for RuntimeError {}
31+
impl Error for RuntimeError {}
3132

32-
fn main() -> Result<ExitCode, RuntimeError> {
33+
fn main() -> Result<ExitCode, Report<RuntimeError>> {
3334
setup();
3435

3536
let Cli { cargo_cmd, ft_args, cargo_args } = Cli::parse();
3637
let context = RuntimeError { cargo_cmd };
3738

3839
let config = cargo_config2::Config::load()
3940
.change_context(context)
40-
.attach_printable("could not load cargo configuration")?;
41+
.attach("could not load cargo configuration")?;
4142

4243
let mut targets = config
4344
.build_target_for_cli(&ft_args.target)
4445
.change_context(context)
45-
.attach_printable("could not select target triple")?;
46+
.attach("could not select target triple")?;
4647

4748
let target = targets.pop();
4849
let build_target = target.as_deref().unwrap_or(env!("TARGET_PLATFORM"));
4950
ensure!(
5051
targets.is_empty(),
51-
report!(context).attach_printable("multi-target build is not supported")
52+
context.into_report().attach("multi-target build is not supported")
5253
);
5354

5455
let manifest_options = [
@@ -68,7 +69,7 @@ fn main() -> Result<ExitCode, RuntimeError> {
6869
.verbose(true)
6970
.exec()
7071
.change_context(context)
71-
.attach_printable_lazy(|| {
72+
.attach_with(|| {
7273
format!(
7374
"could not run initial cargo metadata on {}",
7475
manifest_path_display(ft_args.manifest.manifest_path.as_deref())
@@ -89,7 +90,7 @@ fn main() -> Result<ExitCode, RuntimeError> {
8990

9091
ensure!(
9192
!selected_supported.is_empty(),
92-
report!(context).attach_printable(format!(
93+
context.into_report().attach(format!(
9394
"all selected packages {:?} are unsupported on {build_target}",
9495
package_names(&selected)
9596
))
@@ -99,7 +100,7 @@ fn main() -> Result<ExitCode, RuntimeError> {
99100

100101
ensure!(
101102
!selected_is_explicit || selected_unsupported.is_empty(),
102-
report!(context).attach_printable(format!(
103+
context.into_report().attach(format!(
103104
"selected packages {:?} are unsupported on {build_target}",
104105
package_names(&selected_unsupported)
105106
))
@@ -126,7 +127,7 @@ fn main() -> Result<ExitCode, RuntimeError> {
126127
let status = command
127128
.status()
128129
.change_context(context)
129-
.attach_printable_lazy(|| format!("could not run {command:?}"))?;
130+
.attach_with(|| format!("could not run {command:?}"))?;
130131

131132
Ok(status.code().map_or(ExitCode::FAILURE, |code| ExitCode::from(code as u8)))
132133
}

src/package.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use std::error::Error;
12
use std::fmt;
23

34
use anstream::eprintln;
45
use cargo_metadata::{Metadata, Package};
5-
use error_stack::{Context, Result, ResultExt};
6+
use error_stack::{Report, ResultExt};
67

78
use crate::color::warn;
89
use crate::package::metadata::{FtWorkspaceMetadata, ParseMetadataError};
@@ -28,7 +29,7 @@ impl fmt::Display for PackageMetadataError {
2829
}
2930
}
3031

31-
impl Context for PackageMetadataError {}
32+
impl Error for PackageMetadataError {}
3233

3334
#[derive(Debug, Clone, Eq, PartialEq)]
3435
pub struct FtPackage<'p> {
@@ -40,7 +41,7 @@ impl<'p> FtPackage<'p> {
4041
pub fn parse_metadata(
4142
metadata: &Metadata,
4243
packages: &[&'p Package],
43-
) -> Result<Vec<Self>, PackageMetadataError> {
44+
) -> Result<Vec<Self>, Report<PackageMetadataError>> {
4445
let context = PackageMetadataError::from;
4546

4647
let workspace_metadata = FtWorkspaceMetadata::parse(metadata.workspace_metadata.clone())

src/package/metadata.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
use std::error::Error;
12
use std::fmt;
23

3-
use error_stack::{Context, ResultExt, report};
4+
use error_stack::{IntoReport, Report, ResultExt};
45
use serde::de::{MapAccess, SeqAccess};
56
use serde::{Deserialize, Deserializer, de};
67

78
#[cfg(test)]
89
mod tests;
910

10-
type MetadataResult<T> = error_stack::Result<T, ParseMetadataError>;
11+
type MetadataResult<T> = Result<T, Report<ParseMetadataError>>;
1112

1213
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
1314
pub enum ParseMetadataError {
@@ -24,7 +25,7 @@ impl fmt::Display for ParseMetadataError {
2425
}
2526
}
2627

27-
impl Context for ParseMetadataError {}
28+
impl Error for ParseMetadataError {}
2829

2930
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
3031
pub struct FtWorkspaceMetadata {
@@ -56,17 +57,17 @@ impl FtMetadata {
5657
serde_json::from_value::<Option<JsonPackageMetadata>>(package_metadata)
5758
.change_context(ParseMetadataError::Invalid)?
5859
.ok_or(ParseMetadataError::Missing)
59-
.attach_printable("no `package.metadata` table")?;
60+
.attach("no `package.metadata` table")?;
6061

6162
let ft = package_metadata
6263
.ft
6364
.ok_or(ParseMetadataError::Missing)
64-
.attach_printable("no `package.metadata.ft` table")?;
65+
.attach("no `package.metadata.ft` table")?;
6566

6667
let targets = ft
6768
.targets
6869
.ok_or(ParseMetadataError::Missing)
69-
.attach_printable("no `package.metadata.ft.targets` array")?
70+
.attach("no `package.metadata.ft.targets` array")?
7071
.resolve("targets", || workspace_metadata.fields.targets())?;
7172

7273
Ok(Self { targets })
@@ -95,8 +96,8 @@ impl InheritableFields {
9596
self.targets
9697
.as_ref()
9798
.cloned()
98-
.ok_or(report!(ParseMetadataError::Invalid))
99-
.attach_printable("`workspace.metadata.ft.targets` was not defined")
99+
.ok_or(ParseMetadataError::Invalid.into_report())
100+
.attach("`workspace.metadata.ft.targets` was not defined")
100101
}
101102
}
102103

@@ -169,7 +170,7 @@ impl<T> MaybeWorkspace<T> {
169170
) -> MetadataResult<T> {
170171
match self {
171172
Self::Defined(value) => Ok(value),
172-
Self::Workspace => get_workspace_inheritable().attach_printable_lazy(|| format!("error inheriting `{label}` from workspace root manifest's `workspace.metadata.ft.{label}`")),
173+
Self::Workspace => get_workspace_inheritable().attach_with(|| format!("error inheriting `{label}` from workspace root manifest's `workspace.metadata.ft.{label}`")),
173174
}
174175
}
175176
}

0 commit comments

Comments
 (0)