Skip to content

Fix clippy::result-large-err in the config crate #290

@TheJanzap

Description

@TheJanzap

I run clippy in my CI configured with --workspace --all-targets -- -D warnings and on a newly created gerust app, Clippy reports that figment::error is too big.

    Checking test-config v0.0.1 (/home/me/git/gerust/test/config)
error: the `Err`-variant returned from this closure is very large
   --> config/src/lib.rs:231:36
    |
231 |           figment::Jail::expect_with(|jail| {
    |  ____________________________________^
232 | |             let config_dir = jail.create_dir("config")?;
233 | |             jail.create_file(
234 | |                 config_dir.join("app.toml"),
...   |
269 | |             Ok(())
270 | |         });
    | |_________^ the `Err`-variant is at least 208 bytes
    |
    = help: try reducing the size of `figment::Error`, for example by boxing large elements or replacing it with `Box<figment::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#result_large_err
    = note: `-D clippy::result-large-err` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::result_large_err)]`

error: the `Err`-variant returned from this closure is very large
   --> config/src/lib.rs:275:36
    |
275 |           figment::Jail::expect_with(|jail| {
    |  ____________________________________^
276 | |             let config_dir = jail.create_dir("config")?;
277 | |             jail.create_file(
278 | |                 config_dir.join("app.toml"),
...   |
313 | |             Ok(())
314 | |         });
    | |_________^ the `Err`-variant is at least 208 bytes
    |
    = help: try reducing the size of `figment::Error`, for example by boxing large elements or replacing it with `Box<figment::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#result_large_err

error: the `Err`-variant returned from this closure is very large
   --> config/src/lib.rs:319:36
    |
319 |           figment::Jail::expect_with(|jail| {
    |  ____________________________________^
320 | |             let config_dir = jail.create_dir("config")?;
321 | |             jail.create_file(
322 | |                 config_dir.join("app.toml"),
...   |
357 | |             Ok(())
358 | |         });
    | |_________^ the `Err`-variant is at least 208 bytes
    |
    = help: try reducing the size of `figment::Error`, for example by boxing large elements or replacing it with `Box<figment::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#result_large_err

error: could not compile `test-config` (lib test) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...

The quick fix is to manually apply #[expect(clippy::result_large_err)], but I would like to see this fixed upstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions