@@ -117,11 +117,14 @@ pub struct Translator<'a> {
117117 resolve_paths : bool ,
118118 source_kind : SourceKind ,
119119 macro_context_depth : usize ,
120+ emit_diagnostic_limit : usize ,
120121}
121122
122123const UNKNOWN_LOCATION : ( LineCol , LineCol ) =
123124 ( LineCol { line : 0 , col : 0 } , LineCol { line : 0 , col : 0 } ) ;
124125
126+ const EMIT_DIAGNOSTIC_LIMIT_PER_FILE : usize = 100 ;
127+
125128impl < ' a > Translator < ' a > {
126129 pub fn new (
127130 trap : TrapFile ,
@@ -142,6 +145,7 @@ impl<'a> Translator<'a> {
142145 resolve_paths : resolve_paths == ResolvePaths :: Yes ,
143146 source_kind,
144147 macro_context_depth : 0 ,
148+ emit_diagnostic_limit : EMIT_DIAGNOSTIC_LIMIT_PER_FILE ,
145149 }
146150 }
147151 fn location ( & self , range : TextRange ) -> Option < ( LineCol , LineCol ) > {
@@ -238,7 +242,8 @@ impl<'a> Translator<'a> {
238242 & full_message,
239243 ) ;
240244
241- if severity > DiagnosticSeverity :: Debug {
245+ if severity > DiagnosticSeverity :: Debug && self . emit_diagnostic_limit > 0 {
246+ self . diagnostic_count -= 1 ;
242247 let location = self . trap . emit_location_label ( self . label , start, end) ;
243248 self . trap
244249 . emit_diagnostic ( severity, tag, message, full_message, location) ;
0 commit comments