Skip to content
Myr

Improve naming in Drop test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 794ba39 · Browse files · 1 file+15 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−8 removed

  • other:+15 added−8 removed

1 file+15 added−8 removed

modified:src/error.rs+15 added-8 removed
327 unmodified lines
328 assert::<Error>();329 }330331 #[test]332 fn destructors_work() {332 fn drop_works() {333 #[derive(Debug)]334 struct HasDrop(Arc<AtomicBool>);335 impl StdError for HasDrop {}336 impl Display for HasDrop {334 struct DetectDrop {335 has_dropped: Arc<AtomicBool>,336 }337338 impl StdError for DetectDrop {}339340 impl Display for DetectDrop {341 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {342 write!(f, "does something")343 }344 }345341 impl Drop for HasDrop {346 impl Drop for DetectDrop {347 fn drop(&mut self) {343 let has_dropped = self.0.swap(true, SeqCst);344 assert!(!has_dropped);348 let already_dropped = self.has_dropped.swap(true, SeqCst);349 assert!(!already_dropped);350 }351 }352353 let has_dropped = Arc::new(AtomicBool::new(false));354350 drop(Error::from(HasDrop(has_dropped.clone())));355 drop(Error::from(DetectDrop {356 has_dropped: has_dropped.clone(),357 }));358359 assert!(has_dropped.load(SeqCst));360 }361}