Skip to content

Commit 0d81a10

Browse files
committed
XXX: delay_as_bug_without_consuming
three cases: - if next to emit, just have delay_as_bug or emit on every path - if returning an err, use downgrade_to_delayed_bug, it will get emitted later - tokentrees.rs: replacing one set of errors with another, so just cancel the original errors
1 parent 1f3dfb4 commit 0d81a10

File tree

9 files changed

+18
-15
lines changed

9 files changed

+18
-15
lines changed

compiler/rustc_hir_typeck/src/intrinsicck.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
121121
);
122122
if from == to {
123123
err.note(format!("`{from}` does not have a fixed size"));
124+
err.emit();
124125
} else {
125126
err.note(format!("source type: `{}` ({})", from, skeleton_string(from, sk_from)))
126127
.note(format!("target type: `{}` ({})", to, skeleton_string(to, sk_to)));
127128
if let Err(LayoutError::ReferencesError(_)) = sk_from {
128-
err.delay_as_bug_without_consuming();
129+
err.delay_as_bug();
129130
} else if let Err(LayoutError::ReferencesError(_)) = sk_to {
130-
err.delay_as_bug_without_consuming();
131+
err.delay_as_bug();
132+
} else {
133+
err.emit();
131134
}
132135
}
133-
err.emit();
134136
}
135137
}

compiler/rustc_hir_typeck/src/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
385385
&& let hir::ExprKind::Assign(..) = expr.kind
386386
{
387387
// We defer to the later error produced by `check_lhs_assignable`.
388-
err.delay_as_bug_without_consuming();
388+
err.downgrade_to_delayed_bug();
389389
}
390390

391391
let suggest_deref_binop =

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
361361
);
362362
}
363363
ty::ReError(_) => {
364-
err.delay_as_bug_without_consuming();
364+
err.downgrade_to_delayed_bug();
365365
}
366366
_ => {
367367
// Ugh. This is a painful case: the hidden region is not one

compiler/rustc_infer/src/infer/error_reporting/note.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
281281
}
282282
};
283283
if sub.is_error() || sup.is_error() {
284-
err.delay_as_bug_without_consuming();
284+
err.downgrade_to_delayed_bug();
285285
}
286286
err
287287
}

compiler/rustc_parse/src/lexer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub(crate) fn parse_token_trees<'a>(
6767
let (stream, res, unmatched_delims) =
6868
tokentrees::TokenTreesReader::parse_all_token_trees(string_reader);
6969
match res {
70-
Ok(_open_spacing) if unmatched_delims.is_empty() => Ok(stream),
70+
Ok(()) if unmatched_delims.is_empty() => Ok(stream),
7171
_ => {
7272
// Return error if there are unmatched delimiters or unclosed delimiters.
7373
// We emit delimiter mismatch errors first, then emit the unclosing delimiter mismatch

compiler/rustc_parse/src/lexer/tokentrees.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ impl<'a> TokenTreesReader<'a> {
277277
parser.bump();
278278
}
279279
if !diff_errs.is_empty() {
280-
errs.iter_mut().for_each(|err| {
281-
err.delay_as_bug_without_consuming();
282-
});
280+
for err in errs {
281+
err.cancel();
282+
}
283283
return diff_errs;
284284
}
285285
return errs;

compiler/rustc_parse/src/parser/pat.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'a> Parser<'a> {
241241
Some(TopLevelOrPatternNotAllowedSugg::WrapInParens { span, pat })
242242
};
243243

244-
let mut err = self.dcx().create_err(match syntax_loc {
244+
let err = self.dcx().create_err(match syntax_loc {
245245
PatternLocation::LetBinding => {
246246
TopLevelOrPatternNotAllowed::LetBinding { span, sub }
247247
}
@@ -250,9 +250,10 @@ impl<'a> Parser<'a> {
250250
}
251251
});
252252
if trailing_vert {
253-
err.delay_as_bug_without_consuming();
253+
err.delay_as_bug();
254+
} else {
255+
err.emit();
254256
}
255-
err.emit();
256257
}
257258

258259
Ok((pat, colon))

compiler/rustc_passes/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'_, G> for BreakNonLoop<'a> {
10401040
// This error is redundant, we will have already emitted a
10411041
// suggestion to use the label when `segment` wasn't found
10421042
// (hence the `Res::Err` check).
1043-
diag.delay_as_bug_without_consuming();
1043+
diag.downgrade_to_delayed_bug();
10441044
}
10451045
_ => {
10461046
diag.span_suggestion(

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
20892089
let ty = self.resolve_vars_if_possible(returned_ty);
20902090
if ty.references_error() {
20912091
// don't print out the [type error] here
2092-
err.delay_as_bug_without_consuming();
2092+
err.downgrade_to_delayed_bug();
20932093
} else {
20942094
err.span_label(expr.span, format!("this returned value is of type `{ty}`"));
20952095
}

0 commit comments

Comments
 (0)