Expand internal-unstable to handle named field accesses and method calls.
This commit is contained in:
parent
0f46e4f1f2
commit
a893c646d0
@ -22,6 +22,17 @@ pub struct Foo {
|
||||
pub x: u8
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
#[unstable(feature = "method")]
|
||||
pub fn method(&self) {}
|
||||
}
|
||||
|
||||
#[stable(feature = "stable", since = "1.0.0")]
|
||||
pub struct Bar {
|
||||
#[unstable(feature = "struct2_field")]
|
||||
pub x: u8
|
||||
}
|
||||
|
||||
#[allow_internal_unstable]
|
||||
#[macro_export]
|
||||
macro_rules! call_unstable_allow {
|
||||
@ -36,6 +47,18 @@ macro_rules! construct_unstable_allow {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow_internal_unstable]
|
||||
#[macro_export]
|
||||
macro_rules! call_method_allow {
|
||||
($e: expr) => { $e.method() }
|
||||
}
|
||||
|
||||
#[allow_internal_unstable]
|
||||
#[macro_export]
|
||||
macro_rules! access_field_allow {
|
||||
($e: expr) => { $e.x }
|
||||
}
|
||||
|
||||
#[allow_internal_unstable]
|
||||
#[macro_export]
|
||||
macro_rules! pass_through_allow {
|
||||
@ -54,6 +77,16 @@ macro_rules! construct_unstable_noallow {
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! call_method_noallow {
|
||||
($e: expr) => { $e.method() }
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! access_field_noallow {
|
||||
($e: expr) => { $e.x }
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! pass_through_noallow {
|
||||
($e: expr) => { $e }
|
||||
|
@ -16,6 +16,8 @@
|
||||
// aux-build:internal_unstable.rs
|
||||
// error-pattern:use of unstable library feature 'function'
|
||||
// error-pattern:use of unstable library feature 'struct_field'
|
||||
// error-pattern:use of unstable library feature 'method'
|
||||
// error-pattern:use of unstable library feature 'struct2_field'
|
||||
|
||||
#[macro_use]
|
||||
extern crate internal_unstable;
|
||||
@ -24,4 +26,8 @@ fn main() {
|
||||
call_unstable_noallow!();
|
||||
|
||||
construct_unstable_noallow!(0);
|
||||
|
||||
|x: internal_unstable::Foo| { call_method_noallow!(x) };
|
||||
|
||||
|x: internal_unstable::Bar| { access_field_noallow!(x) };
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ fn main() {
|
||||
// ok, the instability is contained.
|
||||
call_unstable_allow!();
|
||||
construct_unstable_allow!(0);
|
||||
|x: internal_unstable::Foo| { call_method_allow!(x) };
|
||||
|x: internal_unstable::Bar| { access_field_allow!(x) };
|
||||
|
||||
// bad.
|
||||
pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable
|
||||
|
Loading…
Reference in New Issue
Block a user