-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bug
Description
rust-analyzer version:
rust-analyzer version: 7e95c14ea 2022-05-17 stable
rustc version:
rustc 1.63.0-nightly (cd282d7f7 2022-05-18)
relevant settings:
OS: Ubuntu 20.04.4 LTS
I was learning wasmer
by its examples and came across this lint.
The origin macro is complicated so I extract the code and write a simple case to reproduce it :
#![allow(unused)]
use std::marker::PhantomData;
struct SomeFunc<Args = ()> {
_phantom: PhantomData<Args>,
}
trait SomeTrait {}
impl SomeTrait for i32 {}
impl SomeTrait for f32 {}
impl<Args> SomeFunc<Args> {
fn new() -> Self {
Self {
_phantom: PhantomData,
}
}
}
macro_rules! impl_call {
( $( $x:ident ),* ) => {
#[allow(unused_parens, non_snake_case)]
impl<$( $x , )*> SomeFunc<( $( $x ),* )>
where
$( $x: SomeTrait, )*
{
pub fn call(&self, $( $x: $x, )* ) {
}
}
};
}
impl_call!(A1);
impl_call!(A1, A2);
fn main() {
let f1 = SomeFunc::<i32>::new();
f1.call(10);
let f2 = SomeFunc::<(i32, f32)>::new();
f2.call(10, 10.); // rust analyzer complains: expected 1 argument, found 2
}
cargo run
works fine, but it seems rust-analyzer was confused at f2.call(...)
.
By chance, I tried to switch the order of impl_call!
macros into:
impl_call!(A1, A2);
impl_call!(A1);
And the lint was gone! it's works just fine.
I suppose it might be a 🐞
BTW, I had search the existing issue, this is the closest one #9887 . but I'm not sure if it is the same reason.
taosx
Metadata
Metadata
Assignees
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bug