File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 1- msrv = " 1.56.1 "
1+ msrv = " 1.65.0 "
22disallowed-types = [" std::collections::HashMap" ]
Original file line number Diff line number Diff line change 6464{
6565 type Item = AtomicRef < ' a , T > ;
6666
67+ #[ allow( clippy:: borrowed_box) ] // variant of https://github.com/rust-lang/rust-clippy/issues/5770
6768 fn next ( & mut self ) -> Option < <Self as Iterator >:: Item > {
6869 loop {
6970 let resource_id = match self . tys . get ( self . index ) {
Original file line number Diff line number Diff line change @@ -14,16 +14,17 @@ impl PointsToU64 for Box<u64> {
1414
1515struct MultipleData {
1616 _number : u64 ,
17- pointer : Box < u64 > ,
17+ _pointer : Box < u64 > ,
1818}
1919
2020unsafe impl CastFrom < MultipleData > for dyn PointsToU64 {
21- fn cast ( t : * mut MultipleData ) -> * mut Self {
22- // note, this also assumes the pointer is non-null and probably other things which we can't
23- // assume in an implementation of `CastFrom`.
24-
25- // this is wrong and will cause a panic
26- unsafe { core:: ptr:: addr_of_mut!( ( * t) . pointer) }
21+ fn cast ( _t : * mut MultipleData ) -> * mut Self {
22+ // This is wrong and will cause a panic
23+ //
24+ // NOTE: we use this instead of constructing a pointer to the field since
25+ // there is no way to easily and safely do that currently! (this can be
26+ // changed if offset_of macro is added to std).
27+ core:: ptr:: NonNull :: < Box < u64 > > :: dangling ( ) . as_ptr ( )
2728 }
2829}
2930
@@ -33,7 +34,7 @@ fn test_panics() {
3334 let mut table: MetaTable < dyn PointsToU64 > = MetaTable :: new ( ) ;
3435 let md = MultipleData {
3536 _number : 0x0 , // this will be casted to a pointer, then dereferenced
36- pointer : Box :: new ( 42 ) ,
37+ _pointer : Box :: new ( 42 ) ,
3738 } ;
3839 table. register :: < MultipleData > ( ) ;
3940 if let Some ( t) = table. get ( & md) {
You can’t perform that action at this time.
0 commit comments