`fn self` in libs/modules

It's using bar in the module namespace, you won't get the function since that's a part of the value namespace. This used to also pull in the value namespace, but was backwards incompatibly changed as a bug-fix in rustc 1.28 (as part of `legacy_imports` future-compatibility warnings · Issue #38260 · rust-lang/rust · GitHub, although it doesn't directly mention this variant).

1 Like

Since this turns the module into a function, using the module uses the function. Even with use foo::bar::self.

It’s a module, in the module namespace, that evaluates to a function.

I think you are right. After glancing at the API guideline on stuttering I can’t find anything that states that either of us are wrong and there is some.ambiguity. leaving it at that.

1 Like

I like this because when you come across such function you immediately see that it is special and you know what to look for: "attribute hoist_to_be_crate_root_in_public_value_namespace". In other words it is explicit magic but fn self is more like hidden magic.

If the feature is used frequently then it is ok to upgrade it to self function because it is not magic anymore.

2 Likes

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