Why I must add use<'_, B> here?

The use bounds, as the document says, are used to opt-out some un-needed things. The default hehaviour is capturing all.

So, I think it is OK if I don't add use<'_, B> , leaving the default behaviour of capturing all parameters takes effect.
But the code can't be acceppted without it.

    fn some_fn<const B: bool>(&self) -> impl DerefMut<Target = Vec<Pair>> + use<'_, B> {
        self.mutex.lock().unwrap()
    }

Edit:

I found the problem, there are two targets in my cargo.toml; I set rust 2024 only at only one of them

Would you mind providing a minimal reproducible example? I can't replicate the need for use<'_, B>.

What edition do you have in your Cargo.toml? The behaviour of capturing everything by default is something that was introduced in the 2024 edition. For earlier editions, the default is to capture nothing (EDIT to correct: only lifetime parameters are not captured by default, type and const generics are captured in all editions).

The code can be found at PlayGround;

It seems because it is rust 2021, with 2024, the problem gone;

While my real code is indeed rust 2024, (I started with rust 2021, but changed to 2024 by modifying Cargo.toml manually), and the problem araises;

So, what can I do to fix that? I remember I have done cargo clean after the changing

I believe I found the restriction:

use<..>, if provided, must include all in-scope type and const generic parameters.

It's the default for Edition 2024, not previous editions. Doc

It is not because of const B: bool; the problem appears when the no use<'_, B> at all (not only '_)

You can set the edition for the whole [package] at once, not just individual targets. That will likely be less error-prone.

I set 2024 at the package, unfortunatelly, there is a 2021 left at the bin