Skip to content

Commit c51749a

Browse files
committed
We won't support trait object constants in type level constants for the forseeable future
1 parent 6ca1d87 commit c51749a

File tree

1 file changed

+5
-3
lines changed
  • compiler/rustc_mir/src/const_eval

1 file changed

+5
-3
lines changed

compiler/rustc_mir/src/const_eval/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ fn const_to_valtree_inner<'tcx>(
8787
ty::FnPtr(_) | ty::RawPtr(_) => None,
8888
ty::Ref(..) => unimplemented!("need to use deref_const"),
8989

90-
ty::Dynamic(..) => unimplemented!(
91-
"for trait objects we must look at the vtable and figure out the real type"
92-
),
90+
// Trait objects are not allowed in type level constants, as we have no concept for
91+
// resolving their backing type, even if we can do that at const eval time. We may want to consider
92+
// adding a `ValTree::DownCast(Ty<'tcx>, Box<ValTree>)` in the future, but I don't even know the
93+
// questions such a concept would open up, so an RFC would probably be good for this.
94+
ty::Dynamic(..) => None,
9395

9496
ty::Slice(_) | ty::Str => {
9597
unimplemented!("need to find the backing data of the slice/str and recurse on that")

0 commit comments

Comments
 (0)