[RFC 2091] Add #[track_caller] attribute.
- The attribute is behind a feature gate. - Error if both #[naked] and #[track_caller] are applied to the same function. - Error if #[track_caller] is applied to a non-function item. - Error if ABI is not "rust" - Error if #[track_caller] is applied to a trait function. Error codes and descriptions are pending.
This commit is contained in:
parent
e3cb9ea15a
commit
543449d4fd
22 changed files with 199 additions and 1 deletions
6
src/test/ui/feature-gates/feature-gate-track_caller.rs
Normal file
6
src/test/ui/feature-gates/feature-gate-track_caller.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
#[track_caller]
|
||||
fn f() {}
|
||||
//~^^ ERROR the `#[track_caller]` attribute is an experimental feature
|
||||
|
||||
fn main() {}
|
||||
12
src/test/ui/feature-gates/feature-gate-track_caller.stderr
Normal file
12
src/test/ui/feature-gates/feature-gate-track_caller.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0658]: the `#[track_caller]` attribute is an experimental feature
|
||||
--> $DIR/feature-gate-track_caller.rs:2:1
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/47809
|
||||
= help: add `#![feature(track_caller)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
7
src/test/ui/rfc-2091-track-caller/error-odd-syntax.rs
Normal file
7
src/test/ui/rfc-2091-track-caller/error-odd-syntax.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![feature(track_caller)]
|
||||
|
||||
#[track_caller(1)]
|
||||
fn f() {}
|
||||
//~^^ ERROR malformed `track_caller` attribute input
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
error: malformed `track_caller` attribute input
|
||||
--> $DIR/error-odd-syntax.rs:3:1
|
||||
|
|
||||
LL | #[track_caller(1)]
|
||||
| ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[track_caller]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#![feature(track_caller)]
|
||||
|
||||
#[track_caller]
|
||||
extern "C" fn f() {}
|
||||
//~^^ ERROR rust ABI is required to use `#[track_caller]`
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0902]: rust ABI is required to use `#[track_caller]`
|
||||
--> $DIR/error-with-invalid-abi.rs:3:1
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0902`.
|
||||
8
src/test/ui/rfc-2091-track-caller/error-with-naked.rs
Normal file
8
src/test/ui/rfc-2091-track-caller/error-with-naked.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![feature(naked_functions, track_caller)]
|
||||
|
||||
#[track_caller]
|
||||
#[naked]
|
||||
fn f() {}
|
||||
//~^^^ ERROR cannot use `#[track_caller]` with `#[naked]`
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0901]: cannot use `#[track_caller]` with `#[naked]`
|
||||
--> $DIR/error-with-naked.rs:3:1
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0901`.
|
||||
13
src/test/ui/rfc-2091-track-caller/error-with-trait-fns.rs
Normal file
13
src/test/ui/rfc-2091-track-caller/error-with-trait-fns.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#![feature(track_caller)]
|
||||
|
||||
trait Trait {
|
||||
#[track_caller]
|
||||
fn unwrap(&self);
|
||||
//~^^ ERROR: `#[track_caller]` is not supported for trait items yet.
|
||||
}
|
||||
|
||||
impl Trait for u64 {
|
||||
fn unwrap(&self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0903]: `#[track_caller]` is not supported for trait items yet.
|
||||
--> $DIR/error-with-trait-fns.rs:4:5
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0903`.
|
||||
7
src/test/ui/rfc-2091-track-caller/only-for-fns.rs
Normal file
7
src/test/ui/rfc-2091-track-caller/only-for-fns.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![feature(track_caller)]
|
||||
|
||||
#[track_caller]
|
||||
struct S;
|
||||
//~^^ ERROR attribute should be applied to function
|
||||
|
||||
fn main() {}
|
||||
11
src/test/ui/rfc-2091-track-caller/only-for-fns.stderr
Normal file
11
src/test/ui/rfc-2091-track-caller/only-for-fns.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0900]: attribute should be applied to function
|
||||
--> $DIR/only-for-fns.rs:3:1
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
LL | struct S;
|
||||
| --------- not a function
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0900`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue