Name resolution documentation

Hi,

I am looking for documentation on the rules for name resolution of items.

I've seen https://rust-lang.github.io/rustc-guide/name-resolution.html but it doesnt explain resolution of items.

My current assumption is that scopes are traversed upwards, and for each scope: if an unambiguous explicit identifier is found, then it is used. If an unambiguous identifier is found from wildcards (*), then it is used.

Is this correct, and, is there any documentation on this?

Shown below, Example 1 and 2 binds differently.

Context:

mod m1 { pub fn foo() {panic!("");} }
mod m2 { pub fn foo() {} }

Example 1:

use m2::foo;
use m1::*;
{
  foo(); // m2::foo
}

Example 2:

use m2::foo;
{
  use m1::*;
  foo(); // m1::foo
}
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.