Expand E0738 to cover different cases.
This commit is contained in:
parent
bdc4bd142b
commit
130be6d4b8
8 changed files with 94 additions and 13 deletions
|
|
@ -180,7 +180,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: DefId) {
|
|||
tcx.sess,
|
||||
attr.span,
|
||||
E0738,
|
||||
"`#[track_caller]` is not supported for trait items yet."
|
||||
"`#[track_caller]` is not supported in trait declarations."
|
||||
).emit();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4926,12 +4926,11 @@ extern "C" fn foo() {}
|
|||
"##,
|
||||
|
||||
E0738: r##"
|
||||
#[track_caller] cannot be applied to trait methods.
|
||||
#[track_caller] cannot be used in traits yet. This is due to limitations in the
|
||||
compiler which are likely to be temporary. See [RFC 2091] for details on this
|
||||
and other restrictions.
|
||||
|
||||
This is due to limitations in the compiler which are likely to be temporary.
|
||||
See [RFC 2091] for details on this and other restrictions.
|
||||
|
||||
Erroneous code example:
|
||||
Erroneous example with a trait method implementation:
|
||||
|
||||
```compile_fail,E0738
|
||||
#![feature(track_caller)]
|
||||
|
|
@ -4940,14 +4939,40 @@ trait Foo {
|
|||
fn bar(&self);
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for Bar {
|
||||
impl Foo for u64 {
|
||||
#[track_caller]
|
||||
fn bar(&self) {}
|
||||
}
|
||||
```
|
||||
|
||||
Erroneous example with a blanket trait method implementation:
|
||||
|
||||
```compile_fail,E0738
|
||||
#![feature(track_caller)]
|
||||
|
||||
trait Foo {
|
||||
#[track_caller]
|
||||
fn bar(&self) {}
|
||||
fn baz(&self);
|
||||
}
|
||||
```
|
||||
|
||||
Erroneous example with a trait method declaration:
|
||||
|
||||
```compile_fail,E0738
|
||||
#[!feature(track_caller)]
|
||||
|
||||
trait Foo {
|
||||
fn bar(&self) {}
|
||||
|
||||
#[track_caller]
|
||||
fn baz(&self);
|
||||
}
|
||||
```
|
||||
|
||||
Note that while the compiler may be able to support the attribute in traits in
|
||||
the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
|
||||
|
||||
[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
|
||||
"##,
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
trait Trait {
|
||||
#[track_caller]
|
||||
fn unwrap(&self);
|
||||
//~^^ ERROR: `#[track_caller]` is not supported for trait items yet.
|
||||
//~^^ ERROR: `#[track_caller]` is not supported in traits yet.
|
||||
}
|
||||
|
||||
impl Trait for u64 {
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
warning: the feature `track_caller` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/error-with-trait-decl.rs:1:12
|
||||
|
|
||||
LL | #![feature(track_caller)]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0738]: `#[track_caller]` is not supported in trait declarations.
|
||||
--> $DIR/error-with-trait-decl.rs:4:5
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0738`.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#![feature(track_caller)] //~ WARN the feature `track_caller` is incomplete
|
||||
|
||||
trait Trait {
|
||||
#[track_caller]
|
||||
fn unwrap(&self) {}
|
||||
//~^^ ERROR: `#[track_caller]` is not supported in trait declarations.
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
warning: the feature `track_caller` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/error-with-trait-default-impl.rs:1:12
|
||||
|
|
||||
LL | #![feature(track_caller)]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0738]: `#[track_caller]` is not supported in traits yet.
|
||||
--> $DIR/error-with-trait-default-impl.rs:4:5
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0738`.
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#![feature(track_caller)] //~ WARN the feature `track_caller` is incomplete
|
||||
|
||||
trait Trait {
|
||||
fn unwrap(&self);
|
||||
}
|
||||
|
||||
impl Trait for u64 {
|
||||
#[track_caller]
|
||||
fn unwrap(&self) {}
|
||||
//~^^ ERROR: `#[track_caller]` is not supported in traits yet.
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
warning: the feature `track_caller` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/error-with-trait-fns.rs:1:12
|
||||
--> $DIR/error-with-trait-fn-impl.rs:1:12
|
||||
|
|
||||
LL | #![feature(track_caller)]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0738]: `#[track_caller]` is not supported for trait items yet.
|
||||
--> $DIR/error-with-trait-fns.rs:4:5
|
||||
error[E0738]: `#[track_caller]` is not supported in traits yet.
|
||||
--> $DIR/error-with-trait-fn-impl.rs:4:5
|
||||
|
|
||||
LL | #[track_caller]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
Loading…
Add table
Add a link
Reference in a new issue