Skip to content

Type inference fails with braces in const generics #21315

@araraloren

Description

@araraloren

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

0.3.2719-standalone (87cf6631c6 2025-12-14)

rustc version: (eg. output of rustc -V)

rustc 1.92.0 (ded5c06cf 2025-12-08)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

VScode

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

https://github.com/araraloren/example

code snippet to reproduce:

https://github.com/araraloren/example/blob/main/src/main.rs

// add your code here
// trait definition 
    fn at_least<const M: usize>(self) -> Between<M, { usize::MAX }, C, Self> {
        self.between::<M, { usize::MAX }>()
    }

    fn at_most<const N: usize>(self) -> Between<0, N, C, Self> {
        self.between::<0, N>()
    }
// code
    let num = '9'.at_least::<1>();
    let ver = num.sep_once(".", num); // type inference failure

    let mut ctx = CharsCtx::new("");

    ctx.ctor(&ver)?;

    let num = '9'.at_most::<1>();
    let ver = num.sep_once(".", num); // okay
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions