mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Fix cell checks in const fn
This commit is contained in:
parent
3a44a20ed1
commit
354e510f7d
@ -227,6 +227,13 @@ impl NonConstOp for CellBorrowBehindRef {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CellBorrow;
|
pub struct CellBorrow;
|
||||||
impl NonConstOp for CellBorrow {
|
impl NonConstOp for CellBorrow {
|
||||||
|
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||||
|
match ccx.const_kind() {
|
||||||
|
// The borrow checker does a much better job at handling these than we do
|
||||||
|
hir::ConstContext::ConstFn => Status::Allowed,
|
||||||
|
_ => Status::Forbidden,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn importance(&self) -> DiagnosticImportance {
|
fn importance(&self) -> DiagnosticImportance {
|
||||||
// The problematic cases will already emit a `CellBorrowBehindRef`
|
// The problematic cases will already emit a `CellBorrowBehindRef`
|
||||||
DiagnosticImportance::Secondary
|
DiagnosticImportance::Secondary
|
||||||
|
@ -36,4 +36,6 @@ unsafe impl<T> Sync for Wrap<T> {}
|
|||||||
|
|
||||||
static BAR_PTR: Wrap<*mut u32> = Wrap(BAR.0.get());
|
static BAR_PTR: Wrap<*mut u32> = Wrap(BAR.0.get());
|
||||||
|
|
||||||
|
const fn fst_ref<T, U>(x: &(T, U)) -> &T { &x.0 }
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user