diff options
| author | John Kugelman <john@kugelman.name> | 2021-10-14 18:54:55 -0400 |
|---|---|---|
| committer | John Kugelman <john@kugelman.name> | 2021-10-30 18:21:29 -0400 |
| commit | 68b0d862945782f215f39980d6ac9ffabdb2031c (patch) | |
| tree | 34d1bdbf7fa83aadc8df13f589774d7ef64174ed /library/core/src/panic | |
| parent | e1e9319d93aea755c444c8f8ff863b0936d7a4b6 (diff) | |
Add #[must_use] to remaining core functions
Diffstat (limited to 'library/core/src/panic')
| -rw-r--r-- | library/core/src/panic/location.rs | 4 | ||||
| -rw-r--r-- | library/core/src/panic/panic_info.rs | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/library/core/src/panic/location.rs b/library/core/src/panic/location.rs index a482414caaf..714e9b73c78 100644 --- a/library/core/src/panic/location.rs +++ b/library/core/src/panic/location.rs @@ -79,6 +79,7 @@ impl<'a> Location<'a> { /// assert_ne!(this_location.line(), another_location.line()); /// assert_ne!(this_location.column(), another_location.column()); /// ``` + #[must_use] #[stable(feature = "track_caller", since = "1.46.0")] #[rustc_const_unstable(feature = "const_caller_location", issue = "76156")] #[track_caller] @@ -119,6 +120,7 @@ impl<'a> Location<'a> { /// /// panic!("Normal panic"); /// ``` + #[must_use] #[stable(feature = "panic_hooks", since = "1.10.0")] pub fn file(&self) -> &str { self.file @@ -141,6 +143,7 @@ impl<'a> Location<'a> { /// /// panic!("Normal panic"); /// ``` + #[must_use] #[stable(feature = "panic_hooks", since = "1.10.0")] pub fn line(&self) -> u32 { self.line @@ -163,6 +166,7 @@ impl<'a> Location<'a> { /// /// panic!("Normal panic"); /// ``` + #[must_use] #[stable(feature = "panic_col", since = "1.25.0")] pub fn column(&self) -> u32 { self.col diff --git a/library/core/src/panic/panic_info.rs b/library/core/src/panic/panic_info.rs index a52a0022e5d..b1fdf138211 100644 --- a/library/core/src/panic/panic_info.rs +++ b/library/core/src/panic/panic_info.rs @@ -81,6 +81,7 @@ impl<'a> PanicInfo<'a> { /// /// panic!("Normal panic"); /// ``` + #[must_use] #[stable(feature = "panic_hooks", since = "1.10.0")] pub fn payload(&self) -> &(dyn Any + Send) { self.payload @@ -89,6 +90,7 @@ impl<'a> PanicInfo<'a> { /// If the `panic!` macro from the `core` crate (not from `std`) /// was used with a formatting string and some additional arguments, /// returns that message ready to be used for example with [`fmt::write`] + #[must_use] #[unstable(feature = "panic_info_message", issue = "66745")] pub fn message(&self) -> Option<&fmt::Arguments<'_>> { self.message @@ -118,6 +120,7 @@ impl<'a> PanicInfo<'a> { /// /// panic!("Normal panic"); /// ``` + #[must_use] #[stable(feature = "panic_hooks", since = "1.10.0")] pub fn location(&self) -> Option<&Location<'_>> { // NOTE: If this is changed to sometimes return None, |
