rls icon indicating copy to clipboard operation
rls copied to clipboard

Guessing game from The Rust Book has wrong completion

Open TomasHubelbauer opened this issue 5 years ago • 1 comments

I am following the Rust book, using VS Code with the official Rust extension which uses RLS internally. I am typing this line from the guessing game example:

let secret_number = rand::thread_rng().gen_range(1, 101);

When typing this line, the dot after rand::thread_rng() provides these completion items:

image

There is no gen_range. However, the line compiles just fine.

Not sure if this is a problem with RLS or perhaps the docs or maybe even the rand crate's types, so I'm starting here.

TomasHubelbauer avatar Mar 04 '20 21:03 TomasHubelbauer

The thread_rng returns a type that impls RngCore which is extended by the trait Rng(any type that impls RngCore also impls Rng) but because its defined in a different place and isn't directly impl'ed rls (Racer is what powers completions for this) doesn't see it.

DevinR528 avatar Mar 05 '20 13:03 DevinR528