|
1 | 1 | use std::any::Any;
|
2 |
| -use std::ops::{Div, Mul}; |
3 | 2 | use std::path::{Path, PathBuf};
|
4 | 3 | use std::str::FromStr;
|
5 | 4 | use std::sync::Arc;
|
6 | 5 | use std::sync::atomic::AtomicBool;
|
7 |
| -use std::{env, fmt, io}; |
| 6 | +use std::{env, io}; |
8 | 7 |
|
| 8 | +pub use rustc_ast::Limit; |
9 | 9 | use rustc_data_structures::flock;
|
10 | 10 | use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
11 | 11 | use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
|
@@ -58,59 +58,6 @@ pub enum CtfeBacktrace {
|
58 | 58 | Immediate,
|
59 | 59 | }
|
60 | 60 |
|
61 |
| -/// New-type wrapper around `usize` for representing limits. Ensures that comparisons against |
62 |
| -/// limits are consistent throughout the compiler. |
63 |
| -#[derive(Clone, Copy, Debug, HashStable_Generic)] |
64 |
| -pub struct Limit(pub usize); |
65 |
| - |
66 |
| -impl Limit { |
67 |
| - /// Create a new limit from a `usize`. |
68 |
| - pub fn new(value: usize) -> Self { |
69 |
| - Limit(value) |
70 |
| - } |
71 |
| - |
72 |
| - /// Check that `value` is within the limit. Ensures that the same comparisons are used |
73 |
| - /// throughout the compiler, as mismatches can cause ICEs, see #72540. |
74 |
| - #[inline] |
75 |
| - pub fn value_within_limit(&self, value: usize) -> bool { |
76 |
| - value <= self.0 |
77 |
| - } |
78 |
| -} |
79 |
| - |
80 |
| -impl From<usize> for Limit { |
81 |
| - fn from(value: usize) -> Self { |
82 |
| - Self::new(value) |
83 |
| - } |
84 |
| -} |
85 |
| - |
86 |
| -impl fmt::Display for Limit { |
87 |
| - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
88 |
| - self.0.fmt(f) |
89 |
| - } |
90 |
| -} |
91 |
| - |
92 |
| -impl Div<usize> for Limit { |
93 |
| - type Output = Limit; |
94 |
| - |
95 |
| - fn div(self, rhs: usize) -> Self::Output { |
96 |
| - Limit::new(self.0 / rhs) |
97 |
| - } |
98 |
| -} |
99 |
| - |
100 |
| -impl Mul<usize> for Limit { |
101 |
| - type Output = Limit; |
102 |
| - |
103 |
| - fn mul(self, rhs: usize) -> Self::Output { |
104 |
| - Limit::new(self.0 * rhs) |
105 |
| - } |
106 |
| -} |
107 |
| - |
108 |
| -impl rustc_errors::IntoDiagArg for Limit { |
109 |
| - fn into_diag_arg(self) -> rustc_errors::DiagArgValue { |
110 |
| - self.to_string().into_diag_arg() |
111 |
| - } |
112 |
| -} |
113 |
| - |
114 | 61 | #[derive(Clone, Copy, Debug, HashStable_Generic)]
|
115 | 62 | pub struct Limits {
|
116 | 63 | /// The maximum recursion limit for potentially infinitely recursive
|
|
0 commit comments