Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only apply inferred bounds if interpolation refers to field #353

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Nov 4, 2024

Fixes #345.

    error[E0599]: `test_no_bound_on_named_fmt::Error<DebugOnly>` doesn't implement `std::fmt::Display`
       --> tests/test_generics.rs:173:22
        |
    168 |     struct Error<T> {
        |     --------------- method `to_string` not found for this struct because it doesn't satisfy `_: Display` or `_: ToString`
    ...
    173 |     assert_eq!(error.to_string(), "...");
        |                      ^^^^^^^^^ `test_no_bound_on_named_fmt::Error<DebugOnly>` cannot be formatted with the default formatter
        |
        = note: the following trait bounds were not satisfied:
                `test_no_bound_on_named_fmt::Error<DebugOnly>: std::fmt::Display`
                which is required by `test_no_bound_on_named_fmt::Error<DebugOnly>: ToString`
        = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
    note: the trait `std::fmt::Display` must be implemented
       --> $RUSTUP_HOME/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:727:1
        |
    727 | pub trait Display {
        | ^^^^^^^^^^^^^^^^^
        = help: items from traits can only be used if the trait is implemented and in scope
        = note: the following trait defines an item `to_string`, perhaps you need to implement it:
                candidate #1: `ToString`
@dtolnay dtolnay merged commit b81fd86 into master Nov 4, 2024
18 checks passed
@dtolnay dtolnay deleted the inferbound branch November 4, 2024 22:22
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.

Inappropriate inferred trait bounds when format var name overlaps with field name
1 participant