diff options
| author | David Wood <david@davidtw.co> | 2018-08-08 14:50:16 +0200 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-08-14 11:12:09 +0200 |
| commit | 3fc7ab237314a4ce85e612b4ce590c27f1425291 (patch) | |
| tree | c775f852e05e1272032cb053ee347315c973c7b5 /src/test/ui/internal | |
| parent | 3e0a4079884eab5b54489c92f7428cda2797ea5c (diff) | |
Merged migrated compile-fail tests and ui tests. Fixes #46841.
Diffstat (limited to 'src/test/ui/internal')
| -rw-r--r-- | src/test/ui/internal/auxiliary/internal_unstable.rs | 102 | ||||
| -rw-r--r-- | src/test/ui/internal/internal-unstable-noallow.rs | 33 | ||||
| -rw-r--r-- | src/test/ui/internal/internal-unstable-noallow.stderr | 39 | ||||
| -rw-r--r-- | src/test/ui/internal/internal-unstable-thread-local.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/internal/internal-unstable-thread-local.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/internal/internal-unstable.rs | 52 | ||||
| -rw-r--r-- | src/test/ui/internal/internal-unstable.stderr | 46 |
7 files changed, 304 insertions, 0 deletions
diff --git a/src/test/ui/internal/auxiliary/internal_unstable.rs b/src/test/ui/internal/auxiliary/internal_unstable.rs new file mode 100644 index 00000000000..a4cd487eb65 --- /dev/null +++ b/src/test/ui/internal/auxiliary/internal_unstable.rs @@ -0,0 +1,102 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api, allow_internal_unstable)] +#![stable(feature = "stable", since = "1.0.0")] + +#[unstable(feature = "function", issue = "0")] +pub fn unstable() {} + + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Foo { + #[unstable(feature = "struct_field", issue = "0")] + pub x: u8 +} + +impl Foo { + #[unstable(feature = "method", issue = "0")] + pub fn method(&self) {} +} + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Bar { + #[unstable(feature = "struct2_field", issue = "0")] + pub x: u8 +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! call_unstable_allow { + () => { $crate::unstable() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! construct_unstable_allow { + ($e: expr) => { + $crate::Foo { x: $e } + } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! call_method_allow { + ($e: expr) => { $e.method() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! access_field_allow { + ($e: expr) => { $e.x } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! pass_through_allow { + ($e: expr) => { $e } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! call_unstable_noallow { + () => { $crate::unstable() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! construct_unstable_noallow { + ($e: expr) => { + $crate::Foo { x: $e } + } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! call_method_noallow { + ($e: expr) => { $e.method() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! access_field_noallow { + ($e: expr) => { $e.x } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! pass_through_noallow { + ($e: expr) => { $e } +} diff --git a/src/test/ui/internal/internal-unstable-noallow.rs b/src/test/ui/internal/internal-unstable-noallow.rs new file mode 100644 index 00000000000..2e42e9d3b01 --- /dev/null +++ b/src/test/ui/internal/internal-unstable-noallow.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// this has to be separate to internal-unstable.rs because these tests +// have error messages pointing deep into the internals of the +// cross-crate macros, and hence need to use error-pattern instead of +// the // ~ form. + +// 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; + +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/ui/internal/internal-unstable-noallow.stderr b/src/test/ui/internal/internal-unstable-noallow.stderr new file mode 100644 index 00000000000..fc8100525e9 --- /dev/null +++ b/src/test/ui/internal/internal-unstable-noallow.stderr @@ -0,0 +1,39 @@ +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable-noallow.rs:26:5 + | +LL | call_unstable_noallow!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'struct_field' + --> $DIR/internal-unstable-noallow.rs:28:5 + | +LL | construct_unstable_noallow!(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(struct_field)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'method' + --> $DIR/internal-unstable-noallow.rs:30:35 + | +LL | |x: internal_unstable::Foo| { call_method_noallow!(x) }; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(method)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'struct2_field' + --> $DIR/internal-unstable-noallow.rs:32:35 + | +LL | |x: internal_unstable::Bar| { access_field_noallow!(x) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(struct2_field)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/internal/internal-unstable-thread-local.rs b/src/test/ui/internal/internal-unstable-thread-local.rs new file mode 100644 index 00000000000..74526fb3d83 --- /dev/null +++ b/src/test/ui/internal/internal-unstable-thread-local.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:internal_unstable.rs + +#![allow(dead_code)] + +extern crate internal_unstable; + + +thread_local!(static FOO: () = ()); +thread_local!(static BAR: () = internal_unstable::unstable()); //~ ERROR use of unstable + +fn main() {} diff --git a/src/test/ui/internal/internal-unstable-thread-local.stderr b/src/test/ui/internal/internal-unstable-thread-local.stderr new file mode 100644 index 00000000000..b77b94663ff --- /dev/null +++ b/src/test/ui/internal/internal-unstable-thread-local.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable-thread-local.rs:19:32 + | +LL | thread_local!(static BAR: () = internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/internal/internal-unstable.rs b/src/test/ui/internal/internal-unstable.rs new file mode 100644 index 00000000000..e01259f0deb --- /dev/null +++ b/src/test/ui/internal/internal-unstable.rs @@ -0,0 +1,52 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:internal_unstable.rs + +#![feature(allow_internal_unstable)] + +#[macro_use] +extern crate internal_unstable; + +macro_rules! foo { + ($e: expr, $f: expr) => {{ + $e; + $f; + internal_unstable::unstable(); //~ ERROR use of unstable + }} +} + +#[allow_internal_unstable] +macro_rules! bar { + ($e: expr) => {{ + foo!($e, + internal_unstable::unstable()); + internal_unstable::unstable(); + }} +} + +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 + + pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable + + + + println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable + + bar!(internal_unstable::unstable()); //~ ERROR use of unstable +} diff --git a/src/test/ui/internal/internal-unstable.stderr b/src/test/ui/internal/internal-unstable.stderr new file mode 100644 index 00000000000..ec4f0725c34 --- /dev/null +++ b/src/test/ui/internal/internal-unstable.stderr @@ -0,0 +1,46 @@ +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:43:25 + | +LL | pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:45:27 + | +LL | pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:49:22 + | +LL | println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:51:10 + | +LL | bar!(internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:22:9 + | +LL | internal_unstable::unstable(); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | bar!(internal_unstable::unstable()); //~ ERROR use of unstable + | ------------------------------------ in this macro invocation + | + = help: add #![feature(function)] to the crate attributes to enable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0658`. |
