Skip to content

Commit a893c64

Browse files
committed
Expand internal-unstable to handle named field accesses and method calls.
1 parent 0f46e4f commit a893c64

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/test/auxiliary/internal_unstable.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ pub struct Foo {
2222
pub x: u8
2323
}
2424

25+
impl Foo {
26+
#[unstable(feature = "method")]
27+
pub fn method(&self) {}
28+
}
29+
30+
#[stable(feature = "stable", since = "1.0.0")]
31+
pub struct Bar {
32+
#[unstable(feature = "struct2_field")]
33+
pub x: u8
34+
}
35+
2536
#[allow_internal_unstable]
2637
#[macro_export]
2738
macro_rules! call_unstable_allow {
@@ -36,6 +47,18 @@ macro_rules! construct_unstable_allow {
3647
}
3748
}
3849

50+
#[allow_internal_unstable]
51+
#[macro_export]
52+
macro_rules! call_method_allow {
53+
($e: expr) => { $e.method() }
54+
}
55+
56+
#[allow_internal_unstable]
57+
#[macro_export]
58+
macro_rules! access_field_allow {
59+
($e: expr) => { $e.x }
60+
}
61+
3962
#[allow_internal_unstable]
4063
#[macro_export]
4164
macro_rules! pass_through_allow {
@@ -54,6 +77,16 @@ macro_rules! construct_unstable_noallow {
5477
}
5578
}
5679

80+
#[macro_export]
81+
macro_rules! call_method_noallow {
82+
($e: expr) => { $e.method() }
83+
}
84+
85+
#[macro_export]
86+
macro_rules! access_field_noallow {
87+
($e: expr) => { $e.x }
88+
}
89+
5790
#[macro_export]
5891
macro_rules! pass_through_noallow {
5992
($e: expr) => { $e }

src/test/compile-fail/internal-unstable-noallow.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// aux-build:internal_unstable.rs
1717
// error-pattern:use of unstable library feature 'function'
1818
// error-pattern:use of unstable library feature 'struct_field'
19+
// error-pattern:use of unstable library feature 'method'
20+
// error-pattern:use of unstable library feature 'struct2_field'
1921

2022
#[macro_use]
2123
extern crate internal_unstable;
@@ -24,4 +26,8 @@ fn main() {
2426
call_unstable_noallow!();
2527

2628
construct_unstable_noallow!(0);
29+
30+
|x: internal_unstable::Foo| { call_method_noallow!(x) };
31+
32+
|x: internal_unstable::Bar| { access_field_noallow!(x) };
2733
}

src/test/compile-fail/internal-unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ fn main() {
3636
// ok, the instability is contained.
3737
call_unstable_allow!();
3838
construct_unstable_allow!(0);
39+
|x: internal_unstable::Foo| { call_method_allow!(x) };
40+
|x: internal_unstable::Bar| { access_field_allow!(x) };
3941

4042
// bad.
4143
pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable

0 commit comments

Comments
 (0)