Skip to content

Commit

Permalink
Update compiler/rustc_mir/src/const_eval/mod.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Ralf Jung <post@ralfj.de>
  • Loading branch information
oli-obk and RalfJung committed Mar 16, 2021
1 parent 1ffd21a commit f0997fa
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions compiler/rustc_mir/src/const_eval/mod.rs
Expand Up @@ -84,11 +84,10 @@ fn const_to_valtree_inner<'tcx>(
Some(ty::ValTree::Leaf(val.assert_int()))
}

// Raw pointers are not allowed in type level constants, as raw pointers compare equal if
// their addresses are equal. Since we cannot guarantee any kind of pointer stability in
// the type system.
// Technically we could allow function pointers, but they are not guaranteed to be the
// same as the function pointers at runtime.
// Raw pointers are not allowed in type level constants, as we cannot properly test them for
// equality at compile-time (see `ptr_guaranteed_eq`/`_ne`).
// Technically we could allow function pointers (represented as `ty::Instance`), but this is not guaranteed to
// agree with runtime equality tests.
ty::FnPtr(_) | ty::RawPtr(_) => None,
ty::Ref(..) => unimplemented!("need to use deref_const"),

Expand Down

0 comments on commit f0997fa

Please sign in to comment.