diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2022-01-11 23:52:24 +0800 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2022-01-11 23:52:24 +0800 |
| commit | bf5130b502d3d1c61465c8deded65a1cb3929fbd (patch) | |
| tree | 0a8b9437951f9d194a96b5d7a9457f44c3be3339 | |
| parent | 7fd6ddfba2da259cd5c4232ff32e4c14a54a0e60 (diff) | |
| download | rust-bf5130b502d3d1c61465c8deded65a1cb3929fbd.tar.gz rust-bf5130b502d3d1c61465c8deded65a1cb3929fbd.zip | |
Add test
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr | 9 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs new file mode 100644 index 00000000000..cccb856c2f6 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs @@ -0,0 +1,17 @@ +#![feature(const_fn_trait_bound)] +#![feature(const_trait_impl)] + +pub trait Tr { + #[default_method_body_is_const] + fn a(&self) {} + + #[default_method_body_is_const] + fn b(&self) { + ().a() + //~^ ERROR calls in constant functions are limited + } +} + +impl Tr for () {} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr new file mode 100644 index 00000000000..91f4d2fd4b0 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr @@ -0,0 +1,9 @@ +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/default-method-body-is-const-same-trait-ck.rs:10:9 + | +LL | ().a() + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. |
