From 09940635d58804bbe913202b19ded0d2a27c7c05 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Mon, 9 Jun 2025 01:39:32 +0500 Subject: cleaned up some tests --- tests/ui/auxiliary/pub-and-stability.rs | 133 ---------------- tests/ui/box/empty-alloc-deref-rvalue.rs | 10 ++ tests/ui/derives/copy-drop-mutually-exclusive.rs | 17 ++ .../ui/derives/copy-drop-mutually-exclusive.stderr | 15 ++ tests/ui/empty-allocation-rvalue-non-null.rs | 7 - tests/ui/empty-type-parameter-list.rs | 24 --- tests/ui/empty-type-parameter-list.stderr | 10 -- tests/ui/error-should-say-copy-not-pod.rs | 7 - tests/ui/error-should-say-copy-not-pod.stderr | 22 --- tests/ui/exclusive-drop-and-copy.rs | 17 -- tests/ui/exclusive-drop-and-copy.stderr | 15 -- tests/ui/explicit-i-suffix.rs | 13 -- tests/ui/explore-issue-38412.rs | 64 -------- tests/ui/explore-issue-38412.stderr | 176 --------------------- tests/ui/ext-expand-inner-exprs.rs | 7 - tests/ui/ext-nonexistent.rs | 2 - tests/ui/ext-nonexistent.stderr | 8 - tests/ui/fact.rs | 26 --- tests/ui/generics/empty-generic-brackets-equiv.rs | 27 ++++ .../generics/empty-generic-brackets-equiv.stderr | 10 ++ tests/ui/macros/nested-macro-expansion.rs | 9 ++ tests/ui/resolve/nonexistent-macro.rs | 6 + tests/ui/resolve/nonexistent-macro.stderr | 8 + .../auxiliary/pub-and-stability.rs | 133 ++++++++++++++++ .../stability-privacy-interaction.rs | 78 +++++++++ .../stability-privacy-interaction.stderr | 176 +++++++++++++++++++++ 26 files changed, 489 insertions(+), 531 deletions(-) delete mode 100644 tests/ui/auxiliary/pub-and-stability.rs create mode 100644 tests/ui/box/empty-alloc-deref-rvalue.rs create mode 100644 tests/ui/derives/copy-drop-mutually-exclusive.rs create mode 100644 tests/ui/derives/copy-drop-mutually-exclusive.stderr delete mode 100644 tests/ui/empty-allocation-rvalue-non-null.rs delete mode 100644 tests/ui/empty-type-parameter-list.rs delete mode 100644 tests/ui/empty-type-parameter-list.stderr delete mode 100644 tests/ui/error-should-say-copy-not-pod.rs delete mode 100644 tests/ui/error-should-say-copy-not-pod.stderr delete mode 100644 tests/ui/exclusive-drop-and-copy.rs delete mode 100644 tests/ui/exclusive-drop-and-copy.stderr delete mode 100644 tests/ui/explicit-i-suffix.rs delete mode 100644 tests/ui/explore-issue-38412.rs delete mode 100644 tests/ui/explore-issue-38412.stderr delete mode 100644 tests/ui/ext-expand-inner-exprs.rs delete mode 100644 tests/ui/ext-nonexistent.rs delete mode 100644 tests/ui/ext-nonexistent.stderr delete mode 100644 tests/ui/fact.rs create mode 100644 tests/ui/generics/empty-generic-brackets-equiv.rs create mode 100644 tests/ui/generics/empty-generic-brackets-equiv.stderr create mode 100644 tests/ui/macros/nested-macro-expansion.rs create mode 100644 tests/ui/resolve/nonexistent-macro.rs create mode 100644 tests/ui/resolve/nonexistent-macro.stderr create mode 100644 tests/ui/stability-attribute/auxiliary/pub-and-stability.rs create mode 100644 tests/ui/stability-attribute/stability-privacy-interaction.rs create mode 100644 tests/ui/stability-attribute/stability-privacy-interaction.stderr diff --git a/tests/ui/auxiliary/pub-and-stability.rs b/tests/ui/auxiliary/pub-and-stability.rs deleted file mode 100644 index 8866233b61e..00000000000 --- a/tests/ui/auxiliary/pub-and-stability.rs +++ /dev/null @@ -1,133 +0,0 @@ -// This crate attempts to enumerate the various scenarios for how a -// type can define fields and methods with various visibilities and -// stabilities. -// -// The basic stability pattern in this file has four cases: -// 1. no stability attribute at all -// 2. a stable attribute (feature "unit_test") -// 3. an unstable attribute that unit test enables (feature "unstable_declared") -// 4. an unstable attribute that unit test fails to enable (feature "unstable_undeclared") -// -// This file also covers four kinds of visibility: private, -// pub(module), pub(crate), and pub. -// -// However, since stability attributes can only be observed in -// cross-crate linkage scenarios, there is little reason to take the -// cross-product (4 stability cases * 4 visibility cases), because the -// first three visibility cases cannot be accessed outside this crate, -// and therefore stability is only relevant when the visibility is pub -// to the whole universe. -// -// (The only reason to do so would be if one were worried about the -// compiler having some subtle bug where adding a stability attribute -// introduces a privacy violation. As a way to provide evidence that -// this is not occurring, I have put stability attributes on some -// non-pub fields, marked with SILLY below) - -#![feature(staged_api)] - -#![stable(feature = "unit_test", since = "1.0.0")] - -#[stable(feature = "unit_test", since = "1.0.0")] -pub use m::{Record, Trait, Tuple}; - -mod m { - #[derive(Default)] - #[stable(feature = "unit_test", since = "1.0.0")] - pub struct Record { - #[stable(feature = "unit_test", since = "1.0.0")] - pub a_stable_pub: i32, - #[unstable(feature = "unstable_declared", issue = "38412")] - pub a_unstable_declared_pub: i32, - #[unstable(feature = "unstable_undeclared", issue = "38412")] - pub a_unstable_undeclared_pub: i32, - #[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY - pub(crate) b_crate: i32, - #[unstable(feature = "unstable_declared", issue = "38412")] // SILLY - pub(in crate::m) c_mod: i32, - #[stable(feature = "unit_test", since = "1.0.0")] // SILLY - d_priv: i32 - } - - #[derive(Default)] - #[stable(feature = "unit_test", since = "1.0.0")] - pub struct Tuple( - #[stable(feature = "unit_test", since = "1.0.0")] - pub i32, - #[unstable(feature = "unstable_declared", issue = "38412")] - pub i32, - #[unstable(feature = "unstable_undeclared", issue = "38412")] - pub i32, - - pub(crate) i32, - pub(in crate::m) i32, - i32); - - impl Record { - #[stable(feature = "unit_test", since = "1.0.0")] - pub fn new() -> Self { Default::default() } - } - - impl Tuple { - #[stable(feature = "unit_test", since = "1.0.0")] - pub fn new() -> Self { Default::default() } - } - - - #[stable(feature = "unit_test", since = "1.0.0")] - pub trait Trait { - #[stable(feature = "unit_test", since = "1.0.0")] - type Type; - #[stable(feature = "unit_test", since = "1.0.0")] - fn stable_trait_method(&self) -> Self::Type; - #[unstable(feature = "unstable_undeclared", issue = "38412")] - fn unstable_undeclared_trait_method(&self) -> Self::Type; - #[unstable(feature = "unstable_declared", issue = "38412")] - fn unstable_declared_trait_method(&self) -> Self::Type; - } - - #[stable(feature = "unit_test", since = "1.0.0")] - impl Trait for Record { - type Type = i32; - fn stable_trait_method(&self) -> i32 { self.d_priv } - fn unstable_undeclared_trait_method(&self) -> i32 { self.d_priv } - fn unstable_declared_trait_method(&self) -> i32 { self.d_priv } - } - - #[stable(feature = "unit_test", since = "1.0.0")] - impl Trait for Tuple { - type Type = i32; - fn stable_trait_method(&self) -> i32 { self.3 } - fn unstable_undeclared_trait_method(&self) -> i32 { self.3 } - fn unstable_declared_trait_method(&self) -> i32 { self.3 } - } - - impl Record { - #[unstable(feature = "unstable_undeclared", issue = "38412")] - pub fn unstable_undeclared(&self) -> i32 { self.d_priv } - #[unstable(feature = "unstable_declared", issue = "38412")] - pub fn unstable_declared(&self) -> i32 { self.d_priv } - #[stable(feature = "unit_test", since = "1.0.0")] - pub fn stable(&self) -> i32 { self.d_priv } - - #[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY - pub(crate) fn pub_crate(&self) -> i32 { self.d_priv } - #[unstable(feature = "unstable_declared", issue = "38412")] // SILLY - pub(in crate::m) fn pub_mod(&self) -> i32 { self.d_priv } - #[stable(feature = "unit_test", since = "1.0.0")] // SILLY - fn private(&self) -> i32 { self.d_priv } - } - - impl Tuple { - #[unstable(feature = "unstable_undeclared", issue = "38412")] - pub fn unstable_undeclared(&self) -> i32 { self.0 } - #[unstable(feature = "unstable_declared", issue = "38412")] - pub fn unstable_declared(&self) -> i32 { self.0 } - #[stable(feature = "unit_test", since = "1.0.0")] - pub fn stable(&self) -> i32 { self.0 } - - pub(crate) fn pub_crate(&self) -> i32 { self.0 } - pub(in crate::m) fn pub_mod(&self) -> i32 { self.0 } - fn private(&self) -> i32 { self.0 } - } -} diff --git a/tests/ui/box/empty-alloc-deref-rvalue.rs b/tests/ui/box/empty-alloc-deref-rvalue.rs new file mode 100644 index 00000000000..507a753467a --- /dev/null +++ b/tests/ui/box/empty-alloc-deref-rvalue.rs @@ -0,0 +1,10 @@ +//! Smoke test: dereferencing boxed zero-sized types (ZSTs) should not crash. +//! +//! Originally a regression test of github.com/rust-lang/rust/issues/13360 +//! but repurposed for a smoke test. + +//@ run-pass + +pub fn main() { + let _: () = *Box::new(()); +} diff --git a/tests/ui/derives/copy-drop-mutually-exclusive.rs b/tests/ui/derives/copy-drop-mutually-exclusive.rs new file mode 100644 index 00000000000..5147605910d --- /dev/null +++ b/tests/ui/derives/copy-drop-mutually-exclusive.rs @@ -0,0 +1,17 @@ +//! Regression test for issue #20126: Copy and Drop traits are mutually exclusive + +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) {} +} + +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented +struct Bar(::std::marker::PhantomData); + +impl Drop for Bar { + fn drop(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/derives/copy-drop-mutually-exclusive.stderr b/tests/ui/derives/copy-drop-mutually-exclusive.stderr new file mode 100644 index 00000000000..771bbc92569 --- /dev/null +++ b/tests/ui/derives/copy-drop-mutually-exclusive.stderr @@ -0,0 +1,15 @@ +error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor + --> $DIR/copy-drop-mutually-exclusive.rs:3:10 + | +LL | #[derive(Copy, Clone)] + | ^^^^ `Copy` not allowed on types with destructors + +error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor + --> $DIR/copy-drop-mutually-exclusive.rs:10:10 + | +LL | #[derive(Copy, Clone)] + | ^^^^ `Copy` not allowed on types with destructors + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0184`. diff --git a/tests/ui/empty-allocation-rvalue-non-null.rs b/tests/ui/empty-allocation-rvalue-non-null.rs deleted file mode 100644 index 0cd4fde73ed..00000000000 --- a/tests/ui/empty-allocation-rvalue-non-null.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -#![allow(unused_variables)] - -pub fn main() { - let x: () = *Box::new(()); -} diff --git a/tests/ui/empty-type-parameter-list.rs b/tests/ui/empty-type-parameter-list.rs deleted file mode 100644 index e8d6b2a9964..00000000000 --- a/tests/ui/empty-type-parameter-list.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass -// Test that empty type parameter list (<>) is synonymous with -// no type parameters at all - -struct S<>; -trait T<> {} //~ WARN trait `T` is never used -enum E<> { V } -impl<> T<> for S<> {} -impl T for E {} -fn foo<>() {} -fn bar() {} - -fn main() { - let _ = S; - let _ = S::<>; - let _ = E::V; - let _ = E::<>::V; - foo(); - foo::<>(); - - // Test that we can supply <> to non generic things - bar::<>(); - let _: i32<>; -} diff --git a/tests/ui/empty-type-parameter-list.stderr b/tests/ui/empty-type-parameter-list.stderr deleted file mode 100644 index 31a5015e993..00000000000 --- a/tests/ui/empty-type-parameter-list.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: trait `T` is never used - --> $DIR/empty-type-parameter-list.rs:6:7 - | -LL | trait T<> {} - | ^ - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/error-should-say-copy-not-pod.rs b/tests/ui/error-should-say-copy-not-pod.rs deleted file mode 100644 index 40c4730ef69..00000000000 --- a/tests/ui/error-should-say-copy-not-pod.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Tests that the error message uses the word Copy, not Pod. - -fn check_bound(_: T) {} - -fn main() { - check_bound("nocopy".to_string()); //~ ERROR : Copy` is not satisfied -} diff --git a/tests/ui/error-should-say-copy-not-pod.stderr b/tests/ui/error-should-say-copy-not-pod.stderr deleted file mode 100644 index 6aa129fa29b..00000000000 --- a/tests/ui/error-should-say-copy-not-pod.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/error-should-say-copy-not-pod.rs:6:17 - | -LL | check_bound("nocopy".to_string()); - | ----------- ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_bound` - --> $DIR/error-should-say-copy-not-pod.rs:3:18 - | -LL | fn check_bound(_: T) {} - | ^^^^ required by this bound in `check_bound` -help: consider removing this method call, as the receiver has type `&'static str` and `&'static str: Copy` trivially holds - | -LL - check_bound("nocopy".to_string()); -LL + check_bound("nocopy"); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/exclusive-drop-and-copy.rs b/tests/ui/exclusive-drop-and-copy.rs deleted file mode 100644 index 210ecaed756..00000000000 --- a/tests/ui/exclusive-drop-and-copy.rs +++ /dev/null @@ -1,17 +0,0 @@ -// issue #20126 - -#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) {} -} - -#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented -struct Bar(::std::marker::PhantomData); - -impl Drop for Bar { - fn drop(&mut self) {} -} - -fn main() {} diff --git a/tests/ui/exclusive-drop-and-copy.stderr b/tests/ui/exclusive-drop-and-copy.stderr deleted file mode 100644 index 340ca89c396..00000000000 --- a/tests/ui/exclusive-drop-and-copy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor - --> $DIR/exclusive-drop-and-copy.rs:3:10 - | -LL | #[derive(Copy, Clone)] - | ^^^^ `Copy` not allowed on types with destructors - -error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor - --> $DIR/exclusive-drop-and-copy.rs:10:10 - | -LL | #[derive(Copy, Clone)] - | ^^^^ `Copy` not allowed on types with destructors - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0184`. diff --git a/tests/ui/explicit-i-suffix.rs b/tests/ui/explicit-i-suffix.rs deleted file mode 100644 index 0a6ed49ae27..00000000000 --- a/tests/ui/explicit-i-suffix.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(unused_must_use)] - -pub fn main() { - let x: isize = 8; - let y = 9; - x + y; - - let q: isize = -8; - let r = -9; - q + r; -} diff --git a/tests/ui/explore-issue-38412.rs b/tests/ui/explore-issue-38412.rs deleted file mode 100644 index 2008b120faa..00000000000 --- a/tests/ui/explore-issue-38412.rs +++ /dev/null @@ -1,64 +0,0 @@ -//@ aux-build:pub-and-stability.rs - -// A big point of this test is that we *enable* `unstable_declared`, -// but do *not* enable `unstable_undeclared`. This way we can check -// that the compiler is letting in uses of enabled feature-gated -// stuff but still rejecting uses of disabled feature-gated stuff. -#![feature(unstable_declared)] - -extern crate pub_and_stability; -use pub_and_stability::{Record, Trait, Tuple}; - -fn main() { - // Okay - let Record { .. } = Record::new(); - - // Okay - let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new(); - - let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } = - Record::new(); - //~^^ ERROR use of unstable library feature `unstable_undeclared` - - let r = Record::new(); - let t = Tuple::new(); - - r.a_stable_pub; - r.a_unstable_declared_pub; - r.a_unstable_undeclared_pub; //~ ERROR use of unstable library feature - r.b_crate; //~ ERROR is private - r.c_mod; //~ ERROR is private - r.d_priv; //~ ERROR is private - - t.0; - t.1; - t.2; //~ ERROR use of unstable library feature - t.3; //~ ERROR is private - t.4; //~ ERROR is private - t.5; //~ ERROR is private - - r.stable_trait_method(); - r.unstable_declared_trait_method(); - r.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature - - r.stable(); - r.unstable_declared(); - r.unstable_undeclared(); //~ ERROR use of unstable library feature - - r.pub_crate(); //~ ERROR `pub_crate` is private - r.pub_mod(); //~ ERROR `pub_mod` is private - r.private(); //~ ERROR `private` is private - - let t = Tuple::new(); - t.stable_trait_method(); - t.unstable_declared_trait_method(); - t.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature - - t.stable(); - t.unstable_declared(); - t.unstable_undeclared(); //~ ERROR use of unstable library feature - - t.pub_crate(); //~ ERROR `pub_crate` is private - t.pub_mod(); //~ ERROR `pub_mod` is private - t.private(); //~ ERROR `private` is private -} diff --git a/tests/ui/explore-issue-38412.stderr b/tests/ui/explore-issue-38412.stderr deleted file mode 100644 index fca5c738d27..00000000000 --- a/tests/ui/explore-issue-38412.stderr +++ /dev/null @@ -1,176 +0,0 @@ -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:19:63 - | -LL | let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:28:5 - | -LL | r.a_unstable_undeclared_pub; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0616]: field `b_crate` of struct `Record` is private - --> $DIR/explore-issue-38412.rs:29:7 - | -LL | r.b_crate; - | ^^^^^^^ private field - -error[E0616]: field `c_mod` of struct `Record` is private - --> $DIR/explore-issue-38412.rs:30:7 - | -LL | r.c_mod; - | ^^^^^ private field - -error[E0616]: field `d_priv` of struct `Record` is private - --> $DIR/explore-issue-38412.rs:31:7 - | -LL | r.d_priv; - | ^^^^^^ private field - -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:35:5 - | -LL | t.2; - | ^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0616]: field `3` of struct `pub_and_stability::Tuple` is private - --> $DIR/explore-issue-38412.rs:36:7 - | -LL | t.3; - | ^ private field - -error[E0616]: field `4` of struct `pub_and_stability::Tuple` is private - --> $DIR/explore-issue-38412.rs:37:7 - | -LL | t.4; - | ^ private field - -error[E0616]: field `5` of struct `pub_and_stability::Tuple` is private - --> $DIR/explore-issue-38412.rs:38:7 - | -LL | t.5; - | ^ private field - -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:42:7 - | -LL | r.unstable_undeclared_trait_method(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:46:7 - | -LL | r.unstable_undeclared(); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0624]: method `pub_crate` is private - --> $DIR/explore-issue-38412.rs:48:7 - | -LL | r.pub_crate(); - | ^^^^^^^^^ private method - | - ::: $DIR/auxiliary/pub-and-stability.rs:114:9 - | -LL | pub(crate) fn pub_crate(&self) -> i32 { self.d_priv } - | ------------------------------------- private method defined here - -error[E0624]: method `pub_mod` is private - --> $DIR/explore-issue-38412.rs:49:7 - | -LL | r.pub_mod(); - | ^^^^^^^ private method - | - ::: $DIR/auxiliary/pub-and-stability.rs:116:9 - | -LL | pub(in crate::m) fn pub_mod(&self) -> i32 { self.d_priv } - | ----------------------------------------- private method defined here - -error[E0624]: method `private` is private - --> $DIR/explore-issue-38412.rs:50:7 - | -LL | r.private(); - | ^^^^^^^ private method - | - ::: $DIR/auxiliary/pub-and-stability.rs:118:9 - | -LL | fn private(&self) -> i32 { self.d_priv } - | ------------------------ private method defined here - -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:55:7 - | -LL | t.unstable_undeclared_trait_method(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:59:7 - | -LL | t.unstable_undeclared(); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #38412 for more information - = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0624]: method `pub_crate` is private - --> $DIR/explore-issue-38412.rs:61:7 - | -LL | t.pub_crate(); - | ^^^^^^^^^ private method - | - ::: $DIR/auxiliary/pub-and-stability.rs:129:9 - | -LL | pub(crate) fn pub_crate(&self) -> i32 { self.0 } - | ------------------------------------- private method defined here - -error[E0624]: method `pub_mod` is private - --> $DIR/explore-issue-38412.rs:62:7 - | -LL | t.pub_mod(); - | ^^^^^^^ private method - | - ::: $DIR/auxiliary/pub-and-stability.rs:130:9 - | -LL | pub(in crate::m) fn pub_mod(&self) -> i32 { self.0 } - | ----------------------------------------- private method defined here - -error[E0624]: method `private` is private - --> $DIR/explore-issue-38412.rs:63:7 - | -LL | t.private(); - | ^^^^^^^ private method - | - ::: $DIR/auxiliary/pub-and-stability.rs:131:9 - | -LL | fn private(&self) -> i32 { self.0 } - | ------------------------ private method defined here - -error: aborting due to 19 previous errors - -Some errors have detailed explanations: E0616, E0624, E0658. -For more information about an error, try `rustc --explain E0616`. diff --git a/tests/ui/ext-expand-inner-exprs.rs b/tests/ui/ext-expand-inner-exprs.rs deleted file mode 100644 index 94610d0a328..00000000000 --- a/tests/ui/ext-expand-inner-exprs.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -static FOO : &'static str = concat!(concat!("hel", "lo"), "world"); - -pub fn main() { - assert_eq!(FOO, "helloworld"); -} diff --git a/tests/ui/ext-nonexistent.rs b/tests/ui/ext-nonexistent.rs deleted file mode 100644 index 1293324b67e..00000000000 --- a/tests/ui/ext-nonexistent.rs +++ /dev/null @@ -1,2 +0,0 @@ -fn main() { iamnotanextensionthatexists!(""); } -//~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope diff --git a/tests/ui/ext-nonexistent.stderr b/tests/ui/ext-nonexistent.stderr deleted file mode 100644 index edb59bba6e5..00000000000 --- a/tests/ui/ext-nonexistent.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: cannot find macro `iamnotanextensionthatexists` in this scope - --> $DIR/ext-nonexistent.rs:1:13 - | -LL | fn main() { iamnotanextensionthatexists!(""); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/fact.rs b/tests/ui/fact.rs deleted file mode 100644 index e94c12da013..00000000000 --- a/tests/ui/fact.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass - -fn f(x: isize) -> isize { - // println!("in f:"); - - println!("{}", x); - if x == 1 { - // println!("bottoming out"); - - return 1; - } else { - // println!("recurring"); - - let y: isize = x * f(x - 1); - // println!("returned"); - - println!("{}", y); - return y; - } -} - -pub fn main() { - assert_eq!(f(5), 120); - // println!("all done"); - -} diff --git a/tests/ui/generics/empty-generic-brackets-equiv.rs b/tests/ui/generics/empty-generic-brackets-equiv.rs new file mode 100644 index 00000000000..d84498a60f8 --- /dev/null +++ b/tests/ui/generics/empty-generic-brackets-equiv.rs @@ -0,0 +1,27 @@ +//! Test that empty type parameter list <> is equivalent to no type parameters +//! +//! Checks` that empty angle brackets <> are syntactically valid and equivalent +//! to omitting type parameters entirely across various language constructs. + +//@ run-pass + +struct S<>; +trait T<> {} //~ WARN trait `T` is never used +enum E<> { + V +} +impl<> T<> for S<> {} +impl T for E {} +fn foo<>() {} +fn bar() {} +fn main() { + let _ = S; + let _ = S::<>; + let _ = E::V; + let _ = E::<>::V; + foo(); + foo::<>(); + // Test that we can supply <> to non-generic things + bar::<>(); + let _: i32<>; +} diff --git a/tests/ui/generics/empty-generic-brackets-equiv.stderr b/tests/ui/generics/empty-generic-brackets-equiv.stderr new file mode 100644 index 00000000000..151ee4697b4 --- /dev/null +++ b/tests/ui/generics/empty-generic-brackets-equiv.stderr @@ -0,0 +1,10 @@ +warning: trait `T` is never used + --> $DIR/empty-generic-brackets-equiv.rs:9:7 + | +LL | trait T<> {} + | ^ + | + = note: `#[warn(dead_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/macros/nested-macro-expansion.rs b/tests/ui/macros/nested-macro-expansion.rs new file mode 100644 index 00000000000..3b94b1051c9 --- /dev/null +++ b/tests/ui/macros/nested-macro-expansion.rs @@ -0,0 +1,9 @@ +//! Test nested macro expansion with concat! macros + +//@ run-pass + +static FOO : &'static str = concat!(concat!("hel", "lo"), "world"); + +pub fn main() { + assert_eq!(FOO, "helloworld"); +} diff --git a/tests/ui/resolve/nonexistent-macro.rs b/tests/ui/resolve/nonexistent-macro.rs new file mode 100644 index 00000000000..663075473a1 --- /dev/null +++ b/tests/ui/resolve/nonexistent-macro.rs @@ -0,0 +1,6 @@ +//! Test error handling for undefined macro calls + +fn main() { + iamnotanextensionthatexists!(""); + //~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope +} diff --git a/tests/ui/resolve/nonexistent-macro.stderr b/tests/ui/resolve/nonexistent-macro.stderr new file mode 100644 index 00000000000..7e89e07bf30 --- /dev/null +++ b/tests/ui/resolve/nonexistent-macro.stderr @@ -0,0 +1,8 @@ +error: cannot find macro `iamnotanextensionthatexists` in this scope + --> $DIR/nonexistent-macro.rs:4:5 + | +LL | iamnotanextensionthatexists!(""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/stability-attribute/auxiliary/pub-and-stability.rs b/tests/ui/stability-attribute/auxiliary/pub-and-stability.rs new file mode 100644 index 00000000000..8866233b61e --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/pub-and-stability.rs @@ -0,0 +1,133 @@ +// This crate attempts to enumerate the various scenarios for how a +// type can define fields and methods with various visibilities and +// stabilities. +// +// The basic stability pattern in this file has four cases: +// 1. no stability attribute at all +// 2. a stable attribute (feature "unit_test") +// 3. an unstable attribute that unit test enables (feature "unstable_declared") +// 4. an unstable attribute that unit test fails to enable (feature "unstable_undeclared") +// +// This file also covers four kinds of visibility: private, +// pub(module), pub(crate), and pub. +// +// However, since stability attributes can only be observed in +// cross-crate linkage scenarios, there is little reason to take the +// cross-product (4 stability cases * 4 visibility cases), because the +// first three visibility cases cannot be accessed outside this crate, +// and therefore stability is only relevant when the visibility is pub +// to the whole universe. +// +// (The only reason to do so would be if one were worried about the +// compiler having some subtle bug where adding a stability attribute +// introduces a privacy violation. As a way to provide evidence that +// this is not occurring, I have put stability attributes on some +// non-pub fields, marked with SILLY below) + +#![feature(staged_api)] + +#![stable(feature = "unit_test", since = "1.0.0")] + +#[stable(feature = "unit_test", since = "1.0.0")] +pub use m::{Record, Trait, Tuple}; + +mod m { + #[derive(Default)] + #[stable(feature = "unit_test", since = "1.0.0")] + pub struct Record { + #[stable(feature = "unit_test", since = "1.0.0")] + pub a_stable_pub: i32, + #[unstable(feature = "unstable_declared", issue = "38412")] + pub a_unstable_declared_pub: i32, + #[unstable(feature = "unstable_undeclared", issue = "38412")] + pub a_unstable_undeclared_pub: i32, + #[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY + pub(crate) b_crate: i32, + #[unstable(feature = "unstable_declared", issue = "38412")] // SILLY + pub(in crate::m) c_mod: i32, + #[stable(feature = "unit_test", since = "1.0.0")] // SILLY + d_priv: i32 + } + + #[derive(Default)] + #[stable(feature = "unit_test", since = "1.0.0")] + pub struct Tuple( + #[stable(feature = "unit_test", since = "1.0.0")] + pub i32, + #[unstable(feature = "unstable_declared", issue = "38412")] + pub i32, + #[unstable(feature = "unstable_undeclared", issue = "38412")] + pub i32, + + pub(crate) i32, + pub(in crate::m) i32, + i32); + + impl Record { + #[stable(feature = "unit_test", since = "1.0.0")] + pub fn new() -> Self { Default::default() } + } + + impl Tuple { + #[stable(feature = "unit_test", since = "1.0.0")] + pub fn new() -> Self { Default::default() } + } + + + #[stable(feature = "unit_test", since = "1.0.0")] + pub trait Trait { + #[stable(feature = "unit_test", since = "1.0.0")] + type Type; + #[stable(feature = "unit_test", since = "1.0.0")] + fn stable_trait_method(&self) -> Self::Type; + #[unstable(feature = "unstable_undeclared", issue = "38412")] + fn unstable_undeclared_trait_method(&self) -> Self::Type; + #[unstable(feature = "unstable_declared", issue = "38412")] + fn unstable_declared_trait_method(&self) -> Self::Type; + } + + #[stable(feature = "unit_test", since = "1.0.0")] + impl Trait for Record { + type Type = i32; + fn stable_trait_method(&self) -> i32 { self.d_priv } + fn unstable_undeclared_trait_method(&self) -> i32 { self.d_priv } + fn unstable_declared_trait_method(&self) -> i32 { self.d_priv } + } + + #[stable(feature = "unit_test", since = "1.0.0")] + impl Trait for Tuple { + type Type = i32; + fn stable_trait_method(&self) -> i32 { self.3 } + fn unstable_undeclared_trait_method(&self) -> i32 { self.3 } + fn unstable_declared_trait_method(&self) -> i32 { self.3 } + } + + impl Record { + #[unstable(feature = "unstable_undeclared", issue = "38412")] + pub fn unstable_undeclared(&self) -> i32 { self.d_priv } + #[unstable(feature = "unstable_declared", issue = "38412")] + pub fn unstable_declared(&self) -> i32 { self.d_priv } + #[stable(feature = "unit_test", since = "1.0.0")] + pub fn stable(&self) -> i32 { self.d_priv } + + #[unstable(feature = "unstable_undeclared", issue = "38412")] // SILLY + pub(crate) fn pub_crate(&self) -> i32 { self.d_priv } + #[unstable(feature = "unstable_declared", issue = "38412")] // SILLY + pub(in crate::m) fn pub_mod(&self) -> i32 { self.d_priv } + #[stable(feature = "unit_test", since = "1.0.0")] // SILLY + fn private(&self) -> i32 { self.d_priv } + } + + impl Tuple { + #[unstable(feature = "unstable_undeclared", issue = "38412")] + pub fn unstable_undeclared(&self) -> i32 { self.0 } + #[unstable(feature = "unstable_declared", issue = "38412")] + pub fn unstable_declared(&self) -> i32 { self.0 } + #[stable(feature = "unit_test", since = "1.0.0")] + pub fn stable(&self) -> i32 { self.0 } + + pub(crate) fn pub_crate(&self) -> i32 { self.0 } + pub(in crate::m) fn pub_mod(&self) -> i32 { self.0 } + fn private(&self) -> i32 { self.0 } + } +} diff --git a/tests/ui/stability-attribute/stability-privacy-interaction.rs b/tests/ui/stability-attribute/stability-privacy-interaction.rs new file mode 100644 index 00000000000..e02816ae1e7 --- /dev/null +++ b/tests/ui/stability-attribute/stability-privacy-interaction.rs @@ -0,0 +1,78 @@ +//! Regression test for issue #38412: interaction between stability attributes and privacy +//! +//! Tests that the compiler correctly handles the interaction between feature gates +//! and privacy/visibility rules. Specifically verifies that enabled unstable features +//! are accessible while disabled ones are properly rejected. + +//@ aux-build:pub-and-stability.rs + +// Enable `unstable_declared` but not `unstable_undeclared` to test +// that the compiler allows enabled features but rejects disabled ones +#![feature(unstable_declared)] + +extern crate pub_and_stability; +use pub_and_stability::{Record, Trait, Tuple}; + +fn main() { + // Test struct field access patterns + let Record { .. } = Record::new(); + + let Record { + a_stable_pub: _, + a_unstable_declared_pub: _, + .. + } = Record::new(); + + let Record { + a_stable_pub: _, + a_unstable_declared_pub: _, + a_unstable_undeclared_pub: _, //~ ERROR use of unstable library feature `unstable_undeclared` + .. + } = Record::new(); + + let r = Record::new(); + let t = Tuple::new(); + + // Test field access with different stability/privacy combinations + r.a_stable_pub; + r.a_unstable_declared_pub; + r.a_unstable_undeclared_pub; //~ ERROR use of unstable library feature + r.b_crate; //~ ERROR is private + r.c_mod; //~ ERROR is private + r.d_priv; //~ ERROR is private + + t.0; + t.1; + t.2; //~ ERROR use of unstable library feature + t.3; //~ ERROR is private + t.4; //~ ERROR is private + t.5; //~ ERROR is private + + // Test trait method access + r.stable_trait_method(); + r.unstable_declared_trait_method(); + r.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature + + // Test inherent method access + r.stable(); + r.unstable_declared(); + r.unstable_undeclared(); //~ ERROR use of unstable library feature + + r.pub_crate(); //~ ERROR `pub_crate` is private + r.pub_mod(); //~ ERROR `pub_mod` is private + r.private(); //~ ERROR `private` is private + + // Repeat tests for tuple struct + let t = Tuple::new(); + t.stable_trait_method(); + t.unstable_declared_trait_method(); + t.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature + + t.stable(); + t.unstable_declared(); + t.unstable_undeclared(); //~ ERROR use of unstable library feature + + t.pub_crate(); //~ ERROR `pub_crate` is private + t.pub_mod(); //~ ERROR `pub_mod` is private + t.private(); //~ ERROR `private` is private +} diff --git a/tests/ui/stability-attribute/stability-privacy-interaction.stderr b/tests/ui/stability-attribute/stability-privacy-interaction.stderr new file mode 100644 index 00000000000..991b3dbe019 --- /dev/null +++ b/tests/ui/stability-attribute/stability-privacy-interaction.stderr @@ -0,0 +1,176 @@ +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:29:9 + | +LL | a_unstable_undeclared_pub: _, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:39:5 + | +LL | r.a_unstable_undeclared_pub; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0616]: field `b_crate` of struct `Record` is private + --> $DIR/stability-privacy-interaction.rs:40:7 + | +LL | r.b_crate; + | ^^^^^^^ private field + +error[E0616]: field `c_mod` of struct `Record` is private + --> $DIR/stability-privacy-interaction.rs:41:7 + | +LL | r.c_mod; + | ^^^^^ private field + +error[E0616]: field `d_priv` of struct `Record` is private + --> $DIR/stability-privacy-interaction.rs:42:7 + | +LL | r.d_priv; + | ^^^^^^ private field + +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:46:5 + | +LL | t.2; + | ^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0616]: field `3` of struct `pub_and_stability::Tuple` is private + --> $DIR/stability-privacy-interaction.rs:47:7 + | +LL | t.3; + | ^ private field + +error[E0616]: field `4` of struct `pub_and_stability::Tuple` is private + --> $DIR/stability-privacy-interaction.rs:48:7 + | +LL | t.4; + | ^ private field + +error[E0616]: field `5` of struct `pub_and_stability::Tuple` is private + --> $DIR/stability-privacy-interaction.rs:49:7 + | +LL | t.5; + | ^ private field + +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:54:7 + | +LL | r.unstable_undeclared_trait_method(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:59:7 + | +LL | r.unstable_undeclared(); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0624]: method `pub_crate` is private + --> $DIR/stability-privacy-interaction.rs:61:7 + | +LL | r.pub_crate(); + | ^^^^^^^^^ private method + | + ::: $DIR/auxiliary/pub-and-stability.rs:114:9 + | +LL | pub(crate) fn pub_crate(&self) -> i32 { self.d_priv } + | ------------------------------------- private method defined here + +error[E0624]: method `pub_mod` is private + --> $DIR/stability-privacy-interaction.rs:62:7 + | +LL | r.pub_mod(); + | ^^^^^^^ private method + | + ::: $DIR/auxiliary/pub-and-stability.rs:116:9 + | +LL | pub(in crate::m) fn pub_mod(&self) -> i32 { self.d_priv } + | ----------------------------------------- private method defined here + +error[E0624]: method `private` is private + --> $DIR/stability-privacy-interaction.rs:63:7 + | +LL | r.private(); + | ^^^^^^^ private method + | + ::: $DIR/auxiliary/pub-and-stability.rs:118:9 + | +LL | fn private(&self) -> i32 { self.d_priv } + | ------------------------ private method defined here + +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:69:7 + | +LL | t.unstable_undeclared_trait_method(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable library feature `unstable_undeclared` + --> $DIR/stability-privacy-interaction.rs:73:7 + | +LL | t.unstable_undeclared(); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38412 for more information + = help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0624]: method `pub_crate` is private + --> $DIR/stability-privacy-interaction.rs:75:7 + | +LL | t.pub_crate(); + | ^^^^^^^^^ private method + | + ::: $DIR/auxiliary/pub-and-stability.rs:129:9 + | +LL | pub(crate) fn pub_crate(&self) -> i32 { self.0 } + | ------------------------------------- private method defined here + +error[E0624]: method `pub_mod` is private + --> $DIR/stability-privacy-interaction.rs:76:7 + | +LL | t.pub_mod(); + | ^^^^^^^ private method + | + ::: $DIR/auxiliary/pub-and-stability.rs:130:9 + | +LL | pub(in crate::m) fn pub_mod(&self) -> i32 { self.0 } + | ----------------------------------------- private method defined here + +error[E0624]: method `private` is private + --> $DIR/stability-privacy-interaction.rs:77:7 + | +LL | t.private(); + | ^^^^^^^ private method + | + ::: $DIR/auxiliary/pub-and-stability.rs:131:9 + | +LL | fn private(&self) -> i32 { self.0 } + | ------------------------ private method defined here + +error: aborting due to 19 previous errors + +Some errors have detailed explanations: E0616, E0624, E0658. +For more information about an error, try `rustc --explain E0616`. -- cgit 1.4.1-3-g733a5