]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0738.md
Rollup merge of #68120 - Centril:ban-range-to-dotdotdot, r=oli-obk
[rust.git] / src / librustc_error_codes / error_codes / E0738.md
1 `#[track_caller]` cannot be used in traits yet. This is due to limitations in
2 the compiler which are likely to be temporary. See [RFC 2091] for details on
3 this and other restrictions.
4
5 Erroneous example with a trait method implementation:
6
7 ```compile_fail,E0738
8 #![feature(track_caller)]
9
10 trait Foo {
11     fn bar(&self);
12 }
13
14 impl Foo for u64 {
15     #[track_caller]
16     fn bar(&self) {}
17 }
18 ```
19
20 Erroneous example with a blanket trait method implementation:
21
22 ```compile_fail,E0738
23 #![feature(track_caller)]
24
25 trait Foo {
26     #[track_caller]
27     fn bar(&self) {}
28     fn baz(&self);
29 }
30 ```
31
32 Erroneous example with a trait method declaration:
33
34 ```compile_fail,E0738
35 #![feature(track_caller)]
36
37 trait Foo {
38     fn bar(&self) {}
39
40     #[track_caller]
41     fn baz(&self);
42 }
43 ```
44
45 Note that while the compiler may be able to support the attribute in traits in
46 the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
47
48 [RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md