@@ -117,11 +117,14 @@ pub struct Translator<'a> {
117
117
resolve_paths : bool ,
118
118
source_kind : SourceKind ,
119
119
macro_context_depth : usize ,
120
+ emit_diagnostic_limit : usize ,
120
121
}
121
122
122
123
const UNKNOWN_LOCATION : ( LineCol , LineCol ) =
123
124
( LineCol { line : 0 , col : 0 } , LineCol { line : 0 , col : 0 } ) ;
124
125
126
+ const EMIT_DIAGNOSTIC_LIMIT_PER_FILE : usize = 100 ;
127
+
125
128
impl < ' a > Translator < ' a > {
126
129
pub fn new (
127
130
trap : TrapFile ,
@@ -142,6 +145,7 @@ impl<'a> Translator<'a> {
142
145
resolve_paths : resolve_paths == ResolvePaths :: Yes ,
143
146
source_kind,
144
147
macro_context_depth : 0 ,
148
+ emit_diagnostic_limit : EMIT_DIAGNOSTIC_LIMIT_PER_FILE ,
145
149
}
146
150
}
147
151
fn location ( & self , range : TextRange ) -> Option < ( LineCol , LineCol ) > {
@@ -238,7 +242,8 @@ impl<'a> Translator<'a> {
238
242
& full_message,
239
243
) ;
240
244
241
- if severity > DiagnosticSeverity :: Debug {
245
+ if severity > DiagnosticSeverity :: Debug && self . emit_diagnostic_limit > 0 {
246
+ self . diagnostic_count -= 1 ;
242
247
let location = self . trap . emit_location_label ( self . label , start, end) ;
243
248
self . trap
244
249
. emit_diagnostic ( severity, tag, message, full_message, location) ;
0 commit comments