@@ -68,7 +68,8 @@ struct LockMetadata {
68
68
69
69
struct LockDep {
70
70
lock : Arc < LockMetadata > ,
71
- lockdep_trace : Backtrace ,
71
+ /// lockdep_trace is unused unless we're building with `backtrace`, so we mark it _
72
+ _lockdep_trace : Backtrace ,
72
73
}
73
74
74
75
#[ cfg( feature = "backtrace" ) ]
@@ -140,21 +141,21 @@ impl LockMetadata {
140
141
// of the same lock.
141
142
debug_assert ! ( cfg!( feature = "backtrace" ) , "Tried to acquire a lock while it was held!" ) ;
142
143
}
143
- for ( locked_dep_idx, locked_dep ) in locked. locked_before . lock ( ) . unwrap ( ) . iter ( ) {
144
+ for ( locked_dep_idx, _locked_dep ) in locked. locked_before . lock ( ) . unwrap ( ) . iter ( ) {
144
145
if * locked_dep_idx == this. lock_idx && * locked_dep_idx != locked. lock_idx {
145
146
#[ cfg( feature = "backtrace" ) ]
146
147
panic ! ( "Tried to violate existing lockorder.\n Mutex that should be locked after the current lock was created at the following backtrace.\n Note that to get a backtrace for the lockorder violation, you should set RUST_BACKTRACE=1\n Lock being taken constructed at: {} ({}):\n {:?}\n Lock constructed at: {} ({})\n {:?}\n \n Lock dep created at:\n {:?}\n \n " ,
147
148
get_construction_location( & this. _lock_construction_bt) , this. lock_idx, this. _lock_construction_bt,
148
149
get_construction_location( & locked. _lock_construction_bt) , locked. lock_idx, locked. _lock_construction_bt,
149
- locked_dep . lockdep_trace ) ;
150
+ _locked_dep . _lockdep_trace ) ;
150
151
#[ cfg( not( feature = "backtrace" ) ) ]
151
152
panic ! ( "Tried to violate existing lockorder. Build with the backtrace feature for more info." ) ;
152
153
}
153
154
}
154
155
// Insert any already-held locks in our locked-before set.
155
156
let mut locked_before = this. locked_before . lock ( ) . unwrap ( ) ;
156
157
if !locked_before. contains_key ( & locked. lock_idx ) {
157
- let lockdep = LockDep { lock : Arc :: clone ( locked) , lockdep_trace : Backtrace :: new ( ) } ;
158
+ let lockdep = LockDep { lock : Arc :: clone ( locked) , _lockdep_trace : Backtrace :: new ( ) } ;
158
159
locked_before. insert ( lockdep. lock . lock_idx , lockdep) ;
159
160
}
160
161
}
@@ -175,7 +176,7 @@ impl LockMetadata {
175
176
let mut locked_before = this. locked_before . lock ( ) . unwrap ( ) ;
176
177
for ( locked_idx, locked) in held. borrow ( ) . iter ( ) {
177
178
if !locked_before. contains_key ( locked_idx) {
178
- let lockdep = LockDep { lock : Arc :: clone ( locked) , lockdep_trace : Backtrace :: new ( ) } ;
179
+ let lockdep = LockDep { lock : Arc :: clone ( locked) , _lockdep_trace : Backtrace :: new ( ) } ;
179
180
locked_before. insert ( * locked_idx, lockdep) ;
180
181
}
181
182
}
0 commit comments