Skip to content

Commit

Permalink
Introduce some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jul 14, 2024
1 parent 38feebd commit 7bd296b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(adt_const_params, unsized_const_parameters)]
#![allow(incomplete_features)]

use std::marker::ConstParamTy_;

fn foo(a: &dyn ConstParamTy_) {}
//~^ ERROR: the trait `ConstParamTy_`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0038]: the trait `ConstParamTy_` cannot be made into an object
--> $DIR/const_param_ty_object_safety.rs:6:12
|
LL | fn foo(a: &dyn ConstParamTy_) {}
| ^^^^^^^^^^^^^^^^^ `ConstParamTy_` cannot be made into an object
|
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>
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: the trait cannot be made into an object because it uses `Self` as a type parameter
help: consider using an opaque type instead
|
LL | fn foo(a: &impl ConstParamTy_) {}
| ~~~~

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0038`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![feature(adt_const_params, unsized_const_parameters)]
#![allow(incomplete_features)]

use std::marker::ConstParamTy_;

struct Foo;

impl ConstParamTy_ for &'static Foo {}
//~^ ERROR: the trait `ConstParamTy_` cannot be implemented for this type

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/reference_pointee_is_const_param-1.rs:8:24
|
LL | impl ConstParamTy_ for &'static Foo {}
| ^^^^^^^^^^^^ this field does not implement `ConstParamTy_`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0204`.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//@ known-bug: #119299
#![feature(adt_const_params)]
#![feature(adt_const_params, unsized_const_parameters)]
#![allow(incomplete_features)]

// Regression test for #119299

use std::marker::ConstParamTy_;

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

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

impl ConstStrU {
const fn from_bytes(bytes: &'static [u8]) -> Self {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0204]: the trait `ConstParamTy_` cannot be implemented for this type
--> $DIR/reference_pointee_is_const_param-2.rs:11:24
|
LL | impl ConstParamTy_ for &'static ConstStrU {}
| ^^^^^^^^^^^^^^^^^^ this field does not implement `ConstParamTy_`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0204`.

0 comments on commit 7bd296b

Please sign in to comment.