Closed
Description
Using str
without the std::str
prefix to specify the module generates unhelpful error messages (especially since the distinction between the std::str
module and the str
primitive is not very nicely thought out due to technical restrictions I wish we could revisit).
Example code:
fn main() {
let bytes = "hello world".as_bytes();
let string = unsafe {
str::from_utf8(bytes)
};
println!("{}", string);
}
This causes the compiler to emit the following error:
error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
--> ./test.rs:4:9
|
4 | str::from_utf8(bytes)
| ^^^^^^^^^^^^^^
error: aborting due to previous error
A recommendation to specify std::
to access the module function with the same name would be most helpful. In fact, anything the compiler could do to blur the distinction between the type and the primitive would be most appreciated.