未验证 提交 ee9c614e 编写于 作者: D Deadbeef

Test for const trait impls behind feature gates

上级 b3a79832
#![feature(const_trait_impl)]
#![allow(incomplete_features)]
#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait MyTrait {
#[stable(feature = "rust1", since = "1.0.0")]
fn func();
}
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Unstable;
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "staged", issue = "none")]
impl const MyTrait for Unstable {
fn func() {
}
}
// revisions: stock staged
#![cfg_attr(staged, feature(staged))]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]
#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]
// aux-build: staged-api.rs
extern crate staged_api;
use staged_api::*;
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Stable;
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(staged, rustc_const_stable(feature = "rust1", since = "1.0.0"))]
// ^ should trigger error with or without the attribute
impl const MyTrait for Stable {
fn func() { //~ ERROR trait methods cannot be stable const fn
}
}
fn non_const_context() {
Unstable::func();
Stable::func();
}
#[unstable(feature = "none", issue = "none")]
const fn const_context() {
Unstable::func();
//[stock]~^ ERROR `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
Stable::func();
}
fn main() {}
error: trait methods cannot be stable const fn
--> $DIR/staged-api.rs:22:5
|
LL | / fn func() {
LL | |
LL | | }
| |_____^
error: aborting due to previous error
error: trait methods cannot be stable const fn
--> $DIR/staged-api.rs:22:5
|
LL | / fn func() {
LL | |
LL | | }
| |_____^
error: `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
--> $DIR/staged-api.rs:34:5
|
LL | Unstable::func();
| ^^^^^^^^^^^^^^^^
|
= help: add `#![feature(staged)]` to the crate attributes to enable
error: aborting due to 2 previous errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册