كتاب الفتن وأشراط الساعة
54  
The Book of Tribulations and Portents of the Last Hour
(18)
Chapter: The Hour Will Not Begin Until A Man Passes By Another Man's Grave And Wishes That He Was In The Place Of The Deceased, Because Of Calamity
(18)
بَاب لَا تَقُومُ السَّاعَةُ حَتَّى يَمُرَّ الرَّجُلُ بِقَبْرِ الرَّجُلِ فَيَتَمَنَّى أَنْ يَكُونَ مَكَانَ الْمَيِّتِ مِنْ الْبَلَاءِ
Sahih Muslim 157 k

Abu Huraira reported Allah's Messenger (ﷺ) as saying:

The Last Hour would not come until a person would pass by a grave of another person and he would say: I wish it had been my abode.
حَدَّثَنَا قُتَيْبَةُ بْنُ سَعِيدٍ، عَنْ مَالِكِ بْنِ أَنَسٍ، فِيمَا قُرِئَ عَلَيْهِ عَنْ أَبِي الزِّنَادِ، عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ لاَ تَقُومُ السَّاعَةُ حَتَّى يَمُرَّ الرَّجُلُ بِقَبْرِ الرَّجُلِ فَيَقُولُ يَا لَيْتَنِي مَكَانَهُ ‏"‏ ‏.‏
Reference : Sahih Muslim 157k
In-book reference : Book 54, Hadith 67
USC-MSA web (English) reference : Book 41, Hadith 6947
  (deprecated numbering scheme)