Skip to content

Commit 25b07c4

Browse files
committed
Do not use mem::transmute on non #[repr(C)] structs
Neither PgConnection nor PgMetadataLookup are marked as `#[repr(C)]` so this is at least implemetation defined behaviour. (The implementation of `std::path::Path` changed in rust-lang/rust#44890)
1 parent af05bcf commit 25b07c4

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

diesel/src/pg/metadata_lookup.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::mem;
2-
31
use prelude::*;
42
use super::{PgConnection, PgTypeMetadata};
53

@@ -11,7 +9,7 @@ pub struct PgMetadataLookup {
119

1210
impl PgMetadataLookup {
1311
pub(crate) fn new(conn: &PgConnection) -> &Self {
14-
unsafe { mem::transmute(conn) }
12+
unsafe { &*(conn as *const PgConnection as *const PgMetadataLookup) }
1513
}
1614

1715
/// Determine the type metadata for the given `type_name`

0 commit comments

Comments
 (0)