forbid #[track_caller] on main

This commit is contained in:
Bastian Kauschke 2020-08-04 07:30:04 +02:00
parent d51b71a35a
commit 06dbd06e4d
5 changed files with 70 additions and 1 deletions

View file

@ -0,0 +1,4 @@
#[track_caller] //~ ERROR `main` function is not allowed to be
fn main() {
panic!("{}: oh no", std::panic::Location::caller());
}

View file

@ -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

View file

@ -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());
}

View file

@ -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