forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test cleanups to match #[track_caller] in panic!.
* Removes unnecessary feature flag from track_caller test. * Tests of panic internals no longer need to explicitly construct Location. * Add #![warn(const_err)] to retain-never-const per @oli-obk. * Add track_caller test with diverging function.
- Loading branch information
Showing
5 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
#![feature(const_panic)] | ||
#![feature(never_type)] | ||
#![warn(const_err)] | ||
|
||
struct PrintName<T>(T); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// run-fail | ||
|
||
//! This test ensures that `#[track_caller]` can be applied directly to diverging functions, as | ||
//! the tracking issue says: https://github.com/rust-lang/rust/issues/47809#issue-292138490. | ||
//! Because the annotated function must diverge and a panic keeps that faster than an infinite loop, | ||
//! we don't inspect the location returned -- it would be difficult to distinguish between the | ||
//! explicit panic and a failed assertion. That it compiles and runs is enough for this one. | ||
|
||
#![feature(track_caller)] | ||
|
||
#[track_caller] | ||
fn doesnt_return() -> ! { | ||
let _location = core::panic::Location::caller(); | ||
panic!("huzzah"); | ||
} | ||
|
||
fn main() { | ||
doesnt_return(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// run-pass | ||
|
||
#![feature(const_fn, track_caller)] | ||
#![feature(track_caller)] | ||
|
||
use std::panic::Location; | ||
|
||
|