diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-08-04 07:30:04 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-08-04 07:35:59 +0200 |
| commit | 06dbd06e4deab2255d310d38ed0ea28becf43664 (patch) | |
| tree | 6f573a5e035727c82735fcb7b3916ad4cdc57935 /src/test | |
| parent | d51b71a35a816f4be56f77d1d1a6f4095352649e (diff) | |
| download | rust-06dbd06e4deab2255d310d38ed0ea28becf43664.tar.gz rust-06dbd06e4deab2255d310d38ed0ea28becf43664.zip | |
forbid `#[track_caller]` on main
Diffstat (limited to 'src/test')
4 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2091-track-caller/error-with-main.rs b/src/test/ui/rfc-2091-track-caller/error-with-main.rs new file mode 100644 index 00000000000..b2ea31bb517 --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/error-with-main.rs @@ -0,0 +1,4 @@ +#[track_caller] //~ ERROR `main` function is not allowed to be +fn main() { + panic!("{}: oh no", std::panic::Location::caller()); +} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-main.stderr b/src/test/ui/rfc-2091-track-caller/error-with-main.stderr new file mode 100644 index 00000000000..f05f88e7d71 --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/error-with-main.stderr @@ -0,0 +1,12 @@ +error: `main` function is not allowed to be `#[track_caller]` + --> $DIR/error-with-main.rs:1:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +LL | / fn main() { +LL | | panic!("{}: oh no", std::panic::Location::caller()); +LL | | } + | |_- `main` function is not allowed to be `#[track_caller]` + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2091-track-caller/error-with-start.rs b/src/test/ui/rfc-2091-track-caller/error-with-start.rs new file mode 100644 index 00000000000..678cb7fa404 --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/error-with-start.rs @@ -0,0 +1,7 @@ +#![feature(start)] + +#[start] +#[track_caller] //~ ERROR start is not allowed to be `#[track_caller]` +fn start(_argc: isize, _argv: *const *const u8) -> isize { + panic!("{}: oh no", std::panic::Location::caller()); +} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-start.stderr b/src/test/ui/rfc-2091-track-caller/error-with-start.stderr new file mode 100644 index 00000000000..03b2ce5514f --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/error-with-start.stderr @@ -0,0 +1,12 @@ +error: start is not allowed to be `#[track_caller]` + --> $DIR/error-with-start.rs:4:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +LL | / fn start(_argc: isize, _argv: *const *const u8) -> isize { +LL | | panic!("{}: oh no", std::panic::Location::caller()); +LL | | } + | |_- start is not allowed to be `#[track_caller]` + +error: aborting due to previous error + |
