You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod foo;/* ... */// ambiguoususe foo::run_foo;// import expression
foo::run_foo();// full path expression// indicates an external crateuse::foo::run_foo;::foo::run_foo();// indicates a local submoduleuseself::foo::run_foo;self::foo::run_foo();
Ambiguous path may mislead to an external crate (dependency) called foo. With respect to leading :: represents the root path, the root path is explicit in macros, but a leading self:: would be better then use module name directly.
Options
"extern" - External crate should use leading ::.
"self" - Submodule should use leading self::.
"explicit" ("extern"+"self") - Directly use foo::run_foo is not allowed. Only accept ::/self::/crate::/super:: path.
Exception
Splitted path is not limited. (clippy::absolute_paths)
This lint is affect on use statement and the starting path is not imported. (foo::bar but foo is not import)
use::std::f64::consts;let x = consts::PI;
Advantage
Explicit path to know if a submodule has similar name to the dependencies.
Public macros can force to use ::/$crate to avoid wrong imports.
Drawbacks
No response
Example
use foo::run_foo;
foo::run_foo();mod bar;use bar::run_bar;
bar::run_bar();
What it does
For a path expression in the current module, like
Ambiguous path may mislead to an external crate (dependency) called
foo
. With respect to leading::
represents the root path, the root path is explicit in macros, but a leadingself::
would be better then use module name directly.Options
"extern"
- External crate should use leading::
."self"
- Submodule should use leadingself::
."explicit"
("extern"+"self"
) - Directly usefoo::run_foo
is not allowed. Only accept::
/self::
/crate::
/super::
path.Exception
Splitted path is not limited. (clippy::absolute_paths)
This lint is affect on
use
statement and the starting path is not imported. (foo::bar
butfoo
is not import)Advantage
::
/$crate
to avoid wrong imports.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: