Skip to content

'inline function' assist does not take generic type parameters into account #16373

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

Open
TieWay59 opened this issue Jan 16, 2024 · 1 comment
Open
Labels
C-bug Category: bug

Comments

@TieWay59
Copy link

TieWay59 commented Jan 16, 2024

rust-analyzer version: rust-analyzer version: 0.4.1808-standalone (a616c4d 2024-01-15)

rustc version: rustc 1.75.0 (82e1608df 2023-12-21)

relevant settings: none

This issue is similar to #16090 but it seems more likely to happen on most generic types.

use std::ops::Add;

struct Foo<T: Add + Default>(T);

impl<T: Add + Default> Foo<T> {
    fn clear(&mut self) {
        self.0 = T::default();
    }
}

fn main() {
    let foo: &mut Foo<i32> = &mut Foo(3);
    // foo.clear(); inline `clear` yeild:
    {
        let ref mut this = foo;
        this.0 = T::default();
        //       ^------------ expect: i32
    };
    foo.0 += 1;
}
### Tasks
- [ ] https://github.com/rust-lang/rust-analyzer/issues/16090
- [ ] https://github.com/rust-lang/rust-analyzer/issues/15471
- [ ] https://github.com/rust-lang/rust-analyzer/issues/15470
@TieWay59 TieWay59 added the C-bug Category: bug label Jan 16, 2024
@TieWay59
Copy link
Author

cc @roife

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

1 participant