diff --git a/src/test/auxiliary/internal_unstable.rs b/src/test/auxiliary/internal_unstable.rs index 3d59b8e9009..7f682d5d8d1 100644 --- a/src/test/auxiliary/internal_unstable.rs +++ b/src/test/auxiliary/internal_unstable.rs @@ -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 } diff --git a/src/test/compile-fail/internal-unstable-noallow.rs b/src/test/compile-fail/internal-unstable-noallow.rs index 2b48d47e940..2e42e9d3b01 100644 --- a/src/test/compile-fail/internal-unstable-noallow.rs +++ b/src/test/compile-fail/internal-unstable-noallow.rs @@ -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) }; } diff --git a/src/test/compile-fail/internal-unstable.rs b/src/test/compile-fail/internal-unstable.rs index accc898b8a8..e01259f0deb 100755 --- a/src/test/compile-fail/internal-unstable.rs +++ b/src/test/compile-fail/internal-unstable.rs @@ -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