- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
When trying to call a method on a raw pointer Rust compiler says there's no such method.
It would be better to say that there is such method, but the pointer has to be explicitly dereferenced first.
let x = 8u8;
let y = &x;
let z: *const u8 = &x;
println!("{} {}", 
    y.to_string(), // OK
    z.to_string()  // Not OK
);error: type
*const u8does not implement any method in scope namedto_string
This is technically correct, but unexpected and help hint for this error suggests wrong solution.
I've read this message as "yada yada no such method", so I went to check whether I've spelled the method correctly, whether I've put the method in the appropriate impl block, etc. — all completely irrelevant to this error.
I'd find something like that more helpful:
error: method
to_stringrequires typeu8, but*const u8cannot be automatically dereferenced. hint: useas_ref()
euclio
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.