Add pattern_complexity_limit
to Limits
.
It's similar to the other limits, e.g. obtained via `get_limit`. So it makes sense to handle it consistently with the other limits. We now use `Limit`/`usize` in most places instead of `Option<usize>`, so we use `Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work. The commit also adds `Limit::unlimited`.
This commit is contained in:
parent
5bc6231454
commit
b023671ce2
11 changed files with 51 additions and 35 deletions
|
@ -24,30 +24,36 @@ pub fn provide(providers: &mut Providers) {
|
|||
tcx.hir().krate_attrs(),
|
||||
tcx.sess,
|
||||
sym::move_size_limit,
|
||||
tcx.sess.opts.unstable_opts.move_size_limit.unwrap_or(0),
|
||||
Limit::new(tcx.sess.opts.unstable_opts.move_size_limit.unwrap_or(0)),
|
||||
),
|
||||
type_length_limit: get_limit(
|
||||
tcx.hir().krate_attrs(),
|
||||
tcx.sess,
|
||||
sym::type_length_limit,
|
||||
2usize.pow(24),
|
||||
Limit::new(2usize.pow(24)),
|
||||
),
|
||||
pattern_complexity_limit: get_limit(
|
||||
tcx.hir().krate_attrs(),
|
||||
tcx.sess,
|
||||
sym::pattern_complexity,
|
||||
Limit::unlimited(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_recursion_limit(krate_attrs: &[impl AttributeExt], sess: &Session) -> Limit {
|
||||
get_limit(krate_attrs, sess, sym::recursion_limit, 128)
|
||||
get_limit(krate_attrs, sess, sym::recursion_limit, Limit::new(128))
|
||||
}
|
||||
|
||||
fn get_limit(
|
||||
krate_attrs: &[impl AttributeExt],
|
||||
sess: &Session,
|
||||
name: Symbol,
|
||||
default: usize,
|
||||
default: Limit,
|
||||
) -> Limit {
|
||||
match get_limit_size(krate_attrs, sess, name) {
|
||||
Some(size) => Limit::new(size),
|
||||
None => Limit::new(default),
|
||||
None => default,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2168,6 +2168,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.limits(()).move_size_limit
|
||||
}
|
||||
|
||||
pub fn pattern_complexity_limit(self) -> Limit {
|
||||
self.limits(()).pattern_complexity_limit
|
||||
}
|
||||
|
||||
/// All traits in the crate graph, including those not visible to the user.
|
||||
pub fn all_traits(self) -> impl Iterator<Item = DefId> + 'tcx {
|
||||
iter::once(LOCAL_CRATE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue