"cannot declare a new module at this location" should specify good locations

25b8aae
Opened by Alex Burka at 2019-10-11 22:55:52

The error has two notes full of weasel words (2x "maybe", 1x "possibly") and it should probably say something straightforward like "modules are declared at the crate root, or mod.rs at the root of a source directory".

  1. This is a particularly annoying error message as it fails to tell the user what the problem is, leading to the impression that modules only work when some randomly shifting set of undocumented requirements are met.

    It also fails to offer any useful suggestions when refactoring and moving code around.

    The prevailing term that comes up when searching for this issue, "from the root", is also misleading as it appears to mean the root file (main.rs, lib.rs), not the root or src directory in the project.

    Ian Gilham at 2017-06-13 16:29:11