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

unnecessary_literal_bound triggered on trait implementation #14085

Open
mladedav opened this issue Jan 27, 2025 · 0 comments
Open

unnecessary_literal_bound triggered on trait implementation #14085

mladedav opened this issue Jan 27, 2025 · 0 comments
Labels
A-lint Area: New lints I-false-positive Issue: The lint was triggered on code it shouldn't have L-pedantic Lint: Belongs in the pedantic lint group

Comments

@mladedav
Copy link
Contributor

Description

The lint triggers on trait implementations where it forces users to refine the return type instead of following whatever is present in the trait definition.

#![allow(dead_code)]
#![warn(clippy::unnecessary_literal_bound)]

trait Trait {
    fn foo(&self) -> &str;
}

struct Struct;

impl Trait for Struct {
    fn foo(&self) -> &str {
        "foo"
    }
}

impl Struct {
    fn bar(&self) -> &str {
        "bar"
    }
}

I would excpect the lint to only trigger on the bar function and not on foo.

There's ongoing discussion about refining RPITIT and I think this trait should behave similarly to what is done there.

Version

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5

Additional Labels

@rustbot label +A-lint +L-pedantic +I-false-positive

@rustbot rustbot added A-lint Area: New lints I-false-positive Issue: The lint was triggered on code it shouldn't have L-pedantic Lint: Belongs in the pedantic lint group labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints I-false-positive Issue: The lint was triggered on code it shouldn't have L-pedantic Lint: Belongs in the pedantic lint group
Projects
None yet
Development

No branches or pull requests

2 participants