Skip to content

Invalid multiple definitions errors for module and function with the same name #4563

@CohenArthur

Description

@CohenArthur
#![feature(no_core)]
#![no_core]

mod foo;

use foo::foo;

fn main() {
    foo();
}

with a foo module file only containing the following function:

pub fn foo() {}

This causes the following issue:

test.rs:6:5: error: ‘foo’ defined multiple times [E0428]
    4 | mod foo;
      | ~~~
    5 |
    6 | use foo::foo;
      |     ^~~

rustc doesn't emit any issues. This is a problem since modules should be inserted in the types NS, while functions should only be inserted in the Values NS.

Note that this is likely caused by the current implementation of #4404 and should be fixed before it gets merged

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions