Skip to content

Wrong suggestion in module declaration error message #38110

Closed
@fabric-and-ink

Description

@fabric-and-ink

Maybe this bug is related to #36146.

Library structure

src/lib.rs
src/foo/mod.rs
src/foo/bar.rs

src/lib.rs:
pub mod foo;

src/foo/mod.rs:
pub mod bar;

src/foo/bar.rs
pub mod baz;

Error

Currently:

error: cannot declare a new module at this location
 --> foo\bar.rs:1:9
  |
1 | pub mod baz;
  |         ^^^
  |
note: maybe move this module `foo` to its own directory via `foo/mod.rs`
 --> foo\bar.rs:1:9
  |
1 | pub mod baz;
  |         ^^^

Should be:

  error: cannot declare a new module at this location
   --> foo\bar.rs:1:9
    |
  1 | pub mod baz;
    |         ^^^
    |
- note: maybe move this module `foo` to its own directory via `foo/mod.rs`
+ note: maybe move this module `bar` to its own directory via `bar/mod.rs`
   --> foo\bar.rs:1:9
    |
  1 | pub mod baz;
    |         ^^^

Additionally, I don't understand what to make of the repeated code excerpt.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions