Add an attribute to be able to configure the limit
This commit is contained in:
parent
e9696c8b62
commit
a2f2179026
11 changed files with 65 additions and 11 deletions
|
@ -83,6 +83,12 @@ impl Limit {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<usize> for Limit {
|
||||
fn from(value: usize) -> Self {
|
||||
Self::new(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Limit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
|
@ -143,6 +149,10 @@ pub struct Session {
|
|||
/// operations such as auto-dereference and monomorphization.
|
||||
pub recursion_limit: OnceCell<Limit>,
|
||||
|
||||
/// The size at which the `large_assignments` lint starts
|
||||
/// being emitted.
|
||||
pub move_size_limit: OnceCell<usize>,
|
||||
|
||||
/// The maximum length of types during monomorphization.
|
||||
pub type_length_limit: OnceCell<Limit>,
|
||||
|
||||
|
@ -352,6 +362,11 @@ impl Session {
|
|||
self.recursion_limit.get().copied().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn move_size_limit(&self) -> usize {
|
||||
self.move_size_limit.get().copied().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_length_limit(&self) -> Limit {
|
||||
self.type_length_limit.get().copied().unwrap()
|
||||
|
@ -1414,6 +1429,7 @@ pub fn build_session(
|
|||
features: OnceCell::new(),
|
||||
lint_store: OnceCell::new(),
|
||||
recursion_limit: OnceCell::new(),
|
||||
move_size_limit: OnceCell::new(),
|
||||
type_length_limit: OnceCell::new(),
|
||||
const_eval_limit: OnceCell::new(),
|
||||
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue