racer icon indicating copy to clipboard operation
racer copied to clipboard

Racer should parse the '[[bin]]' directive in cargo.toml to find the crate root

Open phildawes opened this issue 8 years ago • 3 comments

Currently find_possible_crate_root_modules() just hunts for main.rs and lib.rs files. It also needs to use the [[bin]] directive in the Cargo.toml

phildawes avatar Oct 05 '15 15:10 phildawes

Hope this is being worked on! I was getting really frustrated since completion for external crates wasn't working for me, but then I tried completing in a different file, which did work. I noticed that the only thing different was the first file was from my binary crate, while the second file was from my library crate. That led me to search for problems with completion in binary crates, which led me here. My binary crate does use a non-standard name for main.rs, so that's why racer wasn't able to find the external crates!

If this would be relatively straightforward and no one else is looking at it, I'd be more than happy to lend a hand 😃

aergonaut avatar Apr 26 '16 06:04 aergonaut

Note, see related issue : https://github.com/phildawes/racer/issues/513#issuecomment-214445913

Basically with the recently added cargo metadata command, if we have Racer read that output, it will provide us with the correct source root for each target in the crate (including test targets).

Alternatively, it's seems very simple to code all the logic to determine the source root of the crate targets (I did this in RustDT for example), so Racer could have this coded itself. But sooner or later, other features like #513 will require the use of cargo metadata.

bruno-medeiros avatar Apr 26 '16 13:04 bruno-medeiros

It would also be quite helpful to have this feature parsing Cargo.toml's [lib] section for paths other than just src/lib.rs.

daboross avatar Mar 23 '17 01:03 daboross