Finished const_eval module migration, moving onto sibling folders

This commit is contained in:
nidnogg 2022-08-18 01:54:11 -03:00
parent 0b71ffca18
commit 6af8e46a9a
3 changed files with 16 additions and 6 deletions

View File

@ -1,16 +1,16 @@
// Not in interpret to make sure we do not use private implementation details
use crate::errors::MaxNumNodesExceeded;
use crate::interpret::{
intern_const_alloc_recursive, ConstValue, InternKind, InterpCx, InterpResult, MemPlaceMeta,
Scalar,
};
use rustc_hir::Mutability;
use rustc_middle::mir;
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::{source_map::DUMMY_SP, symbol::Symbol};
use crate::interpret::{
intern_const_alloc_recursive, ConstValue, InternKind, InterpCx, InterpResult, MemPlaceMeta,
Scalar,
};
mod error;
mod eval_queries;
mod fn_queries;
@ -77,7 +77,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
ValTreeCreationError::NodesOverflow => {
let msg = format!("maximum number of nodes exceeded in constant {}", &s);
let mut diag = match tcx.hir().span_if_local(did) {
Some(span) => tcx.sess.struct_span_err(span, &msg),
Some(span) => tcx.sess.create_err(MaxNumNodesExceeded { span, s }),
None => tcx.sess.struct_err(&msg),
};
diag.emit();

View File

@ -87,3 +87,11 @@ pub(crate) struct TransientMutBorrowErrRaw {
pub span: Span,
pub kind: ConstContext,
}
#[derive(SessionDiagnostic)]
#[error(const_eval::const_evaL_max_num_nodes_exceeded)]
pub(crate) struct MaxNumNodesExceeded {
#[primary_span]
pub span: Span,
pub s: String,
}

View File

@ -29,3 +29,5 @@ const_eval_mut_deref =
const_eval_transient_mut_borrow = mutable references are not allowed in {$kind}s
const_eval_transient_mut_borrow_raw = raw mutable references are not allowed in {$kind}s
const_evaL_max_num_nodes_exceeded = maximum number of nodes exceeded in constant {$s}