forbid #[track_caller] on main
This commit is contained in:
parent
d51b71a35a
commit
06dbd06e4d
5 changed files with 70 additions and 1 deletions
4
src/test/ui/rfc-2091-track-caller/error-with-main.rs
Normal file
4
src/test/ui/rfc-2091-track-caller/error-with-main.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#[track_caller] //~ ERROR `main` function is not allowed to be
|
||||
fn main() {
|
||||
panic!("{}: oh no", std::panic::Location::caller());
|
||||
}
|
||||
12
src/test/ui/rfc-2091-track-caller/error-with-main.stderr
Normal file
12
src/test/ui/rfc-2091-track-caller/error-with-main.stderr
Normal 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
|
||||
|
||||
7
src/test/ui/rfc-2091-track-caller/error-with-start.rs
Normal file
7
src/test/ui/rfc-2091-track-caller/error-with-start.rs
Normal 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());
|
||||
}
|
||||
12
src/test/ui/rfc-2091-track-caller/error-with-start.stderr
Normal file
12
src/test/ui/rfc-2091-track-caller/error-with-start.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue