Skip to content

Building hover information for fn pointers from generic with impl args panics. #17811

@nicolas-guichard

Description

@nicolas-guichard

While trying out #17809 on mozilla-central, I noticed a failure in the time crate when building the hover information for the format_number function pointer here.

I managed to write a failing test, see b93994b.

The issue is we end up in hir_ty::display::generic_args_sans_defaults with more binders than parameters. I'm not 100% sure how to fix this, I'm also surprised we don't hit this in more cases since generic_args_sans_defaults is called multiple times with different numbers of parameters at least here and here.

rust-analyzer version: current HEAD

rustc version: rustc 1.80.0 (051478957 2024-07-21)

editor or extension: Kate / SCIP generator

relevant settings:

repository link (if public, optional): initially found with in time, minimal test at b93994b

code snippet to reproduce:

fn bar<const WIDTH: u8>(_: impl Copy) {}
fn test() {
    let f = bar::<3>;
    f(4);
}

hovering over f panics.

Metadata

Metadata

Assignees

Labels

C-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions