Rollup merge of #142217 - Kivooeo:tf10, r=jieyouxu
`tests/ui`: A New Order [10/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@jieyouxu`
This commit is contained in:
commit
c557695fe1
19 changed files with 102 additions and 144 deletions
10
tests/ui/box/empty-alloc-deref-rvalue.rs
Normal file
10
tests/ui/box/empty-alloc-deref-rvalue.rs
Normal file
|
|
@ -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(());
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(unused_variables)]
|
||||
|
||||
pub fn main() {
|
||||
let x: () = *Box::new(());
|
||||
}
|
||||
|
|
@ -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<>;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
// Tests that the error message uses the word Copy, not Pod.
|
||||
|
||||
fn check_bound<T:Copy>(_: T) {}
|
||||
|
||||
fn main() {
|
||||
check_bound("nocopy".to_string()); //~ ERROR : Copy` is not satisfied
|
||||
}
|
||||
|
|
@ -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:Copy>(_: 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`.
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fn main() { iamnotanextensionthatexists!(""); }
|
||||
//~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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");
|
||||
|
||||
}
|
||||
27
tests/ui/generics/empty-generic-brackets-equiv.rs
Normal file
27
tests/ui/generics/empty-generic-brackets-equiv.rs
Normal file
|
|
@ -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<>;
|
||||
}
|
||||
|
|
@ -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<> {}
|
||||
| ^
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! Test nested macro expansion with concat! macros
|
||||
|
||||
//@ run-pass
|
||||
|
||||
static FOO : &'static str = concat!(concat!("hel", "lo"), "world");
|
||||
6
tests/ui/resolve/nonexistent-macro.rs
Normal file
6
tests/ui/resolve/nonexistent-macro.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
//! Test error handling for undefined macro calls
|
||||
|
||||
fn main() {
|
||||
iamnotanextensionthatexists!("");
|
||||
//~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope
|
||||
}
|
||||
8
tests/ui/resolve/nonexistent-macro.stderr
Normal file
8
tests/ui/resolve/nonexistent-macro.stderr
Normal file
|
|
@ -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
|
||||
|
||||
|
|
@ -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();
|
||||
|
|
@ -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 <https://github.com/rust-lang/rust/issues/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
|
||||
Loading…
Add table
Add a link
Reference in a new issue