-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specifically
Description
Currently Rust doesn’t support any of the following:
// Example A
use Default::default;
use f64::sin;
This means one can never write default()
or sin(3.14)
without qualification as individual methods can never be imported in isolation. The workaround is to have a prelude-like module where you write wrappers for such static methods as free functions:
// Example B
pub fn default<T: Default>() -> T { T::default() }
pub fn sin(x: f64) -> f64 { f64::sin(x) }
This is a lot of boilerplate. Perhaps it would useful to make Example A “just work”?
For static methods, the intent is pretty clear: it would enable
static_method(arg1, arg2, …)
This would be just a shorthand for calling Trait::static_method
. It won’t work if Self
is ambiguous.
For non-static methods, it’s not obvious what use Trait::method
would do. Which among these would it enable? (Either or both?)
method(obj, arg1, arg2, …)
obj.method(arg1, arg2, …)
Metadata
Metadata
Assignees
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specifically