rust/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pas...

80 lines
2.8 KiB
Plaintext

error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/call-const-trait-method-pass.rs:7:12
|
LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/call-const-trait-method-pass.rs:15:12
|
LL | impl const PartialEq for Int {
| ^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0049]: method `plus` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/call-const-trait-method-pass.rs:24:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | pub trait Plus {
LL | fn plus(self, rhs: Self) -> Self;
| - expected 0 const parameters
error[E0015]: cannot call non-const operator in constants
--> $DIR/call-const-trait-method-pass.rs:39:22
|
LL | const ADD_INT: Int = Int(1i32) + Int(2i32);
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error[E0015]: cannot call non-const fn `<i32 as Plus>::plus` in constant functions
--> $DIR/call-const-trait-method-pass.rs:11:20
|
LL | Int(self.0.plus(rhs.0))
| ^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error[E0015]: cannot call non-const fn `<Int as PartialEq>::eq` in constant functions
--> $DIR/call-const-trait-method-pass.rs:20:15
|
LL | !self.eq(other)
| ^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error[E0015]: cannot call non-const fn `<i32 as Plus>::plus` in constant functions
--> $DIR/call-const-trait-method-pass.rs:36:7
|
LL | a.plus(b)
| ^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0015, E0049.
For more information about an error, try `rustc --explain E0015`.