- 
                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 lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-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
Minimal repro:
use std::ops::Deref;
struct A (u8);
impl Deref for A {
    type Target = u8;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
fn main() {
    let a = A(0);
    //compiles
    let b: &u8 = &a;
    let c: *const u8 = b;
    //error
    let d: *const u8 = &a;
}Compile error:
coerce.rs:15:24: 15:26 error: mismatched types:
 expected `*const u8`,
    found `&A`
(expected u8,
    found struct `A`) [E0308]
coerce.rs:15     let c: *const u8 = &a;
                                    ^~
coerce.rs:15:24: 15:26 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous errorMetadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-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.