Add tests for cross-crate usage of impl const
This commit is contained in:
parent
3b9453bfe2
commit
c424510746
@ -0,0 +1,22 @@
|
|||||||
|
#![feature(const_trait_impl)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
pub trait MyTrait {
|
||||||
|
fn func(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct NonConst;
|
||||||
|
|
||||||
|
impl MyTrait for NonConst {
|
||||||
|
fn func(self) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Const;
|
||||||
|
|
||||||
|
impl const MyTrait for Const {
|
||||||
|
fn func(self) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// aux-build: cross-crate.rs
|
||||||
|
extern crate cross_crate;
|
||||||
|
|
||||||
|
use cross_crate::*;
|
||||||
|
|
||||||
|
fn non_const_context() {
|
||||||
|
NonConst.func();
|
||||||
|
Const.func();
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn const_context() {
|
||||||
|
NonConst.func();
|
||||||
|
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
Const.func();
|
||||||
|
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,15 @@
|
|||||||
|
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
--> $DIR/cross-crate-feature-disabled.rs:12:5
|
||||||
|
|
|
||||||
|
LL | NonConst.func();
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
--> $DIR/cross-crate-feature-disabled.rs:14:5
|
||||||
|
|
|
||||||
|
LL | Const.func();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
@ -0,0 +1,20 @@
|
|||||||
|
#![feature(const_trait_impl)]
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
|
// aux-build: cross-crate.rs
|
||||||
|
extern crate cross_crate;
|
||||||
|
|
||||||
|
use cross_crate::*;
|
||||||
|
|
||||||
|
fn non_const_context() {
|
||||||
|
NonConst.func();
|
||||||
|
Const.func();
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn const_context() {
|
||||||
|
NonConst.func();
|
||||||
|
//~^ ERROR: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
Const.func();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,9 @@
|
|||||||
|
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
--> $DIR/cross-crate-feature-enabled.rs:15:5
|
||||||
|
|
|
||||||
|
LL | NonConst.func();
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
Loading…
x
Reference in New Issue
Block a user