Closed
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 error
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Type systemCategory: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.