Skip to content

Commit a9c6020

Browse files
committed
cleanud up some tests
1 parent 8072811 commit a9c6020

21 files changed

+105
-147
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::mem;
22

33
use rustc_errors::{Diag, DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg};
44
use rustc_middle::mir::AssertKind;
5-
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo};
5+
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo, UnsupportedOpInfo};
66
use rustc_middle::query::TyCtxtAt;
77
use rustc_middle::ty::layout::LayoutError;
88
use rustc_middle::ty::{ConstInt, TyCtxt};
@@ -167,7 +167,7 @@ where
167167
// anyway (e.g. due to size overflow). And we allow OOM as that can happen any time.
168168
let allowed_in_infallible = matches!(
169169
error,
170-
InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_)
170+
InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_) | InterpErrorKind::Unsupported(UnsupportedOpInfo::ReadPointerAsInt(_))
171171
);
172172

173173
error.add_args(&mut err);

src/tools/cargo

Submodule cargo updated 60 files
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Smoke test: dereferencing boxed zero-sized types (ZSTs) should not crash.
2+
//!
3+
//! Originally a regression test of github.com/rust-lang/rust/issues/13360
4+
//! but repurposed for a smoke test.
5+
6+
//@ run-pass
7+
8+
pub fn main() {
9+
let _: () = *Box::new(());
10+
}

tests/ui/exclusive-drop-and-copy.rs renamed to tests/ui/derives/copy-drop-mutually-exclusive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// issue #20126
1+
//! Regression test for issue #20126: Copy and Drop traits are mutually exclusive
22
33
#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented
44
struct Foo;

tests/ui/exclusive-drop-and-copy.stderr renamed to tests/ui/derives/copy-drop-mutually-exclusive.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
2-
--> $DIR/exclusive-drop-and-copy.rs:3:10
2+
--> $DIR/copy-drop-mutually-exclusive.rs:3:10
33
|
44
LL | #[derive(Copy, Clone)]
55
| ^^^^ `Copy` not allowed on types with destructors
66

77
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
8-
--> $DIR/exclusive-drop-and-copy.rs:10:10
8+
--> $DIR/copy-drop-mutually-exclusive.rs:10:10
99
|
1010
LL | #[derive(Copy, Clone)]
1111
| ^^^^ `Copy` not allowed on types with destructors

tests/ui/empty-allocation-rvalue-non-null.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/ui/empty-type-parameter-list.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/ui/error-should-say-copy-not-pod.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/ui/error-should-say-copy-not-pod.stderr

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/ui/explicit-i-suffix.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/ext-nonexistent.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/ui/ext-nonexistent.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/ui/fact.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! Test that empty type parameter list <> is equivalent to no type parameters
2+
//!
3+
//! Checks` that empty angle brackets <> are syntactically valid and equivalent
4+
//! to omitting type parameters entirely across various language constructs.
5+
6+
//@ run-pass
7+
8+
struct S<>;
9+
trait T<> {} //~ WARN trait `T` is never used
10+
enum E<> {
11+
V
12+
}
13+
impl<> T<> for S<> {}
14+
impl T for E {}
15+
fn foo<>() {}
16+
fn bar() {}
17+
fn main() {
18+
let _ = S;
19+
let _ = S::<>;
20+
let _ = E::V;
21+
let _ = E::<>::V;
22+
foo();
23+
foo::<>();
24+
// Test that we can supply <> to non-generic things
25+
bar::<>();
26+
let _: i32<>;
27+
}

tests/ui/empty-type-parameter-list.stderr renamed to tests/ui/generics/empty-generic-brackets-equiv.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: trait `T` is never used
2-
--> $DIR/empty-type-parameter-list.rs:6:7
2+
--> $DIR/empty-generic-brackets-equiv.rs:9:7
33
|
44
LL | trait T<> {}
55
| ^

tests/ui/ext-expand-inner-exprs.rs renamed to tests/ui/macros/nested-macro-expansion.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test nested macro expansion with concat! macros
2+
13
//@ run-pass
24

35
static FOO : &'static str = concat!(concat!("hel", "lo"), "world");

tests/ui/resolve/nonexistent-macro.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! Test error handling for undefined macro calls
2+
3+
fn main() {
4+
iamnotanextensionthatexists!("");
5+
//~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: cannot find macro `iamnotanextensionthatexists` in this scope
2+
--> $DIR/nonexistent-macro.rs:4:5
3+
|
4+
LL | iamnotanextensionthatexists!("");
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

tests/ui/explore-issue-38412.rs renamed to tests/ui/stability-attribute/stability-privacy-interaction.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1+
//! Regression test for issue #38412: interaction between stability attributes and privacy
2+
//!
3+
//! Tests that the compiler correctly handles the interaction between feature gates
4+
//! and privacy/visibility rules. Specifically verifies that enabled unstable features
5+
//! are accessible while disabled ones are properly rejected.
6+
17
//@ aux-build:pub-and-stability.rs
28

3-
// A big point of this test is that we *enable* `unstable_declared`,
4-
// but do *not* enable `unstable_undeclared`. This way we can check
5-
// that the compiler is letting in uses of enabled feature-gated
6-
// stuff but still rejecting uses of disabled feature-gated stuff.
9+
// Enable `unstable_declared` but not `unstable_undeclared` to test
10+
// that the compiler allows enabled features but rejects disabled ones
711
#![feature(unstable_declared)]
812

913
extern crate pub_and_stability;
1014
use pub_and_stability::{Record, Trait, Tuple};
1115

1216
fn main() {
13-
// Okay
17+
// Test struct field access patterns
1418
let Record { .. } = Record::new();
1519

16-
// Okay
17-
let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new();
20+
let Record {
21+
a_stable_pub: _,
22+
a_unstable_declared_pub: _,
23+
..
24+
} = Record::new();
1825

19-
let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } =
20-
Record::new();
21-
//~^^ ERROR use of unstable library feature `unstable_undeclared`
26+
let Record {
27+
a_stable_pub: _,
28+
a_unstable_declared_pub: _,
29+
a_unstable_undeclared_pub: _, //~ ERROR use of unstable library feature `unstable_undeclared`
30+
..
31+
} = Record::new();
2232

2333
let r = Record::new();
2434
let t = Tuple::new();
2535

36+
// Test field access with different stability/privacy combinations
2637
r.a_stable_pub;
2738
r.a_unstable_declared_pub;
2839
r.a_unstable_undeclared_pub; //~ ERROR use of unstable library feature
@@ -37,10 +48,12 @@ fn main() {
3748
t.4; //~ ERROR is private
3849
t.5; //~ ERROR is private
3950

51+
// Test trait method access
4052
r.stable_trait_method();
4153
r.unstable_declared_trait_method();
4254
r.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature
4355

56+
// Test inherent method access
4457
r.stable();
4558
r.unstable_declared();
4659
r.unstable_undeclared(); //~ ERROR use of unstable library feature
@@ -49,6 +62,7 @@ fn main() {
4962
r.pub_mod(); //~ ERROR `pub_mod` is private
5063
r.private(); //~ ERROR `private` is private
5164

65+
// Repeat tests for tuple struct
5266
let t = Tuple::new();
5367
t.stable_trait_method();
5468
t.unstable_declared_trait_method();

0 commit comments

Comments
 (0)