forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#92432 - fee1-dead:constck-impl-constness, r…
…=oli-obk Error when selected impl is not const in constck Catches bad things when checking a `default_method_body_is_const` body, such as: ```rust self.map(/* .. */).is_sorted(); ``` When `Map` does not yet have a `const` `impl` for `Iterator`. r? ``@oli-obk``
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
9 changes: 9 additions & 0 deletions
9
src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |