Skip to content

fix: annotate return type in closure#1106

Merged
MichaReiser merged 1 commit into
salsa-rs:masterfrom
encoredev:fix/fmt-error-inference-ambiguity
Jun 3, 2026
Merged

fix: annotate return type in closure#1106
MichaReiser merged 1 commit into
salsa-rs:masterfrom
encoredev:fix/fmt-error-inference-ambiguity

Conversation

@fredr

@fredr fredr commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

When importing several packages with a From<std::fmt::Error> impl, I get the following error (I'm on rust 1.95.0):

error[E0283]: type annotations needed
   --> /home/fredr/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/salsa-0.26.2/src/active_query.rs:533:17
    |
518 |                 writeln!(fmt, "{indent}at {}:{}", loc.file, loc.line)?;
    |                                                                      - type must be known at this point
...
533 |                 Ok(())
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
    |
    = note: multiple `impl`s satisfying `_: From<std::fmt::Error>` found in the following crates: `log`, `serde_fmt`, `value_bag`:
            - impl From<std::fmt::Error> for serde_fmt::Error;
            - impl From<std::fmt::Error> for tracing::log::kv::error::Error;
            - impl From<std::fmt::Error> for value_bag::error::Error;

This pr fixes that by annotating the types in the closure in the Display implementation for Backtrace.

A simple way to reproduce is to specify these deps in Cargo.toml and then run cargo build:

[dependencies]
salsa = "=0.26.2"
tracing = { version = "0.1", features = ["log"] }
log = { version = "0.4", features = ["kv_serde"] }

@netlify

netlify Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 3e302b9
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6a1feca2ef41cf0008cfe3f5

1 similar comment
@netlify

netlify Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 3e302b9
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6a1feca2ef41cf0008cfe3f5

@MichaReiser MichaReiser added this pull request to the merge queue Jun 3, 2026
Merged via the queue into salsa-rs:master with commit 27c85ed Jun 3, 2026
12 checks passed
This was referenced Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants