File tree 3 files changed +11
-11
lines changed
src/tools/clippy/tests/ui
3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -35,16 +35,16 @@ fn transmute_ptr_to_ptr() {
35
35
// ref-ref transmutes; bad
36
36
let _: &f32 = &*(&1u32 as *const u32 as *const f32);
37
37
//~^ ERROR: transmute from a reference to a reference
38
- let _: &f64 = &*(&1f32 as *const f32 as *const f64 );
38
+ let _: &f32 = &*(&1f64 as *const f64 as *const f32 );
39
39
//~^ ERROR: transmute from a reference to a reference
40
40
//:^ this test is here because both f32 and f64 are the same TypeVariant, but they are not
41
41
// the same type
42
42
let _: &mut f32 = &mut *(&mut 1u32 as *mut u32 as *mut f32);
43
43
//~^ ERROR: transmute from a reference to a reference
44
44
let _: &GenericParam<f32> = &*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>);
45
45
//~^ ERROR: transmute from a reference to a reference
46
- let u8_ref : &u8 = &0u8 ;
47
- let u64_ref : &u64 = unsafe { &*(u8_ref as *const u8 as *const u64 ) };
46
+ let u64_ref : &u64 = &0u64 ;
47
+ let u8_ref : &u8 = unsafe { &*(u64_ref as *const u64 as *const u8 ) };
48
48
//~^ ERROR: transmute from a reference to a reference
49
49
}
50
50
Original file line number Diff line number Diff line change @@ -35,16 +35,16 @@ fn transmute_ptr_to_ptr() {
35
35
// ref-ref transmutes; bad
36
36
let _: & f32 = std:: mem:: transmute ( & 1u32 ) ;
37
37
//~^ ERROR: transmute from a reference to a reference
38
- let _: & f64 = std:: mem:: transmute ( & 1f32 ) ;
38
+ let _: & f32 = std:: mem:: transmute ( & 1f64 ) ;
39
39
//~^ ERROR: transmute from a reference to a reference
40
40
//:^ this test is here because both f32 and f64 are the same TypeVariant, but they are not
41
41
// the same type
42
42
let _: & mut f32 = std:: mem:: transmute ( & mut 1u32 ) ;
43
43
//~^ ERROR: transmute from a reference to a reference
44
44
let _: & GenericParam < f32 > = std:: mem:: transmute ( & GenericParam { t : 1u32 } ) ;
45
45
//~^ ERROR: transmute from a reference to a reference
46
- let u8_ref : & u8 = & 0u8 ;
47
- let u64_ref : & u64 = unsafe { std:: mem:: transmute ( u8_ref ) } ;
46
+ let u64_ref : & u64 = & 0u64 ;
47
+ let u8_ref : & u8 = unsafe { std:: mem:: transmute ( u64_ref ) } ;
48
48
//~^ ERROR: transmute from a reference to a reference
49
49
}
50
50
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ LL | let _: &f32 = std::mem::transmute(&1u32);
22
22
error: transmute from a reference to a reference
23
23
--> $DIR/transmute_ptr_to_ptr.rs:38:23
24
24
|
25
- LL | let _: &f64 = std::mem::transmute(&1f32 );
26
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64 )`
25
+ LL | let _: &f32 = std::mem::transmute(&1f64 );
26
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f64 as *const f64 as *const f32 )`
27
27
28
28
error: transmute from a reference to a reference
29
29
--> $DIR/transmute_ptr_to_ptr.rs:42:27
@@ -38,10 +38,10 @@ LL | let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t:
38
38
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)`
39
39
40
40
error: transmute from a reference to a reference
41
- --> $DIR/transmute_ptr_to_ptr.rs:47:38
41
+ --> $DIR/transmute_ptr_to_ptr.rs:47:36
42
42
|
43
- LL | let u64_ref : &u64 = unsafe { std::mem::transmute(u8_ref ) };
44
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u8_ref as *const u8 as *const u64 )`
43
+ LL | let u8_ref : &u8 = unsafe { std::mem::transmute(u64_ref ) };
44
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u64_ref as *const u64 as *const u8 )`
45
45
46
46
error: aborting due to 7 previous errors
47
47
You can’t perform that action at this time.
0 commit comments