Auto merge of #118470 - nnethercote:cleanup-error-handlers, r=compiler-errors
Cleanup error handlers Mostly by making function naming more consistent. More to do after this, but this is enough for one PR. r? compiler-errors
This commit is contained in:
commit
2da59b8676
170 changed files with 495 additions and 517 deletions
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
pub trait LayoutCalculator {
|
pub trait LayoutCalculator {
|
||||||
type TargetDataLayoutRef: Borrow<TargetDataLayout>;
|
type TargetDataLayoutRef: Borrow<TargetDataLayout>;
|
||||||
|
|
||||||
fn delay_bug(&self, txt: String);
|
fn delayed_bug(&self, txt: String);
|
||||||
fn current_data_layout(&self) -> Self::TargetDataLayoutRef;
|
fn current_data_layout(&self) -> Self::TargetDataLayoutRef;
|
||||||
|
|
||||||
fn scalar_pair<FieldIdx: Idx, VariantIdx: Idx>(
|
fn scalar_pair<FieldIdx: Idx, VariantIdx: Idx>(
|
||||||
|
@ -792,7 +792,7 @@ pub trait LayoutCalculator {
|
||||||
let only_variant = &variants[VariantIdx::new(0)];
|
let only_variant = &variants[VariantIdx::new(0)];
|
||||||
for field in only_variant {
|
for field in only_variant {
|
||||||
if field.is_unsized() {
|
if field.is_unsized() {
|
||||||
self.delay_bug("unsized field in union".to_string());
|
self.delayed_bug("unsized field in union".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
align = align.max(field.align);
|
align = align.max(field.align);
|
||||||
|
@ -1038,7 +1038,7 @@ fn univariant<
|
||||||
for &i in &inverse_memory_index {
|
for &i in &inverse_memory_index {
|
||||||
let field = &fields[i];
|
let field = &fields[i];
|
||||||
if !sized {
|
if !sized {
|
||||||
this.delay_bug(format!(
|
this.delayed_bug(format!(
|
||||||
"univariant: field #{} comes after unsized field",
|
"univariant: field #{} comes after unsized field",
|
||||||
offsets.len(),
|
offsets.len(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -327,7 +327,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
),
|
),
|
||||||
ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
|
ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
|
||||||
ExprKind::Err => hir::ExprKind::Err(
|
ExprKind::Err => hir::ExprKind::Err(
|
||||||
self.tcx.sess.delay_span_bug(e.span, "lowered ExprKind::Err"),
|
self.tcx.sess.span_delayed_bug(e.span, "lowered ExprKind::Err"),
|
||||||
),
|
),
|
||||||
ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr),
|
ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr),
|
||||||
|
|
||||||
|
@ -799,7 +799,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
self.expr_ident_mut(span, task_context_ident, task_context_hid)
|
self.expr_ident_mut(span, task_context_ident, task_context_hid)
|
||||||
} else {
|
} else {
|
||||||
// Use of `await` outside of an async context, we cannot use `task_context` here.
|
// Use of `await` outside of an async context, we cannot use `task_context` here.
|
||||||
self.expr_err(span, self.tcx.sess.delay_span_bug(span, "no task_context hir id"))
|
self.expr_err(span, self.tcx.sess.span_delayed_bug(span, "no task_context hir id"))
|
||||||
};
|
};
|
||||||
let new_unchecked = self.expr_call_lang_item_fn_mut(
|
let new_unchecked = self.expr_call_lang_item_fn_mut(
|
||||||
span,
|
span,
|
||||||
|
|
|
@ -267,7 +267,7 @@ fn make_count<'hir>(
|
||||||
ctx.expr(
|
ctx.expr(
|
||||||
sp,
|
sp,
|
||||||
hir::ExprKind::Err(
|
hir::ExprKind::Err(
|
||||||
ctx.tcx.sess.delay_span_bug(sp, "lowered bad format_args count"),
|
ctx.tcx.sess.span_delayed_bug(sp, "lowered bad format_args count"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ fn make_format_spec<'hir>(
|
||||||
}
|
}
|
||||||
Err(_) => ctx.expr(
|
Err(_) => ctx.expr(
|
||||||
sp,
|
sp,
|
||||||
hir::ExprKind::Err(ctx.tcx.sess.delay_span_bug(sp, "lowered bad format_args count")),
|
hir::ExprKind::Err(ctx.tcx.sess.span_delayed_bug(sp, "lowered bad format_args count")),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let &FormatOptions {
|
let &FormatOptions {
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
||||||
|this| match ty {
|
|this| match ty {
|
||||||
None => {
|
None => {
|
||||||
let guar = this.tcx.sess.delay_span_bug(
|
let guar = this.tcx.sess.span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
"expected to lower type alias type, but it was missing",
|
"expected to lower type alias type, but it was missing",
|
||||||
);
|
);
|
||||||
|
@ -863,7 +863,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
||||||
|this| match ty {
|
|this| match ty {
|
||||||
None => {
|
None => {
|
||||||
let guar = this.tcx.sess.delay_span_bug(
|
let guar = this.tcx.sess.span_delayed_bug(
|
||||||
i.span,
|
i.span,
|
||||||
"expected to lower associated type, but it was missing",
|
"expected to lower associated type, but it was missing",
|
||||||
);
|
);
|
||||||
|
@ -996,7 +996,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Expr<'hir> {
|
fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Expr<'hir> {
|
||||||
match block {
|
match block {
|
||||||
Some(block) => self.lower_block_expr(block),
|
Some(block) => self.lower_block_expr(block),
|
||||||
None => self.expr_err(span, self.tcx.sess.delay_span_bug(span, "no block")),
|
None => self.expr_err(span, self.tcx.sess.span_delayed_bug(span, "no block")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,7 +1006,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
&[],
|
&[],
|
||||||
match expr {
|
match expr {
|
||||||
Some(expr) => this.lower_expr_mut(expr),
|
Some(expr) => this.lower_expr_mut(expr),
|
||||||
None => this.expr_err(span, this.tcx.sess.delay_span_bug(span, "no block")),
|
None => this.expr_err(span, this.tcx.sess.span_delayed_bug(span, "no block")),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -54,7 +54,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::sorted_map::SortedMap;
|
use rustc_data_structures::sorted_map::SortedMap;
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::{DiagnosticArgFromDisplay, Handler, StashKey};
|
use rustc_errors::{DiagnosticArgFromDisplay, StashKey};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
|
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
|
||||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||||
|
@ -763,10 +763,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
self.resolver.get_import_res(id).present_items()
|
self.resolver.get_import_res(id).present_items()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diagnostic(&self) -> &Handler {
|
|
||||||
self.tcx.sess.diagnostic()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reuses the span but adds information like the kind of the desugaring and features that are
|
/// Reuses the span but adds information like the kind of the desugaring and features that are
|
||||||
/// allowed inside this span.
|
/// allowed inside this span.
|
||||||
fn mark_span_with_reason(
|
fn mark_span_with_reason(
|
||||||
|
@ -1326,7 +1322,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
let kind = match &t.kind {
|
let kind = match &t.kind {
|
||||||
TyKind::Infer => hir::TyKind::Infer,
|
TyKind::Infer => hir::TyKind::Infer,
|
||||||
TyKind::Err => {
|
TyKind::Err => {
|
||||||
hir::TyKind::Err(self.tcx.sess.delay_span_bug(t.span, "TyKind::Err lowered"))
|
hir::TyKind::Err(self.tcx.sess.span_delayed_bug(t.span, "TyKind::Err lowered"))
|
||||||
}
|
}
|
||||||
// FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
|
// FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
|
@ -1510,7 +1506,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
}
|
}
|
||||||
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
|
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
|
||||||
TyKind::CVarArgs => {
|
TyKind::CVarArgs => {
|
||||||
let guar = self.tcx.sess.delay_span_bug(
|
let guar = self.tcx.sess.span_delayed_bug(
|
||||||
t.span,
|
t.span,
|
||||||
"`TyKind::CVarArgs` should have been handled elsewhere",
|
"`TyKind::CVarArgs` should have been handled elsewhere",
|
||||||
);
|
);
|
||||||
|
@ -1653,7 +1649,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
} else {
|
} else {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(lifetime.ident.span, "no def-id for fresh lifetime");
|
.span_delayed_bug(lifetime.ident.span, "no def-id for fresh lifetime");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2515,9 +2511,10 @@ impl<'hir> GenericArgsCtor<'hir> {
|
||||||
let hir_id = lcx.next_id();
|
let hir_id = lcx.next_id();
|
||||||
|
|
||||||
let Some(host_param_id) = lcx.host_param_id else {
|
let Some(host_param_id) = lcx.host_param_id else {
|
||||||
lcx.tcx
|
lcx.tcx.sess.span_delayed_bug(
|
||||||
.sess
|
span,
|
||||||
.delay_span_bug(span, "no host param id for call in const yet no errors reported");
|
"no host param id for call in const yet no errors reported",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
// We should've returned in the for loop above.
|
// We should've returned in the for loop above.
|
||||||
|
|
||||||
self.diagnostic().span_bug(
|
self.tcx.sess.diagnostic().span_bug(
|
||||||
p.span,
|
p.span,
|
||||||
format!(
|
format!(
|
||||||
"lower_qpath: no final extension segment in {}..{}",
|
"lower_qpath: no final extension segment in {}..{}",
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl<'a> PostExpansionVisitor<'a> {
|
||||||
}
|
}
|
||||||
Err(abi::AbiDisabled::Unrecognized) => {
|
Err(abi::AbiDisabled::Unrecognized) => {
|
||||||
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
|
if self.sess.opts.pretty.map_or(true, |ppm| ppm.needs_hir()) {
|
||||||
self.sess.parse_sess.span_diagnostic.delay_span_bug(
|
self.sess.diagnostic().span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"unrecognized ABI not caught in lowering: {}",
|
"unrecognized ABI not caught in lowering: {}",
|
||||||
|
@ -627,7 +627,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
|
||||||
if all_stable {
|
if all_stable {
|
||||||
err.sugg = Some(attr.span);
|
err.sugg = Some(attr.span);
|
||||||
}
|
}
|
||||||
sess.parse_sess.span_diagnostic.emit_err(err);
|
sess.diagnostic().emit_err(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -945,7 +945,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {attr:?}");
|
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {attr:?}");
|
||||||
use ReprAttr::*;
|
use ReprAttr::*;
|
||||||
let mut acc = Vec::new();
|
let mut acc = Vec::new();
|
||||||
let diagnostic = &sess.parse_sess.span_diagnostic;
|
let diagnostic = sess.diagnostic();
|
||||||
|
|
||||||
if let Some(items) = attr.meta_item_list() {
|
if let Some(items) = attr.meta_item_list() {
|
||||||
for item in items {
|
for item in items {
|
||||||
|
@ -1060,9 +1060,9 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||||
// Not a word we recognize. This will be caught and reported by
|
// Not a word we recognize. This will be caught and reported by
|
||||||
// the `check_mod_attrs` pass, but this pass doesn't always run
|
// the `check_mod_attrs` pass, but this pass doesn't always run
|
||||||
// (e.g. if we only pretty-print the source), so we have to gate
|
// (e.g. if we only pretty-print the source), so we have to gate
|
||||||
// the `delay_span_bug` call as follows:
|
// the `span_delayed_bug` call as follows:
|
||||||
if sess.opts.pretty.map_or(true, |pp| pp.needs_analysis()) {
|
if sess.opts.pretty.map_or(true, |pp| pp.needs_analysis()) {
|
||||||
diagnostic.delay_span_bug(item.span(), "unrecognized representation hint");
|
diagnostic.span_delayed_bug(item.span(), "unrecognized representation hint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,7 +385,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
|
||||||
error_region: Option<ty::Region<'tcx>>,
|
error_region: Option<ty::Region<'tcx>>,
|
||||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||||
// We generally shouldn't have errors here because the query was
|
// We generally shouldn't have errors here because the query was
|
||||||
// already run, but there's no point using `delay_span_bug`
|
// already run, but there's no point using `span_delayed_bug`
|
||||||
// when we're going to emit an error here anyway.
|
// when we're going to emit an error here anyway.
|
||||||
let _errors = ocx.select_all_or_error();
|
let _errors = ocx.select_all_or_error();
|
||||||
let region_constraints = ocx.infcx.with_region_constraints(|r| r.clone());
|
let region_constraints = ocx.infcx.with_region_constraints(|r| r.clone());
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
issued_spans.var_subdiag(
|
issued_spans.var_subdiag(
|
||||||
Some(&self.infcx.tcx.sess.parse_sess.span_diagnostic),
|
Some(self.infcx.tcx.sess.diagnostic()),
|
||||||
&mut err,
|
&mut err,
|
||||||
Some(issued_borrow.kind),
|
Some(issued_borrow.kind),
|
||||||
|kind, var_span| {
|
|kind, var_span| {
|
||||||
|
@ -1152,7 +1152,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
borrow_spans.var_subdiag(
|
borrow_spans.var_subdiag(
|
||||||
Some(&self.infcx.tcx.sess.parse_sess.span_diagnostic),
|
Some(self.infcx.tcx.sess.diagnostic()),
|
||||||
&mut err,
|
&mut err,
|
||||||
Some(gen_borrow_kind),
|
Some(gen_borrow_kind),
|
||||||
|kind, var_span| {
|
|kind, var_span| {
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let did = did.expect_local();
|
let did = did.expect_local();
|
||||||
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
|
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
|
||||||
diag.eager_subdiagnostic(
|
diag.eager_subdiagnostic(
|
||||||
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
|
self.infcx.tcx.sess.diagnostic(),
|
||||||
OnClosureNote::InvokedTwice {
|
OnClosureNote::InvokedTwice {
|
||||||
place_name: &ty::place_to_string_for_capture(
|
place_name: &ty::place_to_string_for_capture(
|
||||||
self.infcx.tcx,
|
self.infcx.tcx,
|
||||||
|
@ -146,7 +146,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let did = did.expect_local();
|
let did = did.expect_local();
|
||||||
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
|
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
|
||||||
diag.eager_subdiagnostic(
|
diag.eager_subdiagnostic(
|
||||||
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
|
self.infcx.tcx.sess.diagnostic(),
|
||||||
OnClosureNote::MovedTwice {
|
OnClosureNote::MovedTwice {
|
||||||
place_name: &ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
|
place_name: &ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
|
||||||
span: *span,
|
span: *span,
|
||||||
|
@ -1119,7 +1119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
&& self.infcx.can_eq(self.param_env, ty, self_ty)
|
&& self.infcx.can_eq(self.param_env, ty, self_ty)
|
||||||
{
|
{
|
||||||
err.eager_subdiagnostic(
|
err.eager_subdiagnostic(
|
||||||
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
|
self.infcx.tcx.sess.diagnostic(),
|
||||||
CaptureReasonSuggest::FreshReborrow {
|
CaptureReasonSuggest::FreshReborrow {
|
||||||
span: move_span.shrink_to_hi(),
|
span: move_span.shrink_to_hi(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl<'tcx> RegionErrors<'tcx> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
||||||
let val = val.into();
|
let val = val.into();
|
||||||
self.1.sess.delay_span_bug(DUMMY_SP, format!("{val:?}"));
|
self.1.sess.span_delayed_bug(DUMMY_SP, format!("{val:?}"));
|
||||||
self.0.push(val);
|
self.0.push(val);
|
||||||
}
|
}
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
|
|
|
@ -619,8 +619,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
// HIR lowering sometimes doesn't catch this in erroneous
|
// HIR lowering sometimes doesn't catch this in erroneous
|
||||||
// programs, so we need to use delay_span_bug here. See #82126.
|
// programs, so we need to use span_delayed_bug here. See #82126.
|
||||||
self.infcx.tcx.sess.delay_span_bug(
|
self.infcx.tcx.sess.span_delayed_bug(
|
||||||
hir_arg.span(),
|
hir_arg.span(),
|
||||||
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
|
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -2130,11 +2130,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
&& !self.has_buffered_errors()
|
&& !self.has_buffered_errors()
|
||||||
{
|
{
|
||||||
// rust-lang/rust#46908: In pure NLL mode this code path should be
|
// rust-lang/rust#46908: In pure NLL mode this code path should be
|
||||||
// unreachable, but we use `delay_span_bug` because we can hit this when
|
// unreachable, but we use `span_delayed_bug` because we can hit this when
|
||||||
// dereferencing a non-Copy raw pointer *and* have `-Ztreat-err-as-bug`
|
// dereferencing a non-Copy raw pointer *and* have `-Ztreat-err-as-bug`
|
||||||
// enabled. We don't want to ICE for that case, as other errors will have
|
// enabled. We don't want to ICE for that case, as other errors will have
|
||||||
// been emitted (#52262).
|
// been emitted (#52262).
|
||||||
self.infcx.tcx.sess.delay_span_bug(
|
self.infcx.tcx.sess.span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"Accessing `{place:?}` with the kind `{kind:?}` shouldn't be possible",
|
"Accessing `{place:?}` with the kind `{kind:?}` shouldn't be possible",
|
||||||
|
@ -2428,7 +2428,7 @@ mod error {
|
||||||
|
|
||||||
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
|
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
|
||||||
if let None = self.tainted_by_errors {
|
if let None = self.tainted_by_errors {
|
||||||
self.tainted_by_errors = Some(self.tcx.sess.delay_span_bug(
|
self.tainted_by_errors = Some(self.tcx.sess.span_delayed_bug(
|
||||||
t.span.clone_ignoring_labels(),
|
t.span.clone_ignoring_labels(),
|
||||||
"diagnostic buffered but not emitted",
|
"diagnostic buffered but not emitted",
|
||||||
))
|
))
|
||||||
|
|
|
@ -187,7 +187,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
||||||
|
|
||||||
if !nll_errors.is_empty() {
|
if !nll_errors.is_empty() {
|
||||||
// Suppress unhelpful extra errors in `infer_opaque_types`.
|
// Suppress unhelpful extra errors in `infer_opaque_types`.
|
||||||
infcx.set_tainted_by_errors(infcx.tcx.sess.delay_span_bug(
|
infcx.set_tainted_by_errors(infcx.tcx.sess.span_delayed_bug(
|
||||||
body.span,
|
body.span,
|
||||||
"`compute_regions` tainted `infcx` with errors but did not emit any errors",
|
"`compute_regions` tainted `infcx` with errors but did not emit any errors",
|
||||||
));
|
));
|
||||||
|
@ -280,7 +280,7 @@ pub(super) fn dump_annotation<'tcx>(
|
||||||
|
|
||||||
let def_span = tcx.def_span(body.source.def_id());
|
let def_span = tcx.def_span(body.source.def_id());
|
||||||
let mut err = if let Some(closure_region_requirements) = closure_region_requirements {
|
let mut err = if let Some(closure_region_requirements) = closure_region_requirements {
|
||||||
let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "external requirements");
|
let mut err = tcx.sess.diagnostic().struct_span_note(def_span, "external requirements");
|
||||||
|
|
||||||
regioncx.annotate(tcx, &mut err);
|
regioncx.annotate(tcx, &mut err);
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ pub(super) fn dump_annotation<'tcx>(
|
||||||
|
|
||||||
err
|
err
|
||||||
} else {
|
} else {
|
||||||
let mut err = tcx.sess.diagnostic().span_note_diag(def_span, "no external requirements");
|
let mut err = tcx.sess.diagnostic().struct_span_note(def_span, "no external requirements");
|
||||||
regioncx.annotate(tcx, &mut err);
|
regioncx.annotate(tcx, &mut err);
|
||||||
|
|
||||||
err
|
err
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
if argument_index + 1 >= body.local_decls.len() {
|
if argument_index + 1 >= body.local_decls.len() {
|
||||||
self.tcx()
|
self.tcx()
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(body.span, "found more normalized_input_ty than local_decls");
|
.span_delayed_bug(body.span, "found more normalized_input_ty than local_decls");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,10 +101,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
// We will not have a universal_regions.yield_ty if we yield (by accident)
|
// We will not have a universal_regions.yield_ty if we yield (by accident)
|
||||||
// outside of a coroutine and return an `impl Trait`, so emit a delay_span_bug
|
// outside of a coroutine and return an `impl Trait`, so emit a span_delayed_bug
|
||||||
// because we don't want to panic in an assert here if we've already got errors.
|
// because we don't want to panic in an assert here if we've already got errors.
|
||||||
if body.yield_ty().is_some() != universal_regions.yield_ty.is_some() {
|
if body.yield_ty().is_some() != universal_regions.yield_ty.is_some() {
|
||||||
self.tcx().sess.delay_span_bug(
|
self.tcx().sess.span_delayed_bug(
|
||||||
body.span,
|
body.span,
|
||||||
format!(
|
format!(
|
||||||
"Expected body to have yield_ty ({:?}) iff we have a UR yield_ty ({:?})",
|
"Expected body to have yield_ty ({:?}) iff we have a UR yield_ty ({:?})",
|
||||||
|
|
|
@ -225,7 +225,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
||||||
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
|
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
|
||||||
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
|
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
|
||||||
if hidden_type.has_non_region_infer() {
|
if hidden_type.has_non_region_infer() {
|
||||||
let reported = infcx.tcx.sess.delay_span_bug(
|
let reported = infcx.tcx.sess.span_delayed_bug(
|
||||||
decl.hidden_type.span,
|
decl.hidden_type.span,
|
||||||
format!("could not resolve {:#?}", hidden_type.ty.kind()),
|
format!("could not resolve {:#?}", hidden_type.ty.kind()),
|
||||||
);
|
);
|
||||||
|
@ -267,9 +267,9 @@ fn translate_outlives_facts(typeck: &mut TypeChecker<'_, '_>) {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: String) {
|
fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: String) {
|
||||||
// We sometimes see MIR failures (notably predicate failures) due to
|
// We sometimes see MIR failures (notably predicate failures) due to
|
||||||
// the fact that we check rvalue sized predicates here. So use `delay_span_bug`
|
// the fact that we check rvalue sized predicates here. So use `span_delayed_bug`
|
||||||
// to avoid reporting bugs in those cases.
|
// to avoid reporting bugs in those cases.
|
||||||
tcx.sess.diagnostic().delay_span_bug(span, msg);
|
tcx.sess.diagnostic().span_delayed_bug(span, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FieldAccessError {
|
enum FieldAccessError {
|
||||||
|
@ -1068,7 +1068,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
self.infcx.tcx.sess.delay_span_bug(
|
self.infcx.tcx.sess.span_delayed_bug(
|
||||||
self.body.span,
|
self.body.span,
|
||||||
"failed re-defining predefined opaques in mir typeck",
|
"failed re-defining predefined opaques in mir typeck",
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,10 +31,7 @@ pub fn expand(
|
||||||
{
|
{
|
||||||
(item, true, ecx.with_def_site_ctxt(fn_kind.sig.span))
|
(item, true, ecx.with_def_site_ctxt(fn_kind.sig.span))
|
||||||
} else {
|
} else {
|
||||||
ecx.sess
|
ecx.sess.diagnostic().emit_err(errors::AllocErrorMustBeFn { span: item.span() });
|
||||||
.parse_sess
|
|
||||||
.span_diagnostic
|
|
||||||
.emit_err(errors::AllocErrorMustBeFn { span: item.span() });
|
|
||||||
return vec![orig_item];
|
return vec![orig_item];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,7 @@ pub fn expand(
|
||||||
{
|
{
|
||||||
(item, true, ecx.with_def_site_ctxt(ty.span))
|
(item, true, ecx.with_def_site_ctxt(ty.span))
|
||||||
} else {
|
} else {
|
||||||
ecx.sess
|
ecx.sess.diagnostic().emit_err(errors::AllocMustStatics { span: item.span() });
|
||||||
.parse_sess
|
|
||||||
.span_diagnostic
|
|
||||||
.emit_err(errors::AllocMustStatics { span: item.span() });
|
|
||||||
return vec![orig_item];
|
return vec![orig_item];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -389,7 +389,7 @@ pub fn expand_test_or_bench(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) {
|
fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) {
|
||||||
let diag = &cx.sess.parse_sess.span_diagnostic;
|
let diag = cx.sess.diagnostic();
|
||||||
let msg = "the `#[test]` attribute may only be used on a non-associated function";
|
let msg = "the `#[test]` attribute may only be used on a non-associated function";
|
||||||
let mut err = match item.map(|i| &i.kind) {
|
let mut err = match item.map(|i| &i.kind) {
|
||||||
// These were a warning before #92959 and need to continue being that to avoid breaking
|
// These were a warning before #92959 and need to continue being that to avoid breaking
|
||||||
|
@ -466,7 +466,7 @@ fn should_ignore_message(i: &ast::Item) -> Option<Symbol> {
|
||||||
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
|
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
|
||||||
match attr::find_by_name(&i.attrs, sym::should_panic) {
|
match attr::find_by_name(&i.attrs, sym::should_panic) {
|
||||||
Some(attr) => {
|
Some(attr) => {
|
||||||
let sd = &cx.sess.parse_sess.span_diagnostic;
|
let sd = cx.sess.diagnostic();
|
||||||
|
|
||||||
match attr.meta_item_list() {
|
match attr.meta_item_list() {
|
||||||
// Handle #[should_panic(expected = "foo")]
|
// Handle #[should_panic(expected = "foo")]
|
||||||
|
@ -535,7 +535,7 @@ fn check_test_signature(
|
||||||
f: &ast::Fn,
|
f: &ast::Fn,
|
||||||
) -> Result<(), ErrorGuaranteed> {
|
) -> Result<(), ErrorGuaranteed> {
|
||||||
let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic);
|
let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic);
|
||||||
let sd = &cx.sess.parse_sess.span_diagnostic;
|
let sd = cx.sess.diagnostic();
|
||||||
|
|
||||||
if let ast::Unsafe::Yes(span) = f.sig.header.unsafety {
|
if let ast::Unsafe::Yes(span) = f.sig.header.unsafety {
|
||||||
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
|
return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }));
|
||||||
|
@ -579,7 +579,7 @@ fn check_bench_signature(
|
||||||
// N.B., inadequate check, but we're running
|
// N.B., inadequate check, but we're running
|
||||||
// well before resolve, can't get too deep.
|
// well before resolve, can't get too deep.
|
||||||
if f.sig.decl.inputs.len() != 1 {
|
if f.sig.decl.inputs.len() != 1 {
|
||||||
return Err(cx.sess.parse_sess.span_diagnostic.emit_err(errors::BenchSig { span: i.span }));
|
return Err(cx.sess.diagnostic().emit_err(errors::BenchSig { span: i.span }));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ pub fn link_binary<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if sess.opts.json_artifact_notifications {
|
if sess.opts.json_artifact_notifications {
|
||||||
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link");
|
sess.diagnostic().emit_artifact_notification(&out_filename, "link");
|
||||||
}
|
}
|
||||||
|
|
||||||
if sess.prof.enabled() {
|
if sess.prof.enabled() {
|
||||||
|
@ -1464,7 +1464,7 @@ fn print_native_static_libs(
|
||||||
sess.emit_note(errors::StaticLibraryNativeArtifacts);
|
sess.emit_note(errors::StaticLibraryNativeArtifacts);
|
||||||
// Prefix for greppability
|
// Prefix for greppability
|
||||||
// Note: This must not be translated as tools are allowed to depend on this exact string.
|
// Note: This must not be translated as tools are allowed to depend on this exact string.
|
||||||
sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" ")));
|
sess.note(format!("native-static-libs: {}", &lib_args.join(" ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1856,7 +1856,7 @@ impl SharedEmitterMain {
|
||||||
let mut err = match level {
|
let mut err = match level {
|
||||||
Level::Error { lint: false } => sess.struct_err(msg).forget_guarantee(),
|
Level::Error { lint: false } => sess.struct_err(msg).forget_guarantee(),
|
||||||
Level::Warning(_) => sess.struct_warn(msg),
|
Level::Warning(_) => sess.struct_warn(msg),
|
||||||
Level::Note => sess.struct_note_without_error(msg),
|
Level::Note => sess.struct_note(msg),
|
||||||
_ => bug!("Invalid inline asm diagnostic level"),
|
_ => bug!("Invalid inline asm diagnostic level"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
Some(tcx.fn_sig(did))
|
Some(tcx.fn_sig(did))
|
||||||
} else {
|
} else {
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.delay_span_bug(attr.span, "this attribute can only be applied to functions");
|
.span_delayed_bug(attr.span, "this attribute can only be applied to functions");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,7 +148,7 @@ where
|
||||||
let mut err = tcx.sess.create_err(err);
|
let mut err = tcx.sess.create_err(err);
|
||||||
|
|
||||||
let msg = error.diagnostic_message();
|
let msg = error.diagnostic_message();
|
||||||
error.add_args(&tcx.sess.parse_sess.span_diagnostic, &mut err);
|
error.add_args(tcx.sess.diagnostic(), &mut err);
|
||||||
|
|
||||||
// Use *our* span to label the interp error
|
// Use *our* span to label the interp error
|
||||||
err.span_label(our_span, msg);
|
err.span_label(our_span, msg);
|
||||||
|
|
|
@ -391,7 +391,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
if ecx.tcx.is_ctfe_mir_available(def) {
|
if ecx.tcx.is_ctfe_mir_available(def) {
|
||||||
Ok(ecx.tcx.mir_for_ctfe(def))
|
Ok(ecx.tcx.mir_for_ctfe(def))
|
||||||
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
|
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
|
||||||
let guar = ecx.tcx.sess.delay_span_bug(
|
let guar = ecx.tcx.sess.span_delayed_bug(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
"This is likely a const item that is missing from its impl",
|
"This is likely a const item that is missing from its impl",
|
||||||
);
|
);
|
||||||
|
@ -622,7 +622,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
let guard = ecx
|
let guard = ecx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, "The deny lint should have already errored");
|
.span_delayed_bug(span, "The deny lint should have already errored");
|
||||||
throw_inval!(AlreadyReported(guard.into()));
|
throw_inval!(AlreadyReported(guard.into()));
|
||||||
}
|
}
|
||||||
} else if new_steps > start && new_steps.is_power_of_two() {
|
} else if new_steps > start && new_steps.is_power_of_two() {
|
||||||
|
|
|
@ -437,7 +437,7 @@ pub trait ReportErrorExt {
|
||||||
{
|
{
|
||||||
ty::tls::with(move |tcx| {
|
ty::tls::with(move |tcx| {
|
||||||
let mut builder = tcx.sess.struct_allow(DiagnosticMessage::Str(String::new().into()));
|
let mut builder = tcx.sess.struct_allow(DiagnosticMessage::Str(String::new().into()));
|
||||||
let handler = &tcx.sess.parse_sess.span_diagnostic;
|
let handler = tcx.sess.diagnostic();
|
||||||
let message = self.diagnostic_message();
|
let message = self.diagnostic_message();
|
||||||
self.add_args(handler, &mut builder);
|
self.add_args(handler, &mut builder);
|
||||||
let s = handler.eagerly_translate_to_string(message, builder.args());
|
let s = handler.eagerly_translate_to_string(message, builder.args());
|
||||||
|
|
|
@ -287,9 +287,9 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
|
||||||
{
|
{
|
||||||
write!(f, "inside closure")
|
write!(f, "inside closure")
|
||||||
} else {
|
} else {
|
||||||
// Note: this triggers a `good_path_bug` state, which means that if we ever get here
|
// Note: this triggers a `good_path_delayed_bug` state, which means that if we ever
|
||||||
// we must emit a diagnostic. We should never display a `FrameInfo` unless we
|
// get here we must emit a diagnostic. We should never display a `FrameInfo` unless
|
||||||
// actually want to emit a warning or error to the user.
|
// we actually want to emit a warning or error to the user.
|
||||||
write!(f, "inside `{}`", self.instance)
|
write!(f, "inside `{}`", self.instance)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -303,8 +303,8 @@ impl<'tcx> FrameInfo<'tcx> {
|
||||||
errors::FrameNote { where_: "closure", span, instance: String::new(), times: 0 }
|
errors::FrameNote { where_: "closure", span, instance: String::new(), times: 0 }
|
||||||
} else {
|
} else {
|
||||||
let instance = format!("{}", self.instance);
|
let instance = format!("{}", self.instance);
|
||||||
// Note: this triggers a `good_path_bug` state, which means that if we ever get here
|
// Note: this triggers a `good_path_delayed_bug` state, which means that if we ever get
|
||||||
// we must emit a diagnostic. We should never display a `FrameInfo` unless we
|
// here we must emit a diagnostic. We should never display a `FrameInfo` unless we
|
||||||
// actually want to emit a warning or error to the user.
|
// actually want to emit a warning or error to the user.
|
||||||
errors::FrameNote { where_: "instance", span, instance, times: 0 }
|
errors::FrameNote { where_: "instance", span, instance, times: 0 }
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
backtrace.print_backtrace();
|
backtrace.print_backtrace();
|
||||||
// FIXME(fee1-dead), HACK: we want to use the error as title therefore we can just extract the
|
// FIXME(fee1-dead), HACK: we want to use the error as title therefore we can just extract the
|
||||||
// label and arguments from the InterpError.
|
// label and arguments from the InterpError.
|
||||||
let handler = &self.tcx.sess.parse_sess.span_diagnostic;
|
let handler = self.tcx.sess.diagnostic();
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
let mut diag = self.tcx.sess.struct_allow("");
|
let mut diag = self.tcx.sess.struct_allow("");
|
||||||
let msg = e.diagnostic_message();
|
let msg = e.diagnostic_message();
|
||||||
|
|
|
@ -94,9 +94,9 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
|
||||||
// If the pointer is dangling (neither in local nor global memory), we leave it
|
// If the pointer is dangling (neither in local nor global memory), we leave it
|
||||||
// to validation to error -- it has the much better error messages, pointing out where
|
// to validation to error -- it has the much better error messages, pointing out where
|
||||||
// in the value the dangling reference lies.
|
// in the value the dangling reference lies.
|
||||||
// The `delay_span_bug` ensures that we don't forget such a check in validation.
|
// The `span_delayed_bug` ensures that we don't forget such a check in validation.
|
||||||
if tcx.try_get_global_alloc(alloc_id).is_none() {
|
if tcx.try_get_global_alloc(alloc_id).is_none() {
|
||||||
tcx.sess.delay_span_bug(ecx.tcx.span, "tried to intern dangling pointer");
|
tcx.sess.span_delayed_bug(ecx.tcx.span, "tried to intern dangling pointer");
|
||||||
}
|
}
|
||||||
// treat dangling pointers like other statics
|
// treat dangling pointers like other statics
|
||||||
// just to stop trying to recurse into them
|
// just to stop trying to recurse into them
|
||||||
|
@ -186,7 +186,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
|
||||||
// Validation will error (with a better message) on an invalid vtable pointer.
|
// Validation will error (with a better message) on an invalid vtable pointer.
|
||||||
// Let validation show the error message, but make sure it *does* error.
|
// Let validation show the error message, but make sure it *does* error.
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.delay_span_bug(tcx.span, "vtables pointers cannot be integer pointers");
|
.span_delayed_bug(tcx.span, "vtables pointers cannot be integer pointers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if we have encountered this pointer+layout combination before.
|
// Check if we have encountered this pointer+layout combination before.
|
||||||
|
@ -375,7 +375,7 @@ pub fn intern_const_alloc_recursive<
|
||||||
match res {
|
match res {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
ecx.tcx.sess.delay_span_bug(
|
ecx.tcx.sess.span_delayed_bug(
|
||||||
ecx.tcx.span,
|
ecx.tcx.span,
|
||||||
format!(
|
format!(
|
||||||
"error during interning should later cause validation failure: {}",
|
"error during interning should later cause validation failure: {}",
|
||||||
|
|
|
@ -248,7 +248,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||||
// `async` functions cannot be `const fn`. This is checked during AST lowering, so there's
|
// `async` functions cannot be `const fn`. This is checked during AST lowering, so there's
|
||||||
// no need to emit duplicate errors here.
|
// no need to emit duplicate errors here.
|
||||||
if self.ccx.is_async() || body.coroutine.is_some() {
|
if self.ccx.is_async() || body.coroutine.is_some() {
|
||||||
tcx.sess.delay_span_bug(body.span, "`async` functions cannot be `const fn`");
|
tcx.sess.span_delayed_bug(body.span, "`async` functions cannot be `const fn`");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +357,9 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||||
|
|
||||||
fn check_static(&mut self, def_id: DefId, span: Span) {
|
fn check_static(&mut self, def_id: DefId, span: Span) {
|
||||||
if self.tcx.is_thread_local_static(def_id) {
|
if self.tcx.is_thread_local_static(def_id) {
|
||||||
self.tcx.sess.delay_span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
|
self.tcx
|
||||||
|
.sess
|
||||||
|
.span_delayed_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
|
||||||
}
|
}
|
||||||
self.check_op_spanned(ops::StaticAccess, span)
|
self.check_op_spanned(ops::StaticAccess, span)
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ pub fn is_const_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||||
None if is_parent_const_stable_trait(tcx, def_id) => {
|
None if is_parent_const_stable_trait(tcx, def_id) => {
|
||||||
// Remove this when `#![feature(const_trait_impl)]` is stabilized,
|
// Remove this when `#![feature(const_trait_impl)]` is stabilized,
|
||||||
// returning `true` unconditionally.
|
// returning `true` unconditionally.
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
tcx.def_span(def_id),
|
tcx.def_span(def_id),
|
||||||
"trait implementations cannot be const stable yet",
|
"trait implementations cannot be const stable yet",
|
||||||
);
|
);
|
||||||
|
|
|
@ -128,9 +128,9 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn fail(&self, location: Location, msg: impl AsRef<str>) {
|
fn fail(&self, location: Location, msg: impl AsRef<str>) {
|
||||||
let span = self.body.source_info(location).span;
|
let span = self.body.source_info(location).span;
|
||||||
// We use `delay_span_bug` as we might see broken MIR when other errors have already
|
// We use `span_delayed_bug` as we might see broken MIR when other errors have already
|
||||||
// occurred.
|
// occurred.
|
||||||
self.tcx.sess.diagnostic().delay_span_bug(
|
self.tcx.sess.diagnostic().span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"broken MIR in {:?} ({}) at {:?}:\n{}",
|
"broken MIR in {:?} ({}) at {:?}:\n{}",
|
||||||
|
@ -571,7 +571,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_source_scope(&mut self, scope: SourceScope) {
|
fn visit_source_scope(&mut self, scope: SourceScope) {
|
||||||
if self.body.source_scopes.get(scope).is_none() {
|
if self.body.source_scopes.get(scope).is_none() {
|
||||||
self.tcx.sess.diagnostic().delay_span_bug(
|
self.tcx.sess.diagnostic().span_delayed_bug(
|
||||||
self.body.span,
|
self.body.span,
|
||||||
format!(
|
format!(
|
||||||
"broken MIR in {:?} ({}):\ninvalid source scope {:?}",
|
"broken MIR in {:?} ({}):\ninvalid source scope {:?}",
|
||||||
|
|
|
@ -351,18 +351,10 @@ impl<'a> DiagnosticBuilder<'a, !> {
|
||||||
/// `struct_*` methods on [`Handler`].
|
/// `struct_*` methods on [`Handler`].
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub(crate) fn new_fatal(handler: &'a Handler, message: impl Into<DiagnosticMessage>) -> Self {
|
pub(crate) fn new_fatal(handler: &'a Handler, message: impl Into<DiagnosticMessage>) -> Self {
|
||||||
let diagnostic = Diagnostic::new_with_code(Level::Fatal, None, message);
|
|
||||||
Self::new_diagnostic_fatal(handler, diagnostic)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new `DiagnosticBuilder` with an already constructed
|
|
||||||
/// diagnostic.
|
|
||||||
pub(crate) fn new_diagnostic_fatal(handler: &'a Handler, diagnostic: Diagnostic) -> Self {
|
|
||||||
debug!("Created new diagnostic");
|
|
||||||
Self {
|
Self {
|
||||||
inner: DiagnosticBuilderInner {
|
inner: DiagnosticBuilderInner {
|
||||||
state: DiagnosticBuilderState::Emittable(handler),
|
state: DiagnosticBuilderState::Emittable(handler),
|
||||||
diagnostic: Box::new(diagnostic),
|
diagnostic: Box::new(Diagnostic::new_with_code(Level::Fatal, None, message)),
|
||||||
},
|
},
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,10 +431,10 @@ struct HandlerInner {
|
||||||
warn_count: usize,
|
warn_count: usize,
|
||||||
deduplicated_err_count: usize,
|
deduplicated_err_count: usize,
|
||||||
emitter: Box<DynEmitter>,
|
emitter: Box<DynEmitter>,
|
||||||
delayed_span_bugs: Vec<DelayedDiagnostic>,
|
span_delayed_bugs: Vec<DelayedDiagnostic>,
|
||||||
delayed_good_path_bugs: Vec<DelayedDiagnostic>,
|
good_path_delayed_bugs: Vec<DelayedDiagnostic>,
|
||||||
/// This flag indicates that an expected diagnostic was emitted and suppressed.
|
/// This flag indicates that an expected diagnostic was emitted and suppressed.
|
||||||
/// This is used for the `delayed_good_path_bugs` check.
|
/// This is used for the `good_path_delayed_bugs` check.
|
||||||
suppressed_expected_diag: bool,
|
suppressed_expected_diag: bool,
|
||||||
|
|
||||||
/// This set contains the `DiagnosticId` of all emitted diagnostics to avoid
|
/// This set contains the `DiagnosticId` of all emitted diagnostics to avoid
|
||||||
|
@ -528,7 +528,7 @@ pub struct HandlerFlags {
|
||||||
/// If true, immediately emit diagnostics that would otherwise be buffered.
|
/// If true, immediately emit diagnostics that would otherwise be buffered.
|
||||||
/// (rustc: see `-Z dont-buffer-diagnostics` and `-Z treat-err-as-bug`)
|
/// (rustc: see `-Z dont-buffer-diagnostics` and `-Z treat-err-as-bug`)
|
||||||
pub dont_buffer_diagnostics: bool,
|
pub dont_buffer_diagnostics: bool,
|
||||||
/// If true, immediately print bugs registered with `delay_span_bug`.
|
/// If true, immediately print bugs registered with `span_delayed_bug`.
|
||||||
/// (rustc: see `-Z report-delayed-bugs`)
|
/// (rustc: see `-Z report-delayed-bugs`)
|
||||||
pub report_delayed_bugs: bool,
|
pub report_delayed_bugs: bool,
|
||||||
/// Show macro backtraces.
|
/// Show macro backtraces.
|
||||||
|
@ -545,20 +545,20 @@ impl Drop for HandlerInner {
|
||||||
self.emit_stashed_diagnostics();
|
self.emit_stashed_diagnostics();
|
||||||
|
|
||||||
if !self.has_errors() {
|
if !self.has_errors() {
|
||||||
let bugs = std::mem::replace(&mut self.delayed_span_bugs, Vec::new());
|
let bugs = std::mem::replace(&mut self.span_delayed_bugs, Vec::new());
|
||||||
self.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued");
|
self.flush_delayed(bugs, "no errors encountered even though `span_delayed_bug` issued");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(eddyb) this explains what `delayed_good_path_bugs` are!
|
// FIXME(eddyb) this explains what `good_path_delayed_bugs` are!
|
||||||
// They're `delayed_span_bugs` but for "require some diagnostic happened"
|
// They're `span_delayed_bugs` but for "require some diagnostic happened"
|
||||||
// instead of "require some error happened". Sadly that isn't ideal, as
|
// instead of "require some error happened". Sadly that isn't ideal, as
|
||||||
// lints can be `#[allow]`'d, potentially leading to this triggering.
|
// lints can be `#[allow]`'d, potentially leading to this triggering.
|
||||||
// Also, "good path" should be replaced with a better naming.
|
// Also, "good path" should be replaced with a better naming.
|
||||||
if !self.has_any_message() && !self.suppressed_expected_diag && !std::thread::panicking() {
|
if !self.has_any_message() && !self.suppressed_expected_diag && !std::thread::panicking() {
|
||||||
let bugs = std::mem::replace(&mut self.delayed_good_path_bugs, Vec::new());
|
let bugs = std::mem::replace(&mut self.good_path_delayed_bugs, Vec::new());
|
||||||
self.flush_delayed(
|
self.flush_delayed(
|
||||||
bugs,
|
bugs,
|
||||||
"no warnings or errors encountered even though `delayed_good_path_bugs` issued",
|
"no warnings or errors encountered even though `good_path_delayed_bugs` issued",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,8 +609,8 @@ impl Handler {
|
||||||
deduplicated_err_count: 0,
|
deduplicated_err_count: 0,
|
||||||
deduplicated_warn_count: 0,
|
deduplicated_warn_count: 0,
|
||||||
emitter,
|
emitter,
|
||||||
delayed_span_bugs: Vec::new(),
|
span_delayed_bugs: Vec::new(),
|
||||||
delayed_good_path_bugs: Vec::new(),
|
good_path_delayed_bugs: Vec::new(),
|
||||||
suppressed_expected_diag: false,
|
suppressed_expected_diag: false,
|
||||||
taught_diagnostics: Default::default(),
|
taught_diagnostics: Default::default(),
|
||||||
emitted_diagnostic_codes: Default::default(),
|
emitted_diagnostic_codes: Default::default(),
|
||||||
|
@ -648,7 +648,7 @@ impl Handler {
|
||||||
// This is here to not allow mutation of flags;
|
// This is here to not allow mutation of flags;
|
||||||
// as of this writing it's only used in tests in librustc_middle.
|
// as of this writing it's only used in tests in librustc_middle.
|
||||||
pub fn can_emit_warnings(&self) -> bool {
|
pub fn can_emit_warnings(&self) -> bool {
|
||||||
self.inner.lock().flags.can_emit_warnings
|
self.inner.borrow_mut().flags.can_emit_warnings
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets the diagnostic error count as well as the cached emitted diagnostics.
|
/// Resets the diagnostic error count as well as the cached emitted diagnostics.
|
||||||
|
@ -664,8 +664,8 @@ impl Handler {
|
||||||
inner.deduplicated_warn_count = 0;
|
inner.deduplicated_warn_count = 0;
|
||||||
|
|
||||||
// actually free the underlying memory (which `clear` would not do)
|
// actually free the underlying memory (which `clear` would not do)
|
||||||
inner.delayed_span_bugs = Default::default();
|
inner.span_delayed_bugs = Default::default();
|
||||||
inner.delayed_good_path_bugs = Default::default();
|
inner.good_path_delayed_bugs = Default::default();
|
||||||
inner.taught_diagnostics = Default::default();
|
inner.taught_diagnostics = Default::default();
|
||||||
inner.emitted_diagnostic_codes = Default::default();
|
inner.emitted_diagnostic_codes = Default::default();
|
||||||
inner.emitted_diagnostics = Default::default();
|
inner.emitted_diagnostics = Default::default();
|
||||||
|
@ -675,14 +675,13 @@ impl Handler {
|
||||||
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
|
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
|
||||||
/// Retrieve a stashed diagnostic with `steal_diagnostic`.
|
/// Retrieve a stashed diagnostic with `steal_diagnostic`.
|
||||||
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
|
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
|
||||||
let mut inner = self.inner.borrow_mut();
|
self.inner.borrow_mut().stash((span.with_parent(None), key), diag);
|
||||||
inner.stash((span.with_parent(None), key), diag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Steal a previously stashed diagnostic with the given `Span` and [`StashKey`] as the key.
|
/// Steal a previously stashed diagnostic with the given `Span` and [`StashKey`] as the key.
|
||||||
pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option<DiagnosticBuilder<'_, ()>> {
|
pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option<DiagnosticBuilder<'_, ()>> {
|
||||||
let mut inner = self.inner.borrow_mut();
|
self.inner
|
||||||
inner
|
.borrow_mut()
|
||||||
.steal((span.with_parent(None), key))
|
.steal((span.with_parent(None), key))
|
||||||
.map(|diag| DiagnosticBuilder::new_diagnostic(self, diag))
|
.map(|diag| DiagnosticBuilder::new_diagnostic(self, diag))
|
||||||
}
|
}
|
||||||
|
@ -927,10 +926,7 @@ impl Handler {
|
||||||
/// Construct a builder at the `Note` level with the `msg`.
|
/// Construct a builder at the `Note` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn struct_note_without_error(
|
pub fn struct_note(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||||
&self,
|
|
||||||
msg: impl Into<DiagnosticMessage>,
|
|
||||||
) -> DiagnosticBuilder<'_, ()> {
|
|
||||||
DiagnosticBuilder::new(self, Level::Note, msg)
|
DiagnosticBuilder::new(self, Level::Note, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,11 +966,12 @@ impl Handler {
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
code: DiagnosticId,
|
code: DiagnosticId,
|
||||||
) {
|
) -> ErrorGuaranteed {
|
||||||
self.emit_diag_at_span(
|
self.emit_diag_at_span(
|
||||||
Diagnostic::new_with_code(Error { lint: false }, Some(code), msg),
|
Diagnostic::new_with_code(Error { lint: false }, Some(code), msg),
|
||||||
span,
|
span,
|
||||||
);
|
)
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
|
@ -998,20 +995,20 @@ impl Handler {
|
||||||
self.inner.borrow_mut().span_bug(span, msg)
|
self.inner.borrow_mut().span_bug(span, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For documentation on this, see `Session::delay_span_bug`.
|
/// For documentation on this, see `Session::span_delayed_bug`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn delay_span_bug(
|
pub fn span_delayed_bug(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
msg: impl Into<String>,
|
msg: impl Into<String>,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
self.inner.borrow_mut().delay_span_bug(span, msg)
|
self.inner.borrow_mut().span_delayed_bug(span, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
|
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
|
||||||
// where the explanation of what "good path" is (also, it should be renamed).
|
// where the explanation of what "good path" is (also, it should be renamed).
|
||||||
pub fn delay_good_path_bug(&self, msg: impl Into<DiagnosticMessage>) {
|
pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>) {
|
||||||
self.inner.borrow_mut().delay_good_path_bug(msg)
|
self.inner.borrow_mut().good_path_delayed_bug(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -1021,17 +1018,13 @@ impl Handler {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn span_note_without_error(
|
pub fn span_note(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
|
||||||
&self,
|
|
||||||
span: impl Into<MultiSpan>,
|
|
||||||
msg: impl Into<DiagnosticMessage>,
|
|
||||||
) {
|
|
||||||
self.emit_diag_at_span(Diagnostic::new(Note, msg), span);
|
self.emit_diag_at_span(Diagnostic::new(Note, msg), span);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn span_note_diag(
|
pub fn struct_span_note(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -1054,12 +1047,11 @@ impl Handler {
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
|
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
|
||||||
let mut db = DiagnosticBuilder::new(self, Warning(None), msg);
|
DiagnosticBuilder::new(self, Warning(None), msg).emit();
|
||||||
db.emit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
pub fn note_without_error(&self, msg: impl Into<DiagnosticMessage>) {
|
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
|
||||||
DiagnosticBuilder::new(self, Note, msg).emit();
|
DiagnosticBuilder::new(self, Note, msg).emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,8 +1077,8 @@ impl Handler {
|
||||||
ErrorGuaranteed::unchecked_claim_error_was_emitted()
|
ErrorGuaranteed::unchecked_claim_error_was_emitted()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn has_errors_or_delayed_span_bugs(&self) -> Option<ErrorGuaranteed> {
|
pub fn has_errors_or_span_delayed_bugs(&self) -> Option<ErrorGuaranteed> {
|
||||||
self.inner.borrow().has_errors_or_delayed_span_bugs().then(|| {
|
self.inner.borrow().has_errors_or_span_delayed_bugs().then(|| {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
ErrorGuaranteed::unchecked_claim_error_was_emitted()
|
ErrorGuaranteed::unchecked_claim_error_was_emitted()
|
||||||
})
|
})
|
||||||
|
@ -1204,8 +1196,7 @@ impl Handler {
|
||||||
mut diag: Diagnostic,
|
mut diag: Diagnostic,
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
) -> Option<ErrorGuaranteed> {
|
) -> Option<ErrorGuaranteed> {
|
||||||
let mut inner = self.inner.borrow_mut();
|
self.inner.borrow_mut().emit_diagnostic(diag.set_span(sp))
|
||||||
inner.emit_diagnostic(diag.set_span(sp))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
|
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
|
||||||
|
@ -1273,9 +1264,9 @@ impl Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush_delayed(&self) {
|
pub fn flush_delayed(&self) {
|
||||||
let mut inner = self.inner.lock();
|
let mut inner = self.inner.borrow_mut();
|
||||||
let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new());
|
let bugs = std::mem::replace(&mut inner.span_delayed_bugs, Vec::new());
|
||||||
inner.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued");
|
inner.flush_delayed(bugs, "no errors encountered even though `span_delayed_bug` issued");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,11 +1323,11 @@ impl HandlerInner {
|
||||||
|
|
||||||
if diagnostic.level == Level::DelayedBug {
|
if diagnostic.level == Level::DelayedBug {
|
||||||
// FIXME(eddyb) this should check for `has_errors` and stop pushing
|
// FIXME(eddyb) this should check for `has_errors` and stop pushing
|
||||||
// once *any* errors were emitted (and truncate `delayed_span_bugs`
|
// once *any* errors were emitted (and truncate `span_delayed_bugs`
|
||||||
// when an error is first emitted, also), but maybe there's a case
|
// when an error is first emitted, also), but maybe there's a case
|
||||||
// in which that's not sound? otherwise this is really inefficient.
|
// in which that's not sound? otherwise this is really inefficient.
|
||||||
let backtrace = std::backtrace::Backtrace::capture();
|
let backtrace = std::backtrace::Backtrace::capture();
|
||||||
self.delayed_span_bugs
|
self.span_delayed_bugs
|
||||||
.push(DelayedDiagnostic::with_backtrace(diagnostic.clone(), backtrace));
|
.push(DelayedDiagnostic::with_backtrace(diagnostic.clone(), backtrace));
|
||||||
|
|
||||||
if !self.flags.report_delayed_bugs {
|
if !self.flags.report_delayed_bugs {
|
||||||
|
@ -1451,7 +1442,7 @@ impl HandlerInner {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delayed_bug_count(&self) -> usize {
|
fn delayed_bug_count(&self) -> usize {
|
||||||
self.delayed_span_bugs.len() + self.delayed_good_path_bugs.len()
|
self.span_delayed_bugs.len() + self.good_path_delayed_bugs.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_error_count(&mut self, registry: &Registry) {
|
fn print_error_count(&mut self, registry: &Registry) {
|
||||||
|
@ -1502,18 +1493,18 @@ impl HandlerInner {
|
||||||
error_codes.sort();
|
error_codes.sort();
|
||||||
if error_codes.len() > 1 {
|
if error_codes.len() > 1 {
|
||||||
let limit = if error_codes.len() > 9 { 9 } else { error_codes.len() };
|
let limit = if error_codes.len() > 9 { 9 } else { error_codes.len() };
|
||||||
self.failure(format!(
|
self.failure_note(format!(
|
||||||
"Some errors have detailed explanations: {}{}",
|
"Some errors have detailed explanations: {}{}",
|
||||||
error_codes[..limit].join(", "),
|
error_codes[..limit].join(", "),
|
||||||
if error_codes.len() > 9 { "..." } else { "." }
|
if error_codes.len() > 9 { "..." } else { "." }
|
||||||
));
|
));
|
||||||
self.failure(format!(
|
self.failure_note(format!(
|
||||||
"For more information about an error, try \
|
"For more information about an error, try \
|
||||||
`rustc --explain {}`.",
|
`rustc --explain {}`.",
|
||||||
&error_codes[0]
|
&error_codes[0]
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
self.failure(format!(
|
self.failure_note(format!(
|
||||||
"For more information about this error, try \
|
"For more information about this error, try \
|
||||||
`rustc --explain {}`.",
|
`rustc --explain {}`.",
|
||||||
&error_codes[0]
|
&error_codes[0]
|
||||||
|
@ -1572,15 +1563,15 @@ impl HandlerInner {
|
||||||
fn has_errors_or_lint_errors(&self) -> bool {
|
fn has_errors_or_lint_errors(&self) -> bool {
|
||||||
self.has_errors() || self.lint_err_count > 0
|
self.has_errors() || self.lint_err_count > 0
|
||||||
}
|
}
|
||||||
fn has_errors_or_delayed_span_bugs(&self) -> bool {
|
fn has_errors_or_span_delayed_bugs(&self) -> bool {
|
||||||
self.has_errors() || !self.delayed_span_bugs.is_empty()
|
self.has_errors() || !self.span_delayed_bugs.is_empty()
|
||||||
}
|
}
|
||||||
fn has_any_message(&self) -> bool {
|
fn has_any_message(&self) -> bool {
|
||||||
self.err_count() > 0 || self.lint_err_count > 0 || self.warn_count > 0
|
self.err_count() > 0 || self.lint_err_count > 0 || self.warn_count > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_compilation_going_to_fail(&self) -> bool {
|
fn is_compilation_going_to_fail(&self) -> bool {
|
||||||
self.has_errors() || self.lint_err_count > 0 || !self.delayed_span_bugs.is_empty()
|
self.has_errors() || self.lint_err_count > 0 || !self.span_delayed_bugs.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn abort_if_errors(&mut self) {
|
fn abort_if_errors(&mut self) {
|
||||||
|
@ -1601,14 +1592,17 @@ impl HandlerInner {
|
||||||
self.emit_diagnostic(diag.set_span(sp));
|
self.emit_diagnostic(diag.set_span(sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For documentation on this, see `Session::delay_span_bug`.
|
/// For documentation on this, see `Session::span_delayed_bug`.
|
||||||
|
///
|
||||||
|
/// Note: this function used to be called `delay_span_bug`. It was renamed
|
||||||
|
/// to match similar functions like `span_bug`, `span_err`, etc.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn delay_span_bug(
|
fn span_delayed_bug(
|
||||||
&mut self,
|
&mut self,
|
||||||
sp: impl Into<MultiSpan>,
|
sp: impl Into<MultiSpan>,
|
||||||
msg: impl Into<String>,
|
msg: impl Into<String>,
|
||||||
) -> ErrorGuaranteed {
|
) -> ErrorGuaranteed {
|
||||||
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
|
// This is technically `self.treat_err_as_bug()` but `span_delayed_bug` is called before
|
||||||
// incrementing `err_count` by one, so we need to +1 the comparing.
|
// incrementing `err_count` by one, so we need to +1 the comparing.
|
||||||
// FIXME: Would be nice to increment err_count in a more coherent way.
|
// FIXME: Would be nice to increment err_count in a more coherent way.
|
||||||
if self.flags.treat_err_as_bug.is_some_and(|c| {
|
if self.flags.treat_err_as_bug.is_some_and(|c| {
|
||||||
|
@ -1624,16 +1618,16 @@ impl HandlerInner {
|
||||||
|
|
||||||
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
|
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
|
||||||
// where the explanation of what "good path" is (also, it should be renamed).
|
// where the explanation of what "good path" is (also, it should be renamed).
|
||||||
fn delay_good_path_bug(&mut self, msg: impl Into<DiagnosticMessage>) {
|
fn good_path_delayed_bug(&mut self, msg: impl Into<DiagnosticMessage>) {
|
||||||
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg);
|
let mut diagnostic = Diagnostic::new(Level::DelayedBug, msg);
|
||||||
if self.flags.report_delayed_bugs {
|
if self.flags.report_delayed_bugs {
|
||||||
self.emit_diagnostic(&mut diagnostic);
|
self.emit_diagnostic(&mut diagnostic);
|
||||||
}
|
}
|
||||||
let backtrace = std::backtrace::Backtrace::capture();
|
let backtrace = std::backtrace::Backtrace::capture();
|
||||||
self.delayed_good_path_bugs.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace));
|
self.good_path_delayed_bugs.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn failure(&mut self, msg: impl Into<DiagnosticMessage>) {
|
fn failure_note(&mut self, msg: impl Into<DiagnosticMessage>) {
|
||||||
self.emit_diagnostic(&mut Diagnostic::new(FailureNote, msg));
|
self.emit_diagnostic(&mut Diagnostic::new(FailureNote, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ impl<'a> ExtCtxt<'a> {
|
||||||
sp: S,
|
sp: S,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg)
|
self.sess.diagnostic().struct_span_err(sp, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -1143,15 +1143,15 @@ impl<'a> ExtCtxt<'a> {
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
|
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
|
||||||
self.sess.parse_sess.span_diagnostic.span_err(sp, msg);
|
self.sess.diagnostic().span_err(sp, msg);
|
||||||
}
|
}
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
|
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
|
||||||
self.sess.parse_sess.span_diagnostic.span_warn(sp, msg);
|
self.sess.diagnostic().span_warn(sp, msg);
|
||||||
}
|
}
|
||||||
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<String>) -> ! {
|
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<String>) -> ! {
|
||||||
self.sess.parse_sess.span_diagnostic.span_bug(sp, msg);
|
self.sess.diagnostic().span_bug(sp, msg);
|
||||||
}
|
}
|
||||||
pub fn trace_macros_diag(&mut self) {
|
pub fn trace_macros_diag(&mut self) {
|
||||||
for (span, notes) in self.expansions.iter() {
|
for (span, notes) in self.expansions.iter() {
|
||||||
|
@ -1165,7 +1165,7 @@ impl<'a> ExtCtxt<'a> {
|
||||||
self.expansions.clear();
|
self.expansions.clear();
|
||||||
}
|
}
|
||||||
pub fn bug(&self, msg: &'static str) -> ! {
|
pub fn bug(&self, msg: &'static str) -> ! {
|
||||||
self.sess.parse_sess.span_diagnostic.bug(msg);
|
self.sess.diagnostic().bug(msg);
|
||||||
}
|
}
|
||||||
pub fn trace_macros(&self) -> bool {
|
pub fn trace_macros(&self) -> bool {
|
||||||
self.ecfg.trace_mac
|
self.ecfg.trace_mac
|
||||||
|
@ -1286,9 +1286,8 @@ pub fn expr_to_string(
|
||||||
|
|
||||||
/// Non-fatally assert that `tts` is empty. Note that this function
|
/// Non-fatally assert that `tts` is empty. Note that this function
|
||||||
/// returns even when `tts` is non-empty, macros that *need* to stop
|
/// returns even when `tts` is non-empty, macros that *need* to stop
|
||||||
/// compilation should call
|
/// compilation should call `cx.diagnostic().abort_if_errors()`
|
||||||
/// `cx.parse_sess.span_diagnostic.abort_if_errors()` (this should be
|
/// (this should be done as rarely as possible).
|
||||||
/// done as rarely as possible).
|
|
||||||
pub fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str) {
|
pub fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str) {
|
||||||
if !tts.is_empty() {
|
if !tts.is_empty() {
|
||||||
cx.emit_err(errors::TakesNoArguments { span, name });
|
cx.emit_err(errors::TakesNoArguments { span, name });
|
||||||
|
|
|
@ -435,7 +435,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
invocations = mem::take(&mut undetermined_invocations);
|
invocations = mem::take(&mut undetermined_invocations);
|
||||||
force = !mem::replace(&mut progress, false);
|
force = !mem::replace(&mut progress, false);
|
||||||
if force && self.monotonic {
|
if force && self.monotonic {
|
||||||
self.cx.sess.delay_span_bug(
|
self.cx.sess.span_delayed_bug(
|
||||||
invocations.last().unwrap().0.span(),
|
invocations.last().unwrap().0.span(),
|
||||||
"expansion entered force mode without producing any errors",
|
"expansion entered force mode without producing any errors",
|
||||||
);
|
);
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub(super) fn failed_to_match_macro<'cx>(
|
||||||
if try_success_result.is_ok() {
|
if try_success_result.is_ok() {
|
||||||
// Nonterminal parser recovery might turn failed matches into successful ones,
|
// Nonterminal parser recovery might turn failed matches into successful ones,
|
||||||
// but for that it must have emitted an error already
|
// but for that it must have emitted an error already
|
||||||
tracker.cx.sess.delay_span_bug(sp, "Macro matching returned a success on the second try");
|
tracker.cx.sess.span_delayed_bug(sp, "Macro matching returned a success on the second try");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(result) = tracker.result {
|
if let Some(result) = tracker.result {
|
||||||
|
@ -151,7 +151,7 @@ impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx,
|
||||||
Success(_) => {
|
Success(_) => {
|
||||||
// Nonterminal parser recovery might turn failed matches into successful ones,
|
// Nonterminal parser recovery might turn failed matches into successful ones,
|
||||||
// but for that it must have emitted an error already
|
// but for that it must have emitted an error already
|
||||||
self.cx.sess.delay_span_bug(
|
self.cx.sess.span_delayed_bug(
|
||||||
self.root_span,
|
self.root_span,
|
||||||
"should not collect detailed info for successful macro match",
|
"should not collect detailed info for successful macro match",
|
||||||
);
|
);
|
||||||
|
|
|
@ -475,17 +475,14 @@ pub fn compile_declarative_macro(
|
||||||
|
|
||||||
let s = parse_failure_msg(&token);
|
let s = parse_failure_msg(&token);
|
||||||
let sp = token.span.substitute_dummy(def.span);
|
let sp = token.span.substitute_dummy(def.span);
|
||||||
let mut err = sess.parse_sess.span_diagnostic.struct_span_err(sp, s);
|
let mut err = sess.diagnostic().struct_span_err(sp, s);
|
||||||
err.span_label(sp, msg);
|
err.span_label(sp, msg);
|
||||||
annotate_doc_comment(&mut err, sess.source_map(), sp);
|
annotate_doc_comment(&mut err, sess.source_map(), sp);
|
||||||
err.emit();
|
err.emit();
|
||||||
return dummy_syn_ext();
|
return dummy_syn_ext();
|
||||||
}
|
}
|
||||||
Error(sp, msg) => {
|
Error(sp, msg) => {
|
||||||
sess.parse_sess
|
sess.diagnostic().struct_span_err(sp.substitute_dummy(def.span), msg).emit();
|
||||||
.span_diagnostic
|
|
||||||
.struct_span_err(sp.substitute_dummy(def.span), msg)
|
|
||||||
.emit();
|
|
||||||
return dummy_syn_ext();
|
return dummy_syn_ext();
|
||||||
}
|
}
|
||||||
ErrorReported(_) => {
|
ErrorReported(_) => {
|
||||||
|
@ -514,10 +511,10 @@ pub fn compile_declarative_macro(
|
||||||
valid &= check_lhs_nt_follows(&sess.parse_sess, def, &tt);
|
valid &= check_lhs_nt_follows(&sess.parse_sess, def, &tt);
|
||||||
return tt;
|
return tt;
|
||||||
}
|
}
|
||||||
sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs")
|
sess.diagnostic().span_bug(def.span, "wrong-structured lhs")
|
||||||
})
|
})
|
||||||
.collect::<Vec<mbe::TokenTree>>(),
|
.collect::<Vec<mbe::TokenTree>>(),
|
||||||
_ => sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs"),
|
_ => sess.diagnostic().span_bug(def.span, "wrong-structured lhs"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let rhses = match &argument_map[&MacroRulesNormalizedIdent::new(rhs_nm)] {
|
let rhses = match &argument_map[&MacroRulesNormalizedIdent::new(rhs_nm)] {
|
||||||
|
@ -536,10 +533,10 @@ pub fn compile_declarative_macro(
|
||||||
.pop()
|
.pop()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured rhs")
|
sess.diagnostic().span_bug(def.span, "wrong-structured rhs")
|
||||||
})
|
})
|
||||||
.collect::<Vec<mbe::TokenTree>>(),
|
.collect::<Vec<mbe::TokenTree>>(),
|
||||||
_ => sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured rhs"),
|
_ => sess.diagnostic().span_bug(def.span, "wrong-structured rhs"),
|
||||||
};
|
};
|
||||||
|
|
||||||
for rhs in &rhses {
|
for rhs in &rhses {
|
||||||
|
@ -595,7 +592,7 @@ pub fn compile_declarative_macro(
|
||||||
mbe::TokenTree::Delimited(_, delimited) => {
|
mbe::TokenTree::Delimited(_, delimited) => {
|
||||||
mbe::macro_parser::compute_locs(&delimited.tts)
|
mbe::macro_parser::compute_locs(&delimited.tts)
|
||||||
}
|
}
|
||||||
_ => sess.parse_sess.span_diagnostic.span_bug(def.span, "malformed macro lhs"),
|
_ => sess.diagnostic().span_bug(def.span, "malformed macro lhs"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -648,10 +645,8 @@ fn is_empty_token_tree(sess: &ParseSess, seq: &mbe::SequenceRepetition) -> bool
|
||||||
iter.next();
|
iter.next();
|
||||||
}
|
}
|
||||||
let span = t.span.to(now.span);
|
let span = t.span.to(now.span);
|
||||||
sess.span_diagnostic.span_note_without_error(
|
sess.span_diagnostic
|
||||||
span,
|
.span_note(span, "doc comments are ignored in matcher position");
|
||||||
"doc comments are ignored in matcher position",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
mbe::TokenTree::Sequence(_, sub_seq)
|
mbe::TokenTree::Sequence(_, sub_seq)
|
||||||
if (sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore
|
if (sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore
|
||||||
|
|
|
@ -357,7 +357,7 @@ fn parse_sep_and_kleene_op<'a>(
|
||||||
fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &ParseSess, token: &Token) {
|
fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &ParseSess, token: &Token) {
|
||||||
sess.span_diagnostic
|
sess.span_diagnostic
|
||||||
.span_err(token.span, format!("unexpected token: {}", pprust::token_to_string(token)));
|
.span_err(token.span, format!("unexpected token: {}", pprust::token_to_string(token)));
|
||||||
sess.span_diagnostic.span_note_without_error(
|
sess.span_diagnostic.span_note(
|
||||||
token.span,
|
token.span,
|
||||||
"`$$` and meta-variable expressions are not allowed inside macro parameter definitions",
|
"`$$` and meta-variable expressions are not allowed inside macro parameter definitions",
|
||||||
);
|
);
|
||||||
|
|
|
@ -156,7 +156,7 @@ impl MultiItemModifier for DeriveProcMacro {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let error_count_before = ecx.sess.parse_sess.span_diagnostic.err_count();
|
let error_count_before = ecx.sess.diagnostic().err_count();
|
||||||
let mut parser =
|
let mut parser =
|
||||||
rustc_parse::stream_to_parser(&ecx.sess.parse_sess, stream, Some("proc-macro derive"));
|
rustc_parse::stream_to_parser(&ecx.sess.parse_sess, stream, Some("proc-macro derive"));
|
||||||
let mut items = vec![];
|
let mut items = vec![];
|
||||||
|
@ -179,7 +179,7 @@ impl MultiItemModifier for DeriveProcMacro {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fail if there have been errors emitted
|
// fail if there have been errors emitted
|
||||||
if ecx.sess.parse_sess.span_diagnostic.err_count() > error_count_before {
|
if ecx.sess.diagnostic().err_count() > error_count_before {
|
||||||
ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span });
|
ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -813,7 +813,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||||
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
|
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
|
||||||
rustc_attr!(
|
rustc_attr!(
|
||||||
TEST, rustc_error, Normal,
|
TEST, rustc_error, Normal,
|
||||||
template!(Word, List: "delay_span_bug_from_inside_query"), WarnFollowingWordOnly
|
template!(Word, List: "span_delayed_bug_from_inside_query"), WarnFollowingWordOnly
|
||||||
),
|
),
|
||||||
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
|
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
|
||||||
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
|
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
|
||||||
|
|
|
@ -720,9 +720,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
// since we should have emitten an error for them earlier, and they will
|
// since we should have emitten an error for them earlier, and they will
|
||||||
// not be well-formed!
|
// not be well-formed!
|
||||||
if polarity == ty::ImplPolarity::Negative {
|
if polarity == ty::ImplPolarity::Negative {
|
||||||
self.tcx()
|
self.tcx().sess.span_delayed_bug(
|
||||||
.sess
|
binding.span,
|
||||||
.delay_span_bug(binding.span, "negative trait bounds should not have bindings");
|
"negative trait bounds should not have bindings",
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1419,7 +1420,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
// trait reference.
|
// trait reference.
|
||||||
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
|
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
|
||||||
// A cycle error occurred, most likely.
|
// A cycle error occurred, most likely.
|
||||||
let guar = tcx.sess.delay_span_bug(span, "expected cycle error");
|
let guar = tcx.sess.span_delayed_bug(span, "expected cycle error");
|
||||||
return Err(guar);
|
return Err(guar);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2376,7 +2377,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let e = self
|
let e = self
|
||||||
.tcx()
|
.tcx()
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(path.span, "path with `Res::Err` but no error emitted");
|
.span_delayed_bug(path.span, "path with `Res::Err` but no error emitted");
|
||||||
self.set_tainted_by_errors(e);
|
self.set_tainted_by_errors(e);
|
||||||
Ty::new_error(self.tcx(), e)
|
Ty::new_error(self.tcx(), e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,7 +325,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
false
|
false
|
||||||
});
|
});
|
||||||
if references_self {
|
if references_self {
|
||||||
let guar = tcx.sess.delay_span_bug(
|
let guar = tcx.sess.span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
"trait object projection bounds reference `Self`",
|
"trait object projection bounds reference `Self`",
|
||||||
);
|
);
|
||||||
|
|
|
@ -130,7 +130,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||||
for field in &def.non_enum_variant().fields {
|
for field in &def.non_enum_variant().fields {
|
||||||
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
|
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
|
||||||
else {
|
else {
|
||||||
tcx.sess.delay_span_bug(span, "could not normalize field type");
|
tcx.sess.span_delayed_bug(span, "could not normalize field type");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -151,7 +151,8 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||||
return false;
|
return false;
|
||||||
} else if field_ty.needs_drop(tcx, param_env) {
|
} else if field_ty.needs_drop(tcx, param_env) {
|
||||||
// This should never happen. But we can get here e.g. in case of name resolution errors.
|
// This should never happen. But we can get here e.g. in case of name resolution errors.
|
||||||
tcx.sess.delay_span_bug(span, "we should never accept maybe-dropping union fields");
|
tcx.sess
|
||||||
|
.span_delayed_bug(span, "we should never accept maybe-dropping union fields");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,7 +182,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
}
|
}
|
||||||
// Generic statics are rejected, but we still reach this case.
|
// Generic statics are rejected, but we still reach this case.
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tcx.sess.delay_span_bug(span, format!("{e:?}"));
|
tcx.sess.span_delayed_bug(span, format!("{e:?}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -204,7 +205,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||||
let item = tcx.hir().item(id);
|
let item = tcx.hir().item(id);
|
||||||
let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else {
|
let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else {
|
||||||
tcx.sess.delay_span_bug(item.span, "expected opaque item");
|
tcx.sess.span_delayed_bug(item.span, "expected opaque item");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -313,7 +314,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(ty_err) => {
|
Err(ty_err) => {
|
||||||
let ty_err = ty_err.to_string(tcx);
|
let ty_err = ty_err.to_string(tcx);
|
||||||
return Err(tcx.sess.delay_span_bug(
|
return Err(tcx.sess.span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
|
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
|
||||||
));
|
));
|
||||||
|
@ -655,7 +656,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
||||||
if !tcx.is_impl_trait_in_trait(impl_item) {
|
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||||
} else {
|
} else {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
format!("parent item: {parent_impl:?} not marked as default"),
|
format!("parent item: {parent_impl:?} not marked as default"),
|
||||||
);
|
);
|
||||||
|
@ -703,7 +704,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||||
tcx.associated_item(trait_item_id)
|
tcx.associated_item(trait_item_id)
|
||||||
} else {
|
} else {
|
||||||
// Checked in `associated_item`.
|
// Checked in `associated_item`.
|
||||||
tcx.sess.delay_span_bug(tcx.def_span(impl_item), "missing associated item in trait");
|
tcx.sess.span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
match ty_impl_item.kind {
|
match ty_impl_item.kind {
|
||||||
|
|
|
@ -439,7 +439,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||||
}
|
}
|
||||||
return Err(tcx
|
return Err(tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(rustc_span::DUMMY_SP, "error should have been emitted"));
|
.span_delayed_bug(rustc_span::DUMMY_SP, "error should have been emitted"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,7 +937,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||||
remapped_types.insert(def_id, ty::EarlyBinder::bind(ty));
|
remapped_types.insert(def_id, ty::EarlyBinder::bind(ty));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let reported = tcx.sess.delay_span_bug(
|
let reported = tcx.sess.span_delayed_bug(
|
||||||
return_span,
|
return_span,
|
||||||
format!("could not fully resolve: {ty} => {err:?}"),
|
format!("could not fully resolve: {ty} => {err:?}"),
|
||||||
);
|
);
|
||||||
|
@ -1114,7 +1114,9 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
||||||
.note(format!("hidden type inferred to be `{}`", self.ty))
|
.note(format!("hidden type inferred to be `{}`", self.ty))
|
||||||
.emit()
|
.emit()
|
||||||
}
|
}
|
||||||
_ => self.tcx.sess.delay_span_bug(DUMMY_SP, "should've been able to remap region"),
|
_ => {
|
||||||
|
self.tcx.sess.span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return Err(guar);
|
return Err(guar);
|
||||||
};
|
};
|
||||||
|
@ -1473,7 +1475,7 @@ fn compare_number_of_generics<'tcx>(
|
||||||
// inheriting the generics from will also have mismatched arguments, and
|
// inheriting the generics from will also have mismatched arguments, and
|
||||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||||
if trait_.is_impl_trait_in_trait() {
|
if trait_.is_impl_trait_in_trait() {
|
||||||
return Err(tcx.sess.delay_span_bug(
|
return Err(tcx.sess.span_delayed_bug(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||||
));
|
));
|
||||||
|
|
|
@ -153,7 +153,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||||
trait_m_sig.inputs_and_output,
|
trait_m_sig.inputs_and_output,
|
||||||
));
|
));
|
||||||
if !ocx.select_all_or_error().is_empty() {
|
if !ocx.select_all_or_error().is_empty() {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
"encountered errors when checking RPITIT refinement (selection)",
|
"encountered errors when checking RPITIT refinement (selection)",
|
||||||
);
|
);
|
||||||
|
@ -165,7 +165,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||||
);
|
);
|
||||||
let errors = infcx.resolve_regions(&outlives_env);
|
let errors = infcx.resolve_regions(&outlives_env);
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
"encountered errors when checking RPITIT refinement (regions)",
|
"encountered errors when checking RPITIT refinement (regions)",
|
||||||
);
|
);
|
||||||
|
@ -173,7 +173,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||||
}
|
}
|
||||||
// Resolve any lifetime variables that may have been introduced during normalization.
|
// Resolve any lifetime variables that may have been introduced during normalization.
|
||||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
"encountered errors when checking RPITIT refinement (resolution)",
|
"encountered errors when checking RPITIT refinement (resolution)",
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,7 +66,7 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
||||||
// already checked by coherence, but compilation may
|
// already checked by coherence, but compilation may
|
||||||
// not have been terminated.
|
// not have been terminated.
|
||||||
let span = tcx.def_span(drop_impl_did);
|
let span = tcx.def_span(drop_impl_did);
|
||||||
let reported = tcx.sess.delay_span_bug(
|
let reported = tcx.sess.span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
format!("should have been rejected by coherence check: {dtor_self_type}"),
|
format!("should have been rejected by coherence check: {dtor_self_type}"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -281,7 +281,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||||
pub fn check_asm(&self, asm: &hir::InlineAsm<'tcx>, enclosing_id: LocalDefId) {
|
pub fn check_asm(&self, asm: &hir::InlineAsm<'tcx>, enclosing_id: LocalDefId) {
|
||||||
let target_features = self.tcx.asm_target_features(enclosing_id.to_def_id());
|
let target_features = self.tcx.asm_target_features(enclosing_id.to_def_id());
|
||||||
let Some(asm_arch) = self.tcx.sess.asm_arch else {
|
let Some(asm_arch) = self.tcx.sess.asm_arch else {
|
||||||
self.tcx.sess.delay_span_bug(DUMMY_SP, "target architecture does not support asm");
|
self.tcx.sess.span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
||||||
|
|
|
@ -118,10 +118,10 @@ where
|
||||||
if tcx.sess.err_count() > 0 {
|
if tcx.sess.err_count() > 0 {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
} else {
|
} else {
|
||||||
// HACK(oli-obk): tests/ui/specialization/min_specialization/specialize_on_type_error.rs causes an
|
// HACK(oli-obk): tests/ui/specialization/min_specialization/specialize_on_type_error.rs
|
||||||
// error (delay_span_bug) during normalization, without reporting an error, so we need to act as if
|
// causes an error (span_delayed_bug) during normalization, without reporting an error,
|
||||||
// no error happened, in order to let our callers continue and report an error later in
|
// so we need to act as if no error happened, in order to let our callers continue and
|
||||||
// check_impl_items_against_trait.
|
// report an error later in check_impl_items_against_trait.
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1040,7 @@ fn check_type_defn<'tcx>(
|
||||||
let ty = tcx.erase_regions(ty);
|
let ty = tcx.erase_regions(ty);
|
||||||
if ty.has_infer() {
|
if ty.has_infer() {
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.delay_span_bug(item.span, format!("inference variables in {ty:?}"));
|
.span_delayed_bug(item.span, format!("inference variables in {ty:?}"));
|
||||||
// Just treat unresolved type expression as if it needs drop.
|
// Just treat unresolved type expression as if it needs drop.
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -1812,8 +1812,10 @@ fn check_variances_for_type_defn<'tcx>(
|
||||||
//
|
//
|
||||||
// if they aren't in the same order, then the user has written invalid code, and already
|
// if they aren't in the same order, then the user has written invalid code, and already
|
||||||
// got an error about it (or I'm wrong about this)
|
// got an error about it (or I'm wrong about this)
|
||||||
tcx.sess
|
tcx.sess.span_delayed_bug(
|
||||||
.delay_span_bug(hir_param.span, "hir generics and ty generics in different order");
|
hir_param.span,
|
||||||
|
"hir generics and ty generics in different order",
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,7 +453,7 @@ fn lint_auto_trait_impl<'tcx>(
|
||||||
impl_def_id: LocalDefId,
|
impl_def_id: LocalDefId,
|
||||||
) {
|
) {
|
||||||
if trait_ref.args.len() != 1 {
|
if trait_ref.args.len() != 1 {
|
||||||
tcx.sess.diagnostic().delay_span_bug(
|
tcx.sess.diagnostic().span_delayed_bug(
|
||||||
tcx.def_span(impl_def_id),
|
tcx.def_span(impl_def_id),
|
||||||
"auto traits cannot have generic parameters",
|
"auto traits cannot have generic parameters",
|
||||||
);
|
);
|
||||||
|
|
|
@ -82,7 +82,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
|
|
||||||
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative(_)) => {
|
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative(_)) => {
|
||||||
// Reported in AST validation
|
// Reported in AST validation
|
||||||
tcx.sess.delay_span_bug(item.span, "unsafe negative impl");
|
tcx.sess.span_delayed_bug(item.span, "unsafe negative impl");
|
||||||
}
|
}
|
||||||
(_, _, Unsafety::Normal, hir::ImplPolarity::Negative(_))
|
(_, _, Unsafety::Normal, hir::ImplPolarity::Negative(_))
|
||||||
| (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
| (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
||||||
|
|
|
@ -335,7 +335,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
// though this may happen when we call `poly_trait_ref_binder_info` with
|
// though this may happen when we call `poly_trait_ref_binder_info` with
|
||||||
// an (erroneous, #113423) associated return type bound in an impl header.
|
// an (erroneous, #113423) associated return type bound in an impl header.
|
||||||
if !supertrait_bound_vars.is_empty() {
|
if !supertrait_bound_vars.is_empty() {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
format!(
|
format!(
|
||||||
"found supertrait lifetimes without a binder to append \
|
"found supertrait lifetimes without a binder to append \
|
||||||
|
@ -1363,7 +1363,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
lifetime_ref.ident.span,
|
lifetime_ref.ident.span,
|
||||||
format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,),
|
format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,),
|
||||||
);
|
);
|
||||||
|
@ -1493,7 +1493,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
self.tcx.hir().span(hir_id),
|
self.tcx.hir().span(hir_id),
|
||||||
format!("could not resolve {param_def_id:?}"),
|
format!("could not resolve {param_def_id:?}"),
|
||||||
);
|
);
|
||||||
|
@ -1724,7 +1724,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(binding.ident.span, "bad return type notation here");
|
.span_delayed_bug(binding.ident.span, "bad return type notation here");
|
||||||
vec![]
|
vec![]
|
||||||
};
|
};
|
||||||
self.with(scope, |this| {
|
self.with(scope, |this| {
|
||||||
|
@ -2057,7 +2057,7 @@ fn is_late_bound_map(
|
||||||
Some(true) => Some(arg),
|
Some(true) => Some(arg),
|
||||||
Some(false) => None,
|
Some(false) => None,
|
||||||
None => {
|
None => {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
*span,
|
*span,
|
||||||
format!(
|
format!(
|
||||||
"Incorrect generic arg count for alias {alias_def:?}"
|
"Incorrect generic arg count for alias {alias_def:?}"
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
||||||
|
|
||||||
// HIR wfcheck should only ever happen as part of improving an existing error
|
// HIR wfcheck should only ever happen as part of improving an existing error
|
||||||
tcx.sess
|
tcx.sess
|
||||||
.delay_span_bug(tcx.def_span(def_id), "Performed HIR wfcheck without an existing error!");
|
.span_delayed_bug(tcx.def_span(def_id), "Performed HIR wfcheck without an existing error!");
|
||||||
|
|
||||||
let icx = ItemCtxt::new(tcx, def_id);
|
let icx = ItemCtxt::new(tcx, def_id);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
|
||||||
if impl_self_ty.references_error() {
|
if impl_self_ty.references_error() {
|
||||||
// Don't complain about unconstrained type params when self ty isn't known due to errors.
|
// Don't complain about unconstrained type params when self ty isn't known due to errors.
|
||||||
// (#36836)
|
// (#36836)
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
tcx.def_span(impl_def_id),
|
tcx.def_span(impl_def_id),
|
||||||
format!(
|
format!(
|
||||||
"potentially unconstrained type parameters weren't evaluated: {impl_self_ty:?}",
|
"potentially unconstrained type parameters weren't evaluated: {impl_self_ty:?}",
|
||||||
|
|
|
@ -209,8 +209,8 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
||||||
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
|
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
|
||||||
});
|
});
|
||||||
|
|
||||||
// HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors
|
// HACK: `check_mod_type_wf` may spuriously emit errors due to `span_delayed_bug`, even if
|
||||||
// only actually get emitted in `check_mod_item_types`.
|
// those errors only actually get emitted in `check_mod_item_types`.
|
||||||
errs?;
|
errs?;
|
||||||
|
|
||||||
if tcx.features().rustc_attrs {
|
if tcx.features().rustc_attrs {
|
||||||
|
|
|
@ -244,7 +244,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
// Check for `self` receiver on the method, otherwise we can't use this as a `Fn*` trait.
|
// Check for `self` receiver on the method, otherwise we can't use this as a `Fn*` trait.
|
||||||
if !self.tcx.associated_item(ok.value.def_id).fn_has_self_parameter {
|
if !self.tcx.associated_item(ok.value.def_id).fn_has_self_parameter {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
call_expr.span,
|
call_expr.span,
|
||||||
"input to overloaded call fn is not a self receiver",
|
"input to overloaded call fn is not a self receiver",
|
||||||
);
|
);
|
||||||
|
@ -259,9 +259,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() else {
|
let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() else {
|
||||||
// The `fn`/`fn_mut` lang item is ill-formed, which should have
|
// The `fn`/`fn_mut` lang item is ill-formed, which should have
|
||||||
// caused an error elsewhere.
|
// caused an error elsewhere.
|
||||||
self.tcx
|
self.tcx.sess.span_delayed_bug(
|
||||||
.sess
|
call_expr.span,
|
||||||
.delay_span_bug(call_expr.span, "input to call/call_mut is not a ref");
|
"input to call/call_mut is not a ref",
|
||||||
|
);
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let reported = self
|
let reported = self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, format!("`{t:?}` should be sized but is not?"));
|
.span_delayed_bug(span, format!("`{t:?}` should be sized but is not?"));
|
||||||
return Err(reported);
|
return Err(reported);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1549,7 +1549,9 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
// any superfluous errors we might encounter while trying to
|
// any superfluous errors we might encounter while trying to
|
||||||
// emit or provide suggestions on how to fix the initial error.
|
// emit or provide suggestions on how to fix the initial error.
|
||||||
fcx.set_tainted_by_errors(
|
fcx.set_tainted_by_errors(
|
||||||
fcx.tcx.sess.delay_span_bug(cause.span, "coercion error but no error emitted"),
|
fcx.tcx
|
||||||
|
.sess
|
||||||
|
.span_delayed_bug(cause.span, "coercion error but no error emitted"),
|
||||||
);
|
);
|
||||||
let (expected, found) = if label_expression_as_expected {
|
let (expected, found) = if label_expression_as_expected {
|
||||||
// In the case where this is a "forced unit", like
|
// In the case where this is a "forced unit", like
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
self.adjust_expr_for_assert_eq_macro(&mut expr, &mut expected_ty_expr);
|
self.adjust_expr_for_assert_eq_macro(&mut expr, &mut expected_ty_expr);
|
||||||
|
|
||||||
self.set_tainted_by_errors(self.tcx.sess.delay_span_bug(
|
self.set_tainted_by_errors(self.tcx.sess.span_delayed_bug(
|
||||||
expr.span,
|
expr.span,
|
||||||
"`TypeError` when attempting coercion but no error emitted",
|
"`TypeError` when attempting coercion but no error emitted",
|
||||||
));
|
));
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// coercions from ! to `expected`.
|
// coercions from ! to `expected`.
|
||||||
if ty.is_never() {
|
if ty.is_never() {
|
||||||
if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
|
if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
|
||||||
let reported = self.tcx().sess.delay_span_bug(
|
let reported = self.tcx().sess.span_delayed_bug(
|
||||||
expr.span,
|
expr.span,
|
||||||
"expression with never type wound up being adjusted",
|
"expression with never type wound up being adjusted",
|
||||||
);
|
);
|
||||||
|
@ -514,7 +514,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
Res::Err => {
|
Res::Err => {
|
||||||
self.suggest_assoc_method_call(segs);
|
self.suggest_assoc_method_call(segs);
|
||||||
let e =
|
let e =
|
||||||
self.tcx.sess.delay_span_bug(qpath.span(), "`Res::Err` but no error emitted");
|
self.tcx.sess.span_delayed_bug(qpath.span(), "`Res::Err` but no error emitted");
|
||||||
self.set_tainted_by_errors(e);
|
self.set_tainted_by_errors(e);
|
||||||
Ty::new_error(tcx, e)
|
Ty::new_error(tcx, e)
|
||||||
}
|
}
|
||||||
|
@ -623,7 +623,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Set expectation to error in that case and set tainted
|
// Set expectation to error in that case and set tainted
|
||||||
// by error (#114529)
|
// by error (#114529)
|
||||||
let coerce_to = opt_coerce_to.unwrap_or_else(|| {
|
let coerce_to = opt_coerce_to.unwrap_or_else(|| {
|
||||||
let guar = tcx.sess.delay_span_bug(
|
let guar = tcx.sess.span_delayed_bug(
|
||||||
expr.span,
|
expr.span,
|
||||||
"illegal break with value found but no error reported",
|
"illegal break with value found but no error reported",
|
||||||
);
|
);
|
||||||
|
@ -1292,7 +1292,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// permit break with a value [1].
|
// permit break with a value [1].
|
||||||
if ctxt.coerce.is_none() && !ctxt.may_break {
|
if ctxt.coerce.is_none() && !ctxt.may_break {
|
||||||
// [1]
|
// [1]
|
||||||
self.tcx.sess.delay_span_bug(body.span, "no coercion, but loop may not break");
|
self.tcx.sess.span_delayed_bug(body.span, "no coercion, but loop may not break");
|
||||||
}
|
}
|
||||||
ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| Ty::new_unit(self.tcx))
|
ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| Ty::new_unit(self.tcx))
|
||||||
}
|
}
|
||||||
|
@ -2187,7 +2187,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let guar = self
|
let guar = self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(expr.span, "parser recovered but no error was emitted");
|
.span_delayed_bug(expr.span, "parser recovered but no error was emitted");
|
||||||
self.set_tainted_by_errors(guar);
|
self.set_tainted_by_errors(guar);
|
||||||
return guar;
|
return guar;
|
||||||
}
|
}
|
||||||
|
@ -2403,7 +2403,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let guar = if field.name == kw::Empty {
|
let guar = if field.name == kw::Empty {
|
||||||
self.tcx.sess.delay_span_bug(field.span, "field name with no name")
|
self.tcx.sess.span_delayed_bug(field.span, "field name with no name")
|
||||||
} else if self.method_exists(field, base_ty, expr.hir_id, expected.only_has_type(self)) {
|
} else if self.method_exists(field, base_ty, expr.hir_id, expected.only_has_type(self)) {
|
||||||
self.ban_take_value_of_method(expr, base_ty, field)
|
self.ban_take_value_of_method(expr, base_ty, field)
|
||||||
} else if !base_ty.is_primitive_ty() {
|
} else if !base_ty.is_primitive_ty() {
|
||||||
|
|
|
@ -538,7 +538,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
// The struct path probably didn't resolve
|
// The struct path probably didn't resolve
|
||||||
if self.mc.typeck_results.opt_field_index(field.hir_id).is_none() {
|
if self.mc.typeck_results.opt_field_index(field.hir_id).is_none() {
|
||||||
self.tcx().sess.delay_span_bug(field.span, "couldn't resolve index for field");
|
self.tcx().sess.span_delayed_bug(field.span, "couldn't resolve index for field");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// FIXME: currently we never try to compose autoderefs
|
// FIXME: currently we never try to compose autoderefs
|
||||||
// and ReifyFnPointer/UnsafeFnPointer, but we could.
|
// and ReifyFnPointer/UnsafeFnPointer, but we could.
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
expr.span,
|
expr.span,
|
||||||
format!(
|
format!(
|
||||||
"while adjusting {:?}, can't compose {:?} and {:?}",
|
"while adjusting {:?}, can't compose {:?} and {:?}",
|
||||||
|
@ -866,7 +866,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let guar = self
|
let guar = self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, "method resolution should've emitted an error");
|
.span_delayed_bug(span, "method resolution should've emitted an error");
|
||||||
let result = match error {
|
let result = match error {
|
||||||
method::MethodError::PrivateMatch(kind, def_id, _) => Ok((kind, def_id)),
|
method::MethodError::PrivateMatch(kind, def_id, _) => Ok((kind, def_id)),
|
||||||
_ => Err(guar),
|
_ => Err(guar),
|
||||||
|
@ -1440,7 +1440,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
Ok(ok) => self.register_infer_ok_obligations(ok),
|
Ok(ok) => self.register_infer_ok_obligations(ok),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
span,
|
span,
|
||||||
format!(
|
format!(
|
||||||
"instantiate_value_path: (UFCS) {self_ty:?} was a subtype of {impl_ty:?} but now is not?",
|
"instantiate_value_path: (UFCS) {self_ty:?} was a subtype of {impl_ty:?} but now is not?",
|
||||||
|
|
|
@ -517,7 +517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
// FIXME: taint after emitting errors and pass through an `ErrorGuaranteed`
|
// FIXME: taint after emitting errors and pass through an `ErrorGuaranteed`
|
||||||
self.set_tainted_by_errors(
|
self.set_tainted_by_errors(
|
||||||
tcx.sess.delay_span_bug(call_span, "no errors reported for args"),
|
tcx.sess.span_delayed_bug(call_span, "no errors reported for args"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get the argument span in the context of the call span so that
|
// Get the argument span in the context of the call span so that
|
||||||
|
@ -1361,7 +1361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let variant = match def {
|
let variant = match def {
|
||||||
Res::Err => {
|
Res::Err => {
|
||||||
let guar =
|
let guar =
|
||||||
self.tcx.sess.delay_span_bug(path_span, "`Res::Err` but no error emitted");
|
self.tcx.sess.span_delayed_bug(path_span, "`Res::Err` but no error emitted");
|
||||||
self.set_tainted_by_errors(guar);
|
self.set_tainted_by_errors(guar);
|
||||||
return Err(guar);
|
return Err(guar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let to = normalize(to);
|
let to = normalize(to);
|
||||||
trace!(?from, ?to);
|
trace!(?from, ?to);
|
||||||
if from.has_non_region_infer() || to.has_non_region_infer() {
|
if from.has_non_region_infer() || to.has_non_region_infer() {
|
||||||
tcx.sess.delay_span_bug(span, "argument to transmute has inference variables");
|
tcx.sess.span_delayed_bug(span, "argument to transmute has inference variables");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Transmutes that are only changing lifetimes are always ok.
|
// Transmutes that are only changing lifetimes are always ok.
|
||||||
|
|
|
@ -420,20 +420,16 @@ fn fatally_break_rust(tcx: TyCtxt<'_>) {
|
||||||
MultiSpan::new(),
|
MultiSpan::new(),
|
||||||
"It looks like you're trying to break rust; would you like some ICE?",
|
"It looks like you're trying to break rust; would you like some ICE?",
|
||||||
);
|
);
|
||||||
handler.note_without_error("the compiler expectedly panicked. this is a feature.");
|
handler.note("the compiler expectedly panicked. this is a feature.");
|
||||||
handler.note_without_error(
|
handler.note(
|
||||||
"we would appreciate a joke overview: \
|
"we would appreciate a joke overview: \
|
||||||
https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675",
|
https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675",
|
||||||
);
|
);
|
||||||
handler.note_without_error(format!(
|
handler.note(format!("rustc {} running on {}", tcx.sess.cfg_version, config::host_triple(),));
|
||||||
"rustc {} running on {}",
|
|
||||||
tcx.sess.cfg_version,
|
|
||||||
config::host_triple(),
|
|
||||||
));
|
|
||||||
if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
|
if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
|
||||||
handler.note_without_error(format!("compiler flags: {}", flags.join(" ")));
|
handler.note(format!("compiler flags: {}", flags.join(" ")));
|
||||||
if excluded_cargo_defaults {
|
if excluded_cargo_defaults {
|
||||||
handler.note_without_error("some of the compiler flags provided by cargo are hidden");
|
handler.note("some of the compiler flags provided by cargo are hidden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,7 +540,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||||
let ty::Adt(adt_def, _) = ty.kind() else {
|
let ty::Adt(adt_def, _) = ty.kind() else {
|
||||||
self.tcx()
|
self.tcx()
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, "struct or tuple struct pattern not applied to an ADT");
|
.span_delayed_bug(span, "struct or tuple struct pattern not applied to an ADT");
|
||||||
return Err(());
|
return Err(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx()
|
self.tcx()
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, "struct or tuple struct pattern not applied to an ADT");
|
.span_delayed_bug(span, "struct or tuple struct pattern not applied to an ADT");
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Tuple(args) => Ok(args.len()),
|
ty::Tuple(args) => Ok(args.len()),
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx().sess.delay_span_bug(span, "tuple pattern not applied to a tuple");
|
self.tcx().sess.span_delayed_bug(span, "tuple pattern not applied to a tuple");
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,7 +385,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// type parameters or early-bound regions.
|
// type parameters or early-bound regions.
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let Some(method_item) = self.associated_value(trait_def_id, m_name) else {
|
let Some(method_item) = self.associated_value(trait_def_id, m_name) else {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
obligation.cause.span,
|
obligation.cause.span,
|
||||||
"operator trait does not have corresponding operator method",
|
"operator trait does not have corresponding operator method",
|
||||||
);
|
);
|
||||||
|
@ -393,7 +393,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if method_item.kind != ty::AssocKind::Fn {
|
if method_item.kind != ty::AssocKind::Fn {
|
||||||
self.tcx.sess.delay_span_bug(tcx.def_span(method_item.def_id), "not a method");
|
self.tcx.sess.span_delayed_bug(tcx.def_span(method_item.def_id), "not a method");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -802,7 +802,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
|
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
|
||||||
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
|
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
|
||||||
if new_trait_ref.has_non_region_bound_vars() {
|
if new_trait_ref.has_non_region_bound_vars() {
|
||||||
this.tcx.sess.delay_span_bug(
|
this.tcx.sess.span_delayed_bug(
|
||||||
this.span,
|
this.span,
|
||||||
"tried to select method from HRTB with non-lifetime bound vars",
|
"tried to select method from HRTB with non-lifetime bound vars",
|
||||||
);
|
);
|
||||||
|
|
|
@ -813,7 +813,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
span: item_span,
|
span: item_span,
|
||||||
..
|
..
|
||||||
})) => {
|
})) => {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
*item_span,
|
*item_span,
|
||||||
"auto trait is invoked with no method error, but no error reported?",
|
"auto trait is invoked with no method error, but no error reported?",
|
||||||
);
|
);
|
||||||
|
|
|
@ -900,7 +900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
) {
|
) {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, "operator didn't have the right number of generic args");
|
.span_delayed_bug(span, "operator didn't have the right number of generic args");
|
||||||
return Err(vec![]);
|
return Err(vec![]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -933,7 +933,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// This path may do some inference, so make sure we've really
|
// This path may do some inference, so make sure we've really
|
||||||
// doomed compilation so as to not accidentally stabilize new
|
// doomed compilation so as to not accidentally stabilize new
|
||||||
// inference or something here...
|
// inference or something here...
|
||||||
self.tcx.sess.delay_span_bug(span, "this path really should be doomed...");
|
self.tcx.sess.span_delayed_bug(span, "this path really should be doomed...");
|
||||||
// Guide inference for the RHS expression if it's provided --
|
// Guide inference for the RHS expression if it's provided --
|
||||||
// this will allow us to better error reporting, at the expense
|
// this will allow us to better error reporting, at the expense
|
||||||
// of making some error messages a bit more specific.
|
// of making some error messages a bit more specific.
|
||||||
|
|
|
@ -899,7 +899,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let (res, opt_ty, segments) = path_resolution;
|
let (res, opt_ty, segments) = path_resolution;
|
||||||
match res {
|
match res {
|
||||||
Res::Err => {
|
Res::Err => {
|
||||||
let e = tcx.sess.delay_span_bug(qpath.span(), "`Res::Err` but no error emitted");
|
let e = tcx.sess.span_delayed_bug(qpath.span(), "`Res::Err` but no error emitted");
|
||||||
self.set_tainted_by_errors(e);
|
self.set_tainted_by_errors(e);
|
||||||
return Ty::new_error(tcx, e);
|
return Ty::new_error(tcx, e);
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1068,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
let (res, opt_ty, segments) =
|
let (res, opt_ty, segments) =
|
||||||
self.resolve_ty_and_res_fully_qualified_call(qpath, pat.hir_id, pat.span, None);
|
self.resolve_ty_and_res_fully_qualified_call(qpath, pat.hir_id, pat.span, None);
|
||||||
if res == Res::Err {
|
if res == Res::Err {
|
||||||
let e = tcx.sess.delay_span_bug(pat.span, "`Res::Err` but no error emitted");
|
let e = tcx.sess.span_delayed_bug(pat.span, "`Res::Err` but no error emitted");
|
||||||
self.set_tainted_by_errors(e);
|
self.set_tainted_by_errors(e);
|
||||||
on_error(e);
|
on_error(e);
|
||||||
return Ty::new_error(tcx, e);
|
return Ty::new_error(tcx, e);
|
||||||
|
@ -1084,7 +1084,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let variant = match res {
|
let variant = match res {
|
||||||
Res::Err => {
|
Res::Err => {
|
||||||
let e = tcx.sess.delay_span_bug(pat.span, "`Res::Err` but no error emitted");
|
let e = tcx.sess.span_delayed_bug(pat.span, "`Res::Err` but no error emitted");
|
||||||
self.set_tainted_by_errors(e);
|
self.set_tainted_by_errors(e);
|
||||||
on_error(e);
|
on_error(e);
|
||||||
return Ty::new_error(tcx, e);
|
return Ty::new_error(tcx, e);
|
||||||
|
|
|
@ -725,7 +725,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
closure_span,
|
closure_span,
|
||||||
format!(
|
format!(
|
||||||
"two identical projections: ({:?}, {:?})",
|
"two identical projections: ({:?}, {:?})",
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||||
// When encountering `return [0][0]` outside of a `fn` body we can encounter a base
|
// When encountering `return [0][0]` outside of a `fn` body we can encounter a base
|
||||||
// that isn't in the type table. We assume more relevant errors have already been
|
// that isn't in the type table. We assume more relevant errors have already been
|
||||||
// emitted, so we delay an ICE if none have. (#64638)
|
// emitted, so we delay an ICE if none have. (#64638)
|
||||||
self.tcx().sess.delay_span_bug(e.span, format!("bad base: `{base:?}`"));
|
self.tcx().sess.span_delayed_bug(e.span, format!("bad base: `{base:?}`"));
|
||||||
}
|
}
|
||||||
if let Some(base_ty) = base_ty
|
if let Some(base_ty) = base_ty
|
||||||
&& let ty::Ref(_, base_ty_inner, _) = *base_ty.kind()
|
&& let ty::Ref(_, base_ty_inner, _) = *base_ty.kind()
|
||||||
|
@ -311,7 +311,9 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
|
||||||
// Nothing to write back here
|
// Nothing to write back here
|
||||||
}
|
}
|
||||||
hir::GenericParamKind::Type { .. } | hir::GenericParamKind::Const { .. } => {
|
hir::GenericParamKind::Type { .. } | hir::GenericParamKind::Const { .. } => {
|
||||||
self.tcx().sess.delay_span_bug(p.span, format!("unexpected generic param: {p:?}"));
|
self.tcx()
|
||||||
|
.sess
|
||||||
|
.span_delayed_bug(p.span, format!("unexpected generic param: {p:?}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,7 +312,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
|
||||||
|
|
||||||
let incr_comp_session_dir: PathBuf = sess.incr_comp_session_dir().clone();
|
let incr_comp_session_dir: PathBuf = sess.incr_comp_session_dir().clone();
|
||||||
|
|
||||||
if let Some(_) = sess.has_errors_or_delayed_span_bugs() {
|
if let Some(_) = sess.has_errors_or_span_delayed_bugs() {
|
||||||
// If there have been any errors during compilation, we don't want to
|
// If there have been any errors during compilation, we don't want to
|
||||||
// publish this session directory. Rather, we'll just delete it.
|
// publish this session directory. Rather, we'll just delete it.
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// This is going to be deleted in finalize_session_directory, so let's not create it
|
// This is going to be deleted in finalize_session_directory, so let's not create it
|
||||||
if let Some(_) = sess.has_errors_or_delayed_span_bugs() {
|
if let Some(_) = sess.has_errors_or_span_delayed_bugs() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ pub fn save_work_product_index(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// This is going to be deleted in finalize_session_directory, so let's not create it
|
// This is going to be deleted in finalize_session_directory, so let's not create it
|
||||||
if let Some(_) = sess.has_errors_or_delayed_span_bugs() {
|
if let Some(_) = sess.has_errors_or_span_delayed_bugs() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,8 +194,8 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
|
||||||
//
|
//
|
||||||
// rust-lang/rust#57464: `impl Trait` can leak local
|
// rust-lang/rust#57464: `impl Trait` can leak local
|
||||||
// scopes (in manner violating typeck). Therefore, use
|
// scopes (in manner violating typeck). Therefore, use
|
||||||
// `delay_span_bug` to allow type error over an ICE.
|
// `span_delayed_bug` to allow type error over an ICE.
|
||||||
canonicalizer.tcx.sess.delay_span_bug(
|
canonicalizer.tcx.sess.span_delayed_bug(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
format!("unexpected region in query response: `{r:?}`"),
|
format!("unexpected region in query response: `{r:?}`"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -175,7 +175,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
&mut OriginalQueryValues::default(),
|
&mut OriginalQueryValues::default(),
|
||||||
);
|
);
|
||||||
self.tcx.check_tys_might_be_eq(canonical).map_err(|_| {
|
self.tcx.check_tys_might_be_eq(canonical).map_err(|_| {
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
format!("cannot relate consts of different types (a={a:?}, b={b:?})",),
|
format!("cannot relate consts of different types (a={a:?}, b={b:?})",),
|
||||||
)
|
)
|
||||||
|
|
|
@ -131,13 +131,13 @@ pub struct TypeErrCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
impl Drop for TypeErrCtxt<'_, '_> {
|
impl Drop for TypeErrCtxt<'_, '_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Some(_) = self.infcx.tcx.sess.has_errors_or_delayed_span_bugs() {
|
if let Some(_) = self.infcx.tcx.sess.has_errors_or_span_delayed_bugs() {
|
||||||
// ok, emitted an error.
|
// ok, emitted an error.
|
||||||
} else {
|
} else {
|
||||||
self.infcx
|
self.infcx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_good_path_bug("used a `TypeErrCtxt` without raising an error or lint");
|
.good_path_delayed_bug("used a `TypeErrCtxt` without raising an error or lint");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
|
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(self.tcx.def_span(generic_param_scope), "expected region errors")
|
.span_delayed_bug(self.tcx.def_span(generic_param_scope), "expected region errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method goes through all the errors and try to group certain types
|
// This method goes through all the errors and try to group certain types
|
||||||
|
|
|
@ -374,7 +374,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
multi_suggestions,
|
multi_suggestions,
|
||||||
bad_label,
|
bad_label,
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic),
|
.into_diagnostic(self.tcx.sess.diagnostic()),
|
||||||
TypeAnnotationNeeded::E0283 => AmbiguousImpl {
|
TypeAnnotationNeeded::E0283 => AmbiguousImpl {
|
||||||
span,
|
span,
|
||||||
source_kind,
|
source_kind,
|
||||||
|
@ -384,7 +384,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
multi_suggestions,
|
multi_suggestions,
|
||||||
bad_label,
|
bad_label,
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic),
|
.into_diagnostic(self.tcx.sess.diagnostic()),
|
||||||
TypeAnnotationNeeded::E0284 => AmbiguousReturn {
|
TypeAnnotationNeeded::E0284 => AmbiguousReturn {
|
||||||
span,
|
span,
|
||||||
source_kind,
|
source_kind,
|
||||||
|
@ -394,7 +394,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
multi_suggestions,
|
multi_suggestions,
|
||||||
bad_label,
|
bad_label,
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic),
|
.into_diagnostic(self.tcx.sess.diagnostic()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
multi_suggestions,
|
multi_suggestions,
|
||||||
bad_label: None,
|
bad_label: None,
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic),
|
.into_diagnostic(self.tcx.sess.diagnostic()),
|
||||||
TypeAnnotationNeeded::E0283 => AmbiguousImpl {
|
TypeAnnotationNeeded::E0283 => AmbiguousImpl {
|
||||||
span,
|
span,
|
||||||
source_kind,
|
source_kind,
|
||||||
|
@ -591,7 +591,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
multi_suggestions,
|
multi_suggestions,
|
||||||
bad_label: None,
|
bad_label: None,
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic),
|
.into_diagnostic(self.tcx.sess.diagnostic()),
|
||||||
TypeAnnotationNeeded::E0284 => AmbiguousReturn {
|
TypeAnnotationNeeded::E0284 => AmbiguousReturn {
|
||||||
span,
|
span,
|
||||||
source_kind,
|
source_kind,
|
||||||
|
@ -601,7 +601,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
multi_suggestions,
|
multi_suggestions,
|
||||||
bad_label: None,
|
bad_label: None,
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic),
|
.into_diagnostic(self.tcx.sess.diagnostic()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
span,
|
span,
|
||||||
notes: reference_valid.into_iter().chain(content_valid).collect(),
|
notes: reference_valid.into_iter().chain(content_valid).collect(),
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
.into_diagnostic(self.tcx.sess.diagnostic())
|
||||||
}
|
}
|
||||||
infer::RelateObjectBound(span) => {
|
infer::RelateObjectBound(span) => {
|
||||||
let object_valid = note_and_explain::RegionExplanation::new(
|
let object_valid = note_and_explain::RegionExplanation::new(
|
||||||
|
@ -161,7 +161,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
span,
|
span,
|
||||||
notes: object_valid.into_iter().chain(pointer_valid).collect(),
|
notes: object_valid.into_iter().chain(pointer_valid).collect(),
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
.into_diagnostic(self.tcx.sess.diagnostic())
|
||||||
}
|
}
|
||||||
infer::RelateParamBound(span, ty, opt_span) => {
|
infer::RelateParamBound(span, ty, opt_span) => {
|
||||||
let prefix = match *sub {
|
let prefix = match *sub {
|
||||||
|
@ -177,7 +177,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
self.tcx, sub, opt_span, prefix, suffix,
|
self.tcx, sub, opt_span, prefix, suffix,
|
||||||
);
|
);
|
||||||
FulfillReqLifetime { span, ty: self.resolve_vars_if_possible(ty), note }
|
FulfillReqLifetime { span, ty: self.resolve_vars_if_possible(ty), note }
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
.into_diagnostic(self.tcx.sess.diagnostic())
|
||||||
}
|
}
|
||||||
infer::RelateRegionParamBound(span) => {
|
infer::RelateRegionParamBound(span) => {
|
||||||
let param_instantiated = note_and_explain::RegionExplanation::new(
|
let param_instantiated = note_and_explain::RegionExplanation::new(
|
||||||
|
@ -198,7 +198,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
span,
|
span,
|
||||||
notes: param_instantiated.into_iter().chain(param_must_outlive).collect(),
|
notes: param_instantiated.into_iter().chain(param_must_outlive).collect(),
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
.into_diagnostic(self.tcx.sess.diagnostic())
|
||||||
}
|
}
|
||||||
infer::ReferenceOutlivesReferent(ty, span) => {
|
infer::ReferenceOutlivesReferent(ty, span) => {
|
||||||
let pointer_valid = note_and_explain::RegionExplanation::new(
|
let pointer_valid = note_and_explain::RegionExplanation::new(
|
||||||
|
@ -220,7 +220,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
ty: self.resolve_vars_if_possible(ty),
|
ty: self.resolve_vars_if_possible(ty),
|
||||||
notes: pointer_valid.into_iter().chain(data_valid).collect(),
|
notes: pointer_valid.into_iter().chain(data_valid).collect(),
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
.into_diagnostic(self.tcx.sess.diagnostic())
|
||||||
}
|
}
|
||||||
infer::CompareImplItemObligation { span, impl_item_def_id, trait_item_def_id } => {
|
infer::CompareImplItemObligation { span, impl_item_def_id, trait_item_def_id } => {
|
||||||
let mut err = self.report_extra_impl_obligation(
|
let mut err = self.report_extra_impl_obligation(
|
||||||
|
@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
span,
|
span,
|
||||||
notes: instantiated.into_iter().chain(must_outlive).collect(),
|
notes: instantiated.into_iter().chain(must_outlive).collect(),
|
||||||
}
|
}
|
||||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
.into_diagnostic(self.tcx.sess.diagnostic())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if sub.is_error() || sup.is_error() {
|
if sub.is_error() || sup.is_error() {
|
||||||
|
|
|
@ -798,7 +798,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
||||||
|
|
||||||
// Errors in earlier passes can yield error variables without
|
// Errors in earlier passes can yield error variables without
|
||||||
// resolution errors here; delay ICE in favor of those errors.
|
// resolution errors here; delay ICE in favor of those errors.
|
||||||
self.tcx().sess.delay_span_bug(
|
self.tcx().sess.span_delayed_bug(
|
||||||
self.var_infos[node_idx].origin.span(),
|
self.var_infos[node_idx].origin.span(),
|
||||||
format!(
|
format!(
|
||||||
"collect_error_for_expanding_node() could not find \
|
"collect_error_for_expanding_node() could not find \
|
||||||
|
|
|
@ -1433,7 +1433,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
let guar = self
|
let guar = self
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(DUMMY_SP, format!("`{value:?}` is not fully resolved"));
|
.span_delayed_bug(DUMMY_SP, format!("`{value:?}` is not fully resolved"));
|
||||||
Ok(self.tcx.fold_regions(value, |re, _| {
|
Ok(self.tcx.fold_regions(value, |re, _| {
|
||||||
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
|
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -494,7 +494,7 @@ where
|
||||||
// shouldn't ever fail. Instead, it unconditionally emits an
|
// shouldn't ever fail. Instead, it unconditionally emits an
|
||||||
// alias-relate goal.
|
// alias-relate goal.
|
||||||
assert!(!self.infcx.next_trait_solver());
|
assert!(!self.infcx.next_trait_solver());
|
||||||
self.tcx().sess.delay_span_bug(
|
self.tcx().sess.span_delayed_bug(
|
||||||
self.delegate.span(),
|
self.delegate.span(),
|
||||||
"failure to relate an opaque to itself should result in an error later on",
|
"failure to relate an opaque to itself should result in an error later on",
|
||||||
);
|
);
|
||||||
|
@ -552,7 +552,7 @@ where
|
||||||
match b.kind() {
|
match b.kind() {
|
||||||
ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => {
|
ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => {
|
||||||
// Forbid inference variables in the RHS.
|
// Forbid inference variables in the RHS.
|
||||||
self.infcx.tcx.sess.delay_span_bug(
|
self.infcx.tcx.sess.span_delayed_bug(
|
||||||
self.delegate.span(),
|
self.delegate.span(),
|
||||||
format!("unexpected inference var {b:?}",),
|
format!("unexpected inference var {b:?}",),
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if !self.opaque_types.is_empty() {
|
if !self.opaque_types.is_empty() {
|
||||||
ty::tls::with(|tcx| {
|
ty::tls::with(|tcx| {
|
||||||
tcx.sess.delay_span_bug(DUMMY_SP, format!("{:?}", self.opaque_types))
|
tcx.sess.span_delayed_bug(DUMMY_SP, format!("{:?}", self.opaque_types))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ where
|
||||||
// ignore this, we presume it will yield an error
|
// ignore this, we presume it will yield an error
|
||||||
// later, since if a type variable is not resolved by
|
// later, since if a type variable is not resolved by
|
||||||
// this point it never will be
|
// this point it never will be
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
origin.span(),
|
origin.span(),
|
||||||
format!("unresolved inference variable in outlives: {v:?}"),
|
format!("unresolved inference variable in outlives: {v:?}"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -180,7 +180,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
||||||
// ignore this, we presume it will yield an error
|
// ignore this, we presume it will yield an error
|
||||||
// later, since if a type variable is not resolved by
|
// later, since if a type variable is not resolved by
|
||||||
// this point it never will be
|
// this point it never will be
|
||||||
self.tcx.sess.delay_span_bug(
|
self.tcx.sess.span_delayed_bug(
|
||||||
rustc_span::DUMMY_SP,
|
rustc_span::DUMMY_SP,
|
||||||
format!("unresolved inference variable in outlives: {v:?}"),
|
format!("unresolved inference variable in outlives: {v:?}"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -519,9 +519,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if sess.opts.json_artifact_notifications {
|
if sess.opts.json_artifact_notifications {
|
||||||
sess.parse_sess
|
sess.diagnostic().emit_artifact_notification(deps_filename, "dep-info");
|
||||||
.span_diagnostic
|
|
||||||
.emit_artifact_notification(deps_filename, "dep-info");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|
|
@ -194,16 +194,16 @@ impl<'tcx> Queries<'tcx> {
|
||||||
let Some((def_id, _)) = tcx.entry_fn(()) else { return };
|
let Some((def_id, _)) = tcx.entry_fn(()) else { return };
|
||||||
for attr in tcx.get_attrs(def_id, sym::rustc_error) {
|
for attr in tcx.get_attrs(def_id, sym::rustc_error) {
|
||||||
match attr.meta_item_list() {
|
match attr.meta_item_list() {
|
||||||
// Check if there is a `#[rustc_error(delay_span_bug_from_inside_query)]`.
|
// Check if there is a `#[rustc_error(span_delayed_bug_from_inside_query)]`.
|
||||||
Some(list)
|
Some(list)
|
||||||
if list.iter().any(|list_item| {
|
if list.iter().any(|list_item| {
|
||||||
matches!(
|
matches!(
|
||||||
list_item.ident().map(|i| i.name),
|
list_item.ident().map(|i| i.name),
|
||||||
Some(sym::delay_span_bug_from_inside_query)
|
Some(sym::span_delayed_bug_from_inside_query)
|
||||||
)
|
)
|
||||||
}) =>
|
}) =>
|
||||||
{
|
{
|
||||||
tcx.ensure().trigger_delay_span_bug(def_id);
|
tcx.ensure().trigger_span_delayed_bug(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bare `#[rustc_error]`.
|
// Bare `#[rustc_error]`.
|
||||||
|
|
|
@ -430,7 +430,7 @@ pub fn check_ast_node_inner<'a, T: EarlyLintPass>(
|
||||||
// that was not lint-checked (perhaps it doesn't exist?). This is a bug.
|
// that was not lint-checked (perhaps it doesn't exist?). This is a bug.
|
||||||
for (id, lints) in cx.context.buffered.map {
|
for (id, lints) in cx.context.buffered.map {
|
||||||
for early_lint in lints {
|
for early_lint in lints {
|
||||||
sess.delay_span_bug(
|
sess.span_delayed_bug(
|
||||||
early_lint.span,
|
early_lint.span,
|
||||||
format!(
|
format!(
|
||||||
"failed to process buffered lint here (dummy = {})",
|
"failed to process buffered lint here (dummy = {})",
|
||||||
|
|
|
@ -267,7 +267,7 @@ impl CStore {
|
||||||
let unused_externs =
|
let unused_externs =
|
||||||
self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
|
self.unused_externs.iter().map(|ident| ident.to_ident_string()).collect::<Vec<_>>();
|
||||||
let unused_externs = unused_externs.iter().map(String::as_str).collect::<Vec<&str>>();
|
let unused_externs = unused_externs.iter().map(String::as_str).collect::<Vec<&str>>();
|
||||||
tcx.sess.parse_sess.span_diagnostic.emit_unused_externs(
|
tcx.sess.diagnostic().emit_unused_externs(
|
||||||
level,
|
level,
|
||||||
json_unused_externs.is_loud(),
|
json_unused_externs.is_loud(),
|
||||||
&unused_externs,
|
&unused_externs,
|
||||||
|
|
|
@ -91,10 +91,7 @@ pub fn encode_and_write_metadata(tcx: TyCtxt<'_>) -> (EncodedMetadata, bool) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if tcx.sess.opts.json_artifact_notifications {
|
if tcx.sess.opts.json_artifact_notifications {
|
||||||
tcx.sess
|
tcx.sess.diagnostic().emit_artifact_notification(out_filename.as_path(), "metadata");
|
||||||
.parse_sess
|
|
||||||
.span_diagnostic
|
|
||||||
.emit_artifact_notification(out_filename.as_path(), "metadata");
|
|
||||||
}
|
}
|
||||||
(filename, None)
|
(filename, None)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
///
|
///
|
||||||
/// If you have a span available, you should use [`span_bug`] instead.
|
/// If you have a span available, you should use [`span_bug`] instead.
|
||||||
///
|
///
|
||||||
/// If the bug should only be emitted when compilation didn't fail, [`Session::delay_span_bug`] may be useful.
|
/// If the bug should only be emitted when compilation didn't fail, [`Session::span_delayed_bug`]
|
||||||
|
/// may be useful.
|
||||||
///
|
///
|
||||||
/// [`Session::delay_span_bug`]: rustc_session::Session::delay_span_bug
|
/// [`Session::span_delayed_bug`]: rustc_session::Session::span_delayed_bug
|
||||||
/// [`span_bug`]: crate::span_bug
|
/// [`span_bug`]: crate::span_bug
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! bug {
|
macro_rules! bug {
|
||||||
|
@ -23,9 +24,10 @@ macro_rules! bug {
|
||||||
/// at the code the compiler was compiling when it ICEd. This is the preferred way to trigger
|
/// at the code the compiler was compiling when it ICEd. This is the preferred way to trigger
|
||||||
/// ICEs.
|
/// ICEs.
|
||||||
///
|
///
|
||||||
/// If the bug should only be emitted when compilation didn't fail, [`Session::delay_span_bug`] may be useful.
|
/// If the bug should only be emitted when compilation didn't fail, [`Session::span_delayed_bug`]
|
||||||
|
/// may be useful.
|
||||||
///
|
///
|
||||||
/// [`Session::delay_span_bug`]: rustc_session::Session::delay_span_bug
|
/// [`Session::span_delayed_bug`]: rustc_session::Session::span_delayed_bug
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! span_bug {
|
macro_rules! span_bug {
|
||||||
($span:expr, $msg:expr) => ({ $crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg)) });
|
($span:expr, $msg:expr) => ({ $crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg)) });
|
||||||
|
|
|
@ -566,7 +566,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|span, def_id| {
|
|span, def_id| {
|
||||||
// The API could be uncallable for other reasons, for example when a private module
|
// The API could be uncallable for other reasons, for example when a private module
|
||||||
// was referenced.
|
// was referenced.
|
||||||
self.sess.delay_span_bug(span, format!("encountered unmarked API: {def_id:?}"));
|
self.sess.span_delayed_bug(span, format!("encountered unmarked API: {def_id:?}"));
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,7 +315,7 @@ impl<Prov: Provenance, Bytes: AllocBytes> Allocation<Prov, (), Bytes> {
|
||||||
pub fn try_uninit<'tcx>(size: Size, align: Align) -> InterpResult<'tcx, Self> {
|
pub fn try_uninit<'tcx>(size: Size, align: Align) -> InterpResult<'tcx, Self> {
|
||||||
Self::uninit_inner(size, align, || {
|
Self::uninit_inner(size, align, || {
|
||||||
ty::tls::with(|tcx| {
|
ty::tls::with(|tcx| {
|
||||||
tcx.sess.delay_span_bug(DUMMY_SP, "exhausted memory during interpretation")
|
tcx.sess.span_delayed_bug(DUMMY_SP, "exhausted memory during interpretation")
|
||||||
});
|
});
|
||||||
InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted).into()
|
InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted).into()
|
||||||
})
|
})
|
||||||
|
|
|
@ -199,7 +199,7 @@ pub struct LitToConstInput<'tcx> {
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, HashStable)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, HashStable)]
|
||||||
pub enum LitToConstError {
|
pub enum LitToConstError {
|
||||||
/// The literal's inferred type did not match the expected `ty` in the input.
|
/// The literal's inferred type did not match the expected `ty` in the input.
|
||||||
/// This is used for graceful error handling (`delay_span_bug`) in
|
/// This is used for graceful error handling (`span_delayed_bug`) in
|
||||||
/// type checking (`Const::from_anon_const`).
|
/// type checking (`Const::from_anon_const`).
|
||||||
TypeError,
|
TypeError,
|
||||||
Reported(ErrorGuaranteed),
|
Reported(ErrorGuaranteed),
|
||||||
|
|
|
@ -108,9 +108,9 @@ pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue
|
||||||
// Queries marked with `fatal_cycle` do not need the latter implementation,
|
// Queries marked with `fatal_cycle` do not need the latter implementation,
|
||||||
// as they will raise an fatal error on query cycles instead.
|
// as they will raise an fatal error on query cycles instead.
|
||||||
rustc_queries! {
|
rustc_queries! {
|
||||||
/// This exists purely for testing the interactions between delay_span_bug and incremental.
|
/// This exists purely for testing the interactions between span_delayed_bug and incremental.
|
||||||
query trigger_delay_span_bug(key: DefId) -> () {
|
query trigger_span_delayed_bug(key: DefId) -> () {
|
||||||
desc { "triggering a delay span bug for testing incremental" }
|
desc { "triggering a span delayed bug for testing incremental" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Collects the list of all tools registered using `#![register_tool]`.
|
/// Collects the list of all tools registered using `#![register_tool]`.
|
||||||
|
|
|
@ -551,7 +551,7 @@ macro_rules! define_feedable {
|
||||||
// We have an inconsistency. This can happen if one of the two
|
// We have an inconsistency. This can happen if one of the two
|
||||||
// results is tainted by errors. In this case, delay a bug to
|
// results is tainted by errors. In this case, delay a bug to
|
||||||
// ensure compilation is doomed, and keep the `old` value.
|
// ensure compilation is doomed, and keep the `old` value.
|
||||||
tcx.sess.delay_span_bug(DUMMY_SP, format!(
|
tcx.sess.span_delayed_bug(DUMMY_SP, format!(
|
||||||
"Trying to feed an already recorded value for query {} key={key:?}:\n\
|
"Trying to feed an already recorded value for query {} key={key:?}:\n\
|
||||||
old value: {old:?}\nnew value: {value:?}",
|
old value: {old:?}\nnew value: {value:?}",
|
||||||
stringify!($name),
|
stringify!($name),
|
||||||
|
|
|
@ -481,7 +481,7 @@ impl<'tcx> AdtDef<'tcx> {
|
||||||
ErrorHandled::Reported(..) => "enum discriminant evaluation failed",
|
ErrorHandled::Reported(..) => "enum discriminant evaluation failed",
|
||||||
ErrorHandled::TooGeneric(..) => "enum discriminant depends on generics",
|
ErrorHandled::TooGeneric(..) => "enum discriminant depends on generics",
|
||||||
};
|
};
|
||||||
tcx.sess.delay_span_bug(tcx.def_span(expr_did), msg);
|
tcx.sess.span_delayed_bug(tcx.def_span(expr_did), msg);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl<'tcx> Const<'tcx> {
|
||||||
span: S,
|
span: S,
|
||||||
msg: &'static str,
|
msg: &'static str,
|
||||||
) -> Const<'tcx> {
|
) -> Const<'tcx> {
|
||||||
let reported = tcx.sess.delay_span_bug(span, msg);
|
let reported = tcx.sess.span_delayed_bug(span, msg);
|
||||||
Const::new_error(tcx, reported, ty)
|
Const::new_error(tcx, reported, ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ impl<'tcx> Const<'tcx> {
|
||||||
match tcx.at(expr.span).lit_to_const(lit_input) {
|
match tcx.at(expr.span).lit_to_const(lit_input) {
|
||||||
Ok(c) => return Some(c),
|
Ok(c) => return Some(c),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tcx.sess.delay_span_bug(
|
tcx.sess.span_delayed_bug(
|
||||||
expr.span,
|
expr.span,
|
||||||
format!("Const::from_anon_const: couldn't lit_to_const {e:?}"),
|
format!("Const::from_anon_const: couldn't lit_to_const {e:?}"),
|
||||||
);
|
);
|
||||||
|
|
|
@ -714,8 +714,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
{
|
{
|
||||||
Bound::Included(a)
|
Bound::Included(a)
|
||||||
} else {
|
} else {
|
||||||
self.sess
|
self.sess.span_delayed_bug(
|
||||||
.delay_span_bug(attr.span, "invalid rustc_layout_scalar_valid_range attribute");
|
attr.span,
|
||||||
|
"invalid rustc_layout_scalar_valid_range attribute",
|
||||||
|
);
|
||||||
Bound::Unbounded
|
Bound::Unbounded
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -282,8 +282,8 @@ pub struct LayoutCx<'tcx, C> {
|
||||||
impl<'tcx> LayoutCalculator for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
impl<'tcx> LayoutCalculator for LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||||
type TargetDataLayoutRef = &'tcx TargetDataLayout;
|
type TargetDataLayoutRef = &'tcx TargetDataLayout;
|
||||||
|
|
||||||
fn delay_bug(&self, txt: String) {
|
fn delayed_bug(&self, txt: String) {
|
||||||
self.tcx.sess.delay_span_bug(DUMMY_SP, txt);
|
self.tcx.sess.span_delayed_bug(DUMMY_SP, txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_data_layout(&self) -> Self::TargetDataLayoutRef {
|
fn current_data_layout(&self) -> Self::TargetDataLayoutRef {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue