Skip to content

Commit

Permalink
Bless tests and handle tests/crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jun 4, 2024
1 parent c1f73c8 commit 50c503a
Show file tree
Hide file tree
Showing 35 changed files with 386 additions and 285 deletions.
4 changes: 0 additions & 4 deletions tests/crashes/122908.rs

This file was deleted.

14 changes: 0 additions & 14 deletions tests/crashes/125556.rs

This file was deleted.

4 changes: 2 additions & 2 deletions tests/debuginfo/function-names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// Const generic parameter
// gdb-command:info functions -q function_names::const_generic_fn.*
// gdb-check:[...]static fn function_names::const_generic_fn_bool<false>();
// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#ad91263f6d2dd96e}>();
// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#[...]}>();
// gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>();
// gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>();

Expand Down Expand Up @@ -76,7 +76,7 @@
// Const generic parameter
// cdb-command:x a!function_names::const_generic_fn*
// cdb-check:[...] a!function_names::const_generic_fn_bool<false> (void)
// cdb-check:[...] a!function_names::const_generic_fn_non_int<CONST$ad91263f6d2dd96e> (void)
// cdb-check:[...] a!function_names::const_generic_fn_non_int<CONST#[...]> (void)
// cdb-check:[...] a!function_names::const_generic_fn_unsigned_int<14> (void)
// cdb-check:[...] a!function_names::const_generic_fn_signed_int<-7> (void)

Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/issue_99325.main.built.after.32bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| User Type Annotations
| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }: &'static [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
|
fn main() -> () {
let mut _0: ();
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/issue_99325.main.built.after.64bit.mir
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| User Type Annotations
| 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }: &'static [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}
|
fn main() -> () {
let mut _0: ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//@ edition:2021
//@ check-pass
// issues rust-lang/rust#111911
// test for ICE opaque type with non-universal region substs

#![feature(adt_const_params)]
#![allow(incomplete_features)]

pub async fn foo<const X: &'static str>() {}
//~^ ERROR const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias
//~| ERROR const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias
fn bar<const N: &'static u8>() -> impl Sized {}

pub fn main() {}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
|
= note: type parameters may not be used in the type of const parameters

error: aborting due to 1 previous error
error[E0392]: type parameter `T` is never used
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
|
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused type parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0770`.
Some errors have detailed explanations: E0392, E0770.
For more information about an error, try `rustc --explain E0392`.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
|
= note: type parameters may not be used in the type of const parameters

error: aborting due to 1 previous error
error[E0392]: type parameter `T` is never used
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
|
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused type parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0770`.
Some errors have detailed explanations: E0392, E0770.
For more information about an error, try `rustc --explain E0392`.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

pub struct Dependent<T, const X: T>([(); X]);
//~^ ERROR: the type of const parameters must not depend on other generic parameters
//~| ERROR: type parameter `T` is never used

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/const-generics/generic_const_exprs/error_in_ty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ compile-flags: -Znext-solver=coherence

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

pub struct A<const z: [usize; x]> {}
//~^ ERROR: cannot find value `x` in this scope
//~| ERROR: `[usize; x]` is forbidden as the type of a const generic parameter

impl A<2> {
//~^ ERROR: mismatched types
pub const fn B() {}
//~^ ERROR: duplicate definitions
}

impl A<2> {
//~^ ERROR: mismatched types
pub const fn B() {}
}

fn main() {}
45 changes: 45 additions & 0 deletions tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
error[E0425]: cannot find value `x` in this scope
--> $DIR/error_in_ty.rs:6:31
|
LL | pub struct A<const z: [usize; x]> {}
| - ^ help: a const parameter with a similar name exists: `z`
| |
| similarly named const parameter `z` defined here

error: `[usize; x]` is forbidden as the type of a const generic parameter
--> $DIR/error_in_ty.rs:6:23
|
LL | pub struct A<const z: [usize; x]> {}
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
LL + #![feature(adt_const_params)]
|

error[E0308]: mismatched types
--> $DIR/error_in_ty.rs:10:8
|
LL | impl A<2> {
| ^ expected `[usize; x]`, found integer

error[E0308]: mismatched types
--> $DIR/error_in_ty.rs:16:8
|
LL | impl A<2> {
| ^ expected `[usize; x]`, found integer

error[E0592]: duplicate definitions with name `B`
--> $DIR/error_in_ty.rs:12:5
|
LL | pub const fn B() {}
| ^^^^^^^^^^^^^^^^ duplicate definitions for `B`
...
LL | pub const fn B() {}
| ---------------- other definition for `B`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0308, E0425, E0592.
For more information about an error, try `rustc --explain E0308`.
5 changes: 3 additions & 2 deletions tests/ui/const-generics/generic_const_exprs/eval-privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ pub trait Trait {
fn assoc_fn() -> Self::AssocTy;
}

impl<const U: u8> Trait for Const<U> // OK, trait impl predicates
impl<const U: u8> Trait for Const<U>
where
Const<{ my_const_fn(U) }>: ,
// OK, trait impl predicates
Const<{ my_const_fn(U) }>:,
{
type AssocTy = Const<{ my_const_fn(U) }>;
//~^ ERROR private type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface
--> $DIR/eval-privacy.rs:16:5
--> $DIR/eval-privacy.rs:17:5
|
LL | type AssocTy = Const<{ my_const_fn(U) }>;
| ^^^^^^^^^^^^ can't leak private type
Expand All @@ -8,7 +8,7 @@ LL | const fn my_const_fn(val: u8) -> u8 {
| ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private

error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface
--> $DIR/eval-privacy.rs:16:5
--> $DIR/eval-privacy.rs:17:5
|
LL | type AssocTy = Const<{ my_const_fn(U) }>;
| ^^^^^^^^^^^^ can't leak private type
Expand Down
18 changes: 15 additions & 3 deletions tests/ui/const-generics/issues/issue-71381.full.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
= note: type parameters may not be used in the type of const parameters

error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-71381.rs:23:40
--> $DIR/issue-71381.rs:24:40
|
LL | const FN: unsafe extern "C" fn(Args),
| ^^^^ the type must not depend on the parameter `Args`
|
= note: type parameters may not be used in the type of const parameters

error: aborting due to 2 previous errors
error[E0594]: cannot assign to `self.0`, which is behind a `&` reference
--> $DIR/issue-71381.rs:17:9
|
LL | self.0 = Self::trampiline::<Args, IDX, FN> as _
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
|
help: consider changing this to be a mutable reference
|
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&mut self) {
| ~~~~~~~~~

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0770`.
Some errors have detailed explanations: E0594, E0770.
For more information about an error, try `rustc --explain E0594`.
20 changes: 16 additions & 4 deletions tests/ui/const-generics/issues/issue-71381.min.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
= note: type parameters may not be used in the type of const parameters

error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-71381.rs:23:40
--> $DIR/issue-71381.rs:24:40
|
LL | const FN: unsafe extern "C" fn(Args),
| ^^^^ the type must not depend on the parameter `Args`
Expand All @@ -23,13 +23,25 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
= note: the only supported types are integers, `bool` and `char`

error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71381.rs:23:19
--> $DIR/issue-71381.rs:24:19
|
LL | const FN: unsafe extern "C" fn(Args),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`

error: aborting due to 4 previous errors
error[E0594]: cannot assign to `self.0`, which is behind a `&` reference
--> $DIR/issue-71381.rs:17:9
|
LL | self.0 = Self::trampiline::<Args, IDX, FN> as _
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
|
help: consider changing this to be a mutable reference
|
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&mut self) {
| ~~~~~~~~~

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0770`.
Some errors have detailed explanations: E0594, E0770.
For more information about an error, try `rustc --explain E0594`.
1 change: 1 addition & 0 deletions tests/ui/const-generics/issues/issue-71381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl Test {
//~^ ERROR: the type of const parameters must not depend on other generic parameters
//[min]~^^ ERROR: using function pointers as const generic parameters is forbidden
self.0 = Self::trampiline::<Args, IDX, FN> as _
//~^ ERROR: cannot assign to `self.0`
}

unsafe extern "C" fn trampiline<
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/const-generics/not_wf_param_in_rpitit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ edition:2021

trait Trait<const N: Trait = bar> {
//~^ ERROR: cannot find value `bar` in this scope
//~| ERROR: cycle detected when computing type of `Trait::N`
//~| ERROR: the trait `Trait` cannot be made into an object
//~| ERROR: the trait `Trait` cannot be made into an object
//~| ERROR: the trait `Trait` cannot be made into an object
//~| ERROR: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter
//~| ERROR: trait objects must include the `dyn` keyword
async fn a() {}
}

fn main() {}
Loading

0 comments on commit 50c503a

Please sign in to comment.