From 1b5ac399082253288772dc1dabaa9d5458c927a9 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 4 Apr 2023 00:28:05 +0000 Subject: [PATCH] dyn* is a valid const --- .../src/transform/check_consts/check.rs | 2 +- tests/ui/dyn-star/const-and-static.rs | 10 ++++++++++ tests/ui/dyn-star/const-and-static.stderr | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/ui/dyn-star/const-and-static.rs create mode 100644 tests/ui/dyn-star/const-and-static.stderr diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index d6110a050f2..20c0852fe33 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -553,7 +553,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { } Rvalue::Cast(CastKind::DynStar, _, _) => { - unimplemented!() + // `dyn*` coercion is implemented for CTFE. } Rvalue::Cast(_, _, _) => {} diff --git a/tests/ui/dyn-star/const-and-static.rs b/tests/ui/dyn-star/const-and-static.rs new file mode 100644 index 00000000000..551b072abfa --- /dev/null +++ b/tests/ui/dyn-star/const-and-static.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete + +const C: dyn* Send + Sync = &(); + +static S: dyn* Send + Sync = &(); + +fn main() {} diff --git a/tests/ui/dyn-star/const-and-static.stderr b/tests/ui/dyn-star/const-and-static.stderr new file mode 100644 index 00000000000..df8f42fb0f5 --- /dev/null +++ b/tests/ui/dyn-star/const-and-static.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/const-and-static.rs:3:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #102425 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted +