Skip to content

Commit 6c519f6

Browse files
committed
Introduce some tests
1 parent 38feebd commit 6c519f6

8 files changed

+81
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(adt_const_params, unsized_const_parameters)]
2+
#![allow(incomplete_features)]
3+
4+
use std::marker::ConstParamTy_;
5+
6+
fn foo(a: &dyn ConstParamTy_) {}
7+
//~^ ERROR: the trait `ConstParamTy_`
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
2+
--> $DIR/const_param_ty_object_safety.rs:6:12
3+
|
4+
LL | fn foo(a: &dyn ConstParamTy_) {}
5+
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
6+
|
7+
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8+
--> $SRC_DIR/core/src/cmp.rs:LL:COL
9+
|
10+
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
11+
help: consider using an opaque type instead
12+
|
13+
LL | fn foo(a: &impl ConstParamTy_) {}
14+
| ~~~~
15+
16+
error: aborting due to 1 previous error
17+
18+
For more information about this error, try `rustc --explain E0038`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(adt_const_params, unsized_const_parameters)]
2+
#![allow(incomplete_features)]
3+
4+
use std::marker::ConstParamTy_;
5+
6+
struct Foo;
7+
8+
impl ConstParamTy_ for &'static Foo {}
9+
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
2+
--> $DIR/reference_pointee_is_const_param-1.rs:8:24
3+
|
4+
LL | impl ConstParamTy_ for &'static Foo {}
5+
| ^^^^^^^^^^^^ this field does not implement `ConstParamTy_`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0204`.

tests/crashes/119299.rs renamed to tests/ui/const-generics/adt_const_params/reference_pointee_is_const_param-2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
//@ known-bug: #119299
2-
#![feature(adt_const_params)]
1+
#![feature(adt_const_params, unsized_const_parameters)]
32
#![allow(incomplete_features)]
43

4+
// Regression test for #119299
5+
56
use std::marker::ConstParamTy_;
67

78
#[derive(Eq, PartialEq)]
89
struct ConstStrU(*const u8, usize);
910

1011
impl ConstParamTy_ for &'static ConstStrU {}
12+
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type
1113

1214
impl ConstStrU {
1315
const fn from_bytes(bytes: &'static [u8]) -> Self {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
2+
--> $DIR/reference_pointee_is_const_param-2.rs:11:24
3+
|
4+
LL | impl ConstParamTy_ for &'static ConstStrU {}
5+
| ^^^^^^^^^^^^^^^^^^ this field does not implement `ConstParamTy_`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0204`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(adt_const_params, unsized_const_parameters)]
2+
#![allow(incomplete_features)]
3+
4+
use std::marker::ConstParamTy_;
5+
6+
trait Trait {}
7+
8+
impl ConstParamTy_ for dyn Trait {}
9+
//~^ ERROR: the trait `ConstParamTy` may not be implemented for this type
10+
11+
fn foo<const N: dyn Trait>() {}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: the trait `ConstParamTy` may not be implemented for this type
2+
--> $DIR/trait_objects_as_a_const_generic.rs:8:24
3+
|
4+
LL | impl ConstParamTy_ for dyn Trait {}
5+
| ^^^^^^^^^ type is not a structure or enumeration
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)