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 0000000000000..507a753467ac9 --- /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/exclusive-drop-and-copy.rs b/tests/ui/derives/copy-drop-mutually-exclusive.rs similarity index 79% rename from tests/ui/exclusive-drop-and-copy.rs rename to tests/ui/derives/copy-drop-mutually-exclusive.rs index 210ecaed7567d..5147605910d7b 100644 --- a/tests/ui/exclusive-drop-and-copy.rs +++ b/tests/ui/derives/copy-drop-mutually-exclusive.rs @@ -1,4 +1,4 @@ -// issue #20126 +//! Regression test for issue #20126: Copy and Drop traits are mutually exclusive #[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented struct Foo; diff --git a/tests/ui/exclusive-drop-and-copy.stderr b/tests/ui/derives/copy-drop-mutually-exclusive.stderr similarity index 83% rename from tests/ui/exclusive-drop-and-copy.stderr rename to tests/ui/derives/copy-drop-mutually-exclusive.stderr index 340ca89c396b4..771bbc9256958 100644 --- a/tests/ui/exclusive-drop-and-copy.stderr +++ b/tests/ui/derives/copy-drop-mutually-exclusive.stderr @@ -1,11 +1,11 @@ error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor - --> $DIR/exclusive-drop-and-copy.rs:3:10 + --> $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/exclusive-drop-and-copy.rs:10:10 + --> $DIR/copy-drop-mutually-exclusive.rs:10:10 | LL | #[derive(Copy, Clone)] | ^^^^ `Copy` not allowed on types with destructors 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 0cd4fde73eda8..0000000000000 --- 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 e8d6b2a99640c..0000000000000 --- 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/error-should-say-copy-not-pod.rs b/tests/ui/error-should-say-copy-not-pod.rs deleted file mode 100644 index 40c4730ef699b..0000000000000 --- 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 6aa129fa29b53..0000000000000 --- 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/explicit-i-suffix.rs b/tests/ui/explicit-i-suffix.rs deleted file mode 100644 index 0a6ed49ae2704..0000000000000 --- 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/ext-nonexistent.rs b/tests/ui/ext-nonexistent.rs deleted file mode 100644 index 1293324b67ebe..0000000000000 --- 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 edb59bba6e5d1..0000000000000 --- 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 e94c12da01341..0000000000000 --- 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 0000000000000..d84498a60f80d --- /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/empty-type-parameter-list.stderr b/tests/ui/generics/empty-generic-brackets-equiv.stderr similarity index 76% rename from tests/ui/empty-type-parameter-list.stderr rename to tests/ui/generics/empty-generic-brackets-equiv.stderr index 31a5015e99349..151ee4697b4ca 100644 --- a/tests/ui/empty-type-parameter-list.stderr +++ b/tests/ui/generics/empty-generic-brackets-equiv.stderr @@ -1,5 +1,5 @@ warning: trait `T` is never used - --> $DIR/empty-type-parameter-list.rs:6:7 + --> $DIR/empty-generic-brackets-equiv.rs:9:7 | LL | trait T<> {} | ^ diff --git a/tests/ui/ext-expand-inner-exprs.rs b/tests/ui/macros/nested-macro-expansion.rs similarity index 71% rename from tests/ui/ext-expand-inner-exprs.rs rename to tests/ui/macros/nested-macro-expansion.rs index 94610d0a328f0..3b94b1051c9b7 100644 --- a/tests/ui/ext-expand-inner-exprs.rs +++ b/tests/ui/macros/nested-macro-expansion.rs @@ -1,3 +1,5 @@ +//! Test nested macro expansion with concat! macros + //@ run-pass static FOO : &'static str = concat!(concat!("hel", "lo"), "world"); diff --git a/tests/ui/resolve/nonexistent-macro.rs b/tests/ui/resolve/nonexistent-macro.rs new file mode 100644 index 0000000000000..663075473a1c8 --- /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 0000000000000..7e89e07bf30b8 --- /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/auxiliary/pub-and-stability.rs b/tests/ui/stability-attribute/auxiliary/pub-and-stability.rs similarity index 100% rename from tests/ui/auxiliary/pub-and-stability.rs rename to tests/ui/stability-attribute/auxiliary/pub-and-stability.rs diff --git a/tests/ui/explore-issue-38412.rs b/tests/ui/stability-attribute/stability-privacy-interaction.rs similarity index 64% rename from tests/ui/explore-issue-38412.rs rename to tests/ui/stability-attribute/stability-privacy-interaction.rs index 2008b120faae1..e02816ae1e739 100644 --- a/tests/ui/explore-issue-38412.rs +++ b/tests/ui/stability-attribute/stability-privacy-interaction.rs @@ -1,28 +1,39 @@ +//! 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 -// 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. +// 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() { - // Okay + // Test struct field access patterns 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: _, + .. + } = 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 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 @@ -37,10 +48,12 @@ fn main() { 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 @@ -49,6 +62,7 @@ fn main() { 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(); diff --git a/tests/ui/explore-issue-38412.stderr b/tests/ui/stability-attribute/stability-privacy-interaction.stderr similarity index 84% rename from tests/ui/explore-issue-38412.stderr rename to tests/ui/stability-attribute/stability-privacy-interaction.stderr index fca5c738d2769..991b3dbe0191b 100644 --- a/tests/ui/explore-issue-38412.stderr +++ b/tests/ui/stability-attribute/stability-privacy-interaction.stderr @@ -1,15 +1,15 @@ error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:19:63 + --> $DIR/stability-privacy-interaction.rs:29:9 | -LL | let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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/explore-issue-38412.rs:28:5 + --> $DIR/stability-privacy-interaction.rs:39:5 | LL | r.a_unstable_undeclared_pub; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,25 +19,25 @@ LL | r.a_unstable_undeclared_pub; = 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 + --> $DIR/stability-privacy-interaction.rs:40:7 | LL | r.b_crate; | ^^^^^^^ private field error[E0616]: field `c_mod` of struct `Record` is private - --> $DIR/explore-issue-38412.rs:30:7 + --> $DIR/stability-privacy-interaction.rs:41:7 | LL | r.c_mod; | ^^^^^ private field error[E0616]: field `d_priv` of struct `Record` is private - --> $DIR/explore-issue-38412.rs:31:7 + --> $DIR/stability-privacy-interaction.rs:42:7 | LL | r.d_priv; | ^^^^^^ private field error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:35:5 + --> $DIR/stability-privacy-interaction.rs:46:5 | LL | t.2; | ^^^ @@ -47,25 +47,25 @@ LL | t.2; = 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 + --> $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/explore-issue-38412.rs:37:7 + --> $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/explore-issue-38412.rs:38:7 + --> $DIR/stability-privacy-interaction.rs:49:7 | LL | t.5; | ^ private field error[E0658]: use of unstable library feature `unstable_undeclared` - --> $DIR/explore-issue-38412.rs:42:7 + --> $DIR/stability-privacy-interaction.rs:54:7 | LL | r.unstable_undeclared_trait_method(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL | r.unstable_undeclared_trait_method(); = 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 + --> $DIR/stability-privacy-interaction.rs:59:7 | LL | r.unstable_undeclared(); | ^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | r.unstable_undeclared(); = 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 + --> $DIR/stability-privacy-interaction.rs:61:7 | LL | r.pub_crate(); | ^^^^^^^^^ private method @@ -96,7 +96,7 @@ 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 + --> $DIR/stability-privacy-interaction.rs:62:7 | LL | r.pub_mod(); | ^^^^^^^ private method @@ -107,7 +107,7 @@ 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 + --> $DIR/stability-privacy-interaction.rs:63:7 | LL | r.private(); | ^^^^^^^ private method @@ -118,7 +118,7 @@ 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 + --> $DIR/stability-privacy-interaction.rs:69:7 | LL | t.unstable_undeclared_trait_method(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -128,7 +128,7 @@ LL | t.unstable_undeclared_trait_method(); = 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 + --> $DIR/stability-privacy-interaction.rs:73:7 | LL | t.unstable_undeclared(); | ^^^^^^^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL | t.unstable_undeclared(); = 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 + --> $DIR/stability-privacy-interaction.rs:75:7 | LL | t.pub_crate(); | ^^^^^^^^^ private method @@ -149,7 +149,7 @@ 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 + --> $DIR/stability-privacy-interaction.rs:76:7 | LL | t.pub_mod(); | ^^^^^^^ private method @@ -160,7 +160,7 @@ 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 + --> $DIR/stability-privacy-interaction.rs:77:7 | LL | t.private(); | ^^^^^^^ private method