add min_adt_const_params gate tests

This commit is contained in:
zedddie
2026-03-08 18:33:22 +01:00
parent 212ef7770d
commit 98d259beaf
6 changed files with 98 additions and 0 deletions
@@ -0,0 +1,17 @@
//! Ensure we enforce `min_adt_const_params` rules on any adt `ConstParamTy_`
//! implementation unless `adt_const_params` feature is used.
#![allow(incomplete_features)]
#![feature(const_param_ty_trait)]
use std::marker::ConstParamTy_;
#[derive(PartialEq, Eq)]
pub struct Fumo {
cirno: i32,
pub(crate) reimu: i32
}
impl ConstParamTy_ for Fumo {}
//~^ ERROR: the trait `ConstParamTy` may not be implemented for this struct
fn main() {}
@@ -0,0 +1,8 @@
error: the trait `ConstParamTy` may not be implemented for this struct
--> $DIR/const_param_ty-on-adt-without-adt-gate.rs:14:24
|
LL | impl ConstParamTy_ for Fumo {}
| ^^^^ struct fields are less visible than the struct
error: aborting due to 1 previous error
@@ -0,0 +1,35 @@
//! Ensure min_adt_const_params enforce
//! struct's visibility on its fields
#![allow(incomplete_features)]
#![feature(min_adt_const_params)]
#![feature(const_param_ty_trait)]
use std::marker::ConstParamTy_;
#[derive(PartialEq, Eq)]
pub struct Meowl {
pub public: i32,
private: i32
}
#[derive(PartialEq, Eq)]
pub struct Meowl2 {
pub a: i32,
pub b: i32
}
#[derive(PartialEq, Eq)]
pub(crate) struct Meowl3 {
pub(crate) a: i32,
pub b: i32
}
impl ConstParamTy_ for Meowl {}
//~^ ERROR the trait `ConstParamTy` may not be implemented for this struct
impl ConstParamTy_ for Meowl2 {}
impl ConstParamTy_ for Meowl3 {}
fn something<const N: Meowl2>() {}
fn something2<const N: Meowl3>() {}
fn main() {}
@@ -0,0 +1,8 @@
error: the trait `ConstParamTy` may not be implemented for this struct
--> $DIR/min_adt_const_params-gate-fail.rs:27:24
|
LL | impl ConstParamTy_ for Meowl {}
| ^^^^^ struct fields are less visible than the struct
error: aborting due to 1 previous error
@@ -0,0 +1,18 @@
// gate-test-min_adt_const_params
//@run-pass
#![feature(min_adt_const_params, const_param_ty_trait)]
#![allow(incomplete_features, dead_code)]
use std::marker::ConstParamTy_;
#[derive(PartialEq, Eq)]
pub struct Meowl {
pub public: i32,
pub also_public: i32
}
impl ConstParamTy_ for Meowl {}
fn meoow<const N: Meowl>() {}
fn main() {}
@@ -0,0 +1,12 @@
//@run-pass
#![feature(min_adt_const_params)]
use std::marker::ConstParamTy;
#[derive(ConstParamTy, Eq, PartialEq)]
#[allow(dead_code)]
struct Foo {
pub field: u32,
}
fn main() {}