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

r-a gets confused with nested anonymous type params when additional where bounds are involved #17173

Closed
Veykril opened this issue May 2, 2024 · 3 comments · Fixed by #17175
Closed
Assignees
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@Veykril
Copy link
Member

Veykril commented May 2, 2024

pub trait Lookup {
    type Data;
    fn lookup(&self) -> Self::Data;
}
pub trait ItemTreeLoc {
    type Id;
}
fn id_to_generics(id: impl Lookup<Data = impl ItemTreeLoc<Id = ()>>)
where
    (): Sized, // error below disappears if this is removed
{
    id.lookup(); // no method `lookup` on type `impl ItemTreeLoc<Id = ()>
}
@Veykril Veykril added A-ty type system / type inference / traits / method resolution C-bug Category: bug labels May 2, 2024
@Veykril
Copy link
Member Author

Veykril commented May 2, 2024

Test fixture that currently fails

//- minicore: sized
pub trait Lookup {
    type Data;
    fn lookup(&self) -> Self::Data;
}
pub trait ItemTreeLoc {
    type Id;
}
fn id_to_generics(id: impl Lookup<Data = impl ItemTreeLoc<Id = ()>>)
                //^^ impl Lookup<Data = impl ItemTreeLoc<Id = ()>>
where
    (): Sized,
{}

@Veykril
Copy link
Member Author

Veykril commented May 2, 2024

Something is still wrong here

#[test]
fn nested_anon_generics_and_where_bounds_17173() {
    check_types(
        r#"
//- minicore: sized, fn
pub trait Lookup {
    type Data;
    fn lookup(&self) -> Self::Data;
}
pub trait ItemTreeLoc {
    type Id;
}
fn id_to_generics(id: impl Lookup<Data = impl ItemTreeLoc<Id = ()>>,
                //^^ impl Lookup<Data = impl ItemTreeLoc<Id = ()>>
                enabled_params: impl Fn(),
              //^^^^^^^^^^^^^^  impl Fn()
                )
where
    (): Sized,
{}
"#,
    );
}

The impl Fn() is being recognized as impl ItemTreeLoc<Id = ()>

bors added a commit that referenced this issue May 2, 2024
Fix impl trait params not being counted properly

Fixes the other thing in #17173, this just rolls back a change from #17175 and adds a comment as to what it does
@lnicola
Copy link
Member

lnicola commented May 6, 2024

This was fixed in #17176, right?

lnicola pushed a commit to lnicola/rust that referenced this issue May 19, 2024
Fix impl trait params not being counted properly

Fixes the other thing in rust-lang/rust-analyzer#17173, this just rolls back a change from rust-lang/rust-analyzer#17175 and adds a comment as to what it does
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants