mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Remove Session
methods that duplicate DiagCtxt
methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
This commit is contained in:
parent
d51db05d7e
commit
99472c7049
@ -32,7 +32,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
let asm_arch =
|
||||
if self.tcx.sess.opts.actually_rustdoc { None } else { self.tcx.sess.asm_arch };
|
||||
if asm_arch.is_none() && !self.tcx.sess.opts.actually_rustdoc {
|
||||
self.tcx.sess.emit_err(InlineAsmUnsupportedTarget { span: sp });
|
||||
self.dcx().emit_err(InlineAsmUnsupportedTarget { span: sp });
|
||||
}
|
||||
if let Some(asm_arch) = asm_arch {
|
||||
// Inline assembly is currently only stable for these architectures.
|
||||
@ -60,7 +60,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
&& !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
|
||||
&& !self.tcx.sess.opts.actually_rustdoc
|
||||
{
|
||||
self.tcx.sess.emit_err(AttSyntaxOnlyX86 { span: sp });
|
||||
self.dcx().emit_err(AttSyntaxOnlyX86 { span: sp });
|
||||
}
|
||||
if asm.options.contains(InlineAsmOptions::MAY_UNWIND) && !self.tcx.features().asm_unwind {
|
||||
feature_err(
|
||||
@ -87,7 +87,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
!= source_map.span_to_snippet(*abi_span))
|
||||
.then_some(());
|
||||
|
||||
self.tcx.sess.emit_err(AbiSpecifiedMultipleTimes {
|
||||
self.dcx().emit_err(AbiSpecifiedMultipleTimes {
|
||||
abi_span: *abi_span,
|
||||
prev_name: *prev_name,
|
||||
prev_span: *prev_sp,
|
||||
@ -100,14 +100,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
Err(&[]) => {
|
||||
self.tcx.sess.emit_err(ClobberAbiNotSupported { abi_span: *abi_span });
|
||||
self.dcx().emit_err(ClobberAbiNotSupported { abi_span: *abi_span });
|
||||
}
|
||||
Err(supported_abis) => {
|
||||
let mut abis = format!("`{}`", supported_abis[0]);
|
||||
for m in &supported_abis[1..] {
|
||||
let _ = write!(abis, ", `{m}`");
|
||||
}
|
||||
self.tcx.sess.emit_err(InvalidAbiClobberAbi {
|
||||
self.dcx().emit_err(InvalidAbiClobberAbi {
|
||||
abi_span: *abi_span,
|
||||
supported_abis: abis,
|
||||
});
|
||||
@ -128,7 +128,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
InlineAsmRegOrRegClass::Reg(reg) => {
|
||||
asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
|
||||
asm::InlineAsmReg::parse(asm_arch, reg).unwrap_or_else(|error| {
|
||||
sess.emit_err(InvalidRegister { op_span: *op_sp, reg, error });
|
||||
self.dcx().emit_err(InvalidRegister {
|
||||
op_span: *op_sp,
|
||||
reg,
|
||||
error,
|
||||
});
|
||||
asm::InlineAsmReg::Err
|
||||
})
|
||||
} else {
|
||||
@ -139,7 +143,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
|
||||
asm::InlineAsmRegClass::parse(asm_arch, reg_class).unwrap_or_else(
|
||||
|error| {
|
||||
sess.emit_err(InvalidRegisterClass {
|
||||
self.dcx().emit_err(InvalidRegisterClass {
|
||||
op_span: *op_sp,
|
||||
reg_class,
|
||||
error,
|
||||
@ -276,7 +280,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
class_name: class.name(),
|
||||
}
|
||||
};
|
||||
sess.emit_err(InvalidAsmTemplateModifierRegClass {
|
||||
self.dcx().emit_err(InvalidAsmTemplateModifierRegClass {
|
||||
placeholder_span,
|
||||
op_span: op_sp,
|
||||
sub,
|
||||
@ -284,14 +288,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
hir::InlineAsmOperand::Const { .. } => {
|
||||
sess.emit_err(InvalidAsmTemplateModifierConst {
|
||||
self.dcx().emit_err(InvalidAsmTemplateModifierConst {
|
||||
placeholder_span,
|
||||
op_span: op_sp,
|
||||
});
|
||||
}
|
||||
hir::InlineAsmOperand::SymFn { .. }
|
||||
| hir::InlineAsmOperand::SymStatic { .. } => {
|
||||
sess.emit_err(InvalidAsmTemplateModifierSym {
|
||||
self.dcx().emit_err(InvalidAsmTemplateModifierSym {
|
||||
placeholder_span,
|
||||
op_span: op_sp,
|
||||
});
|
||||
@ -315,7 +319,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// require that the operand name an explicit register, not a
|
||||
// register class.
|
||||
if reg_class.is_clobber_only(asm_arch.unwrap()) && !op.is_clobber() {
|
||||
sess.emit_err(RegisterClassOnlyClobber {
|
||||
self.dcx().emit_err(RegisterClassOnlyClobber {
|
||||
op_span: op_sp,
|
||||
reg_class_name: reg_class.name(),
|
||||
});
|
||||
@ -384,7 +388,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
};
|
||||
|
||||
sess.emit_err(RegisterConflict {
|
||||
self.dcx().emit_err(RegisterConflict {
|
||||
op_span1: op_sp,
|
||||
op_span2: op_sp2,
|
||||
reg1_name: reg_str(idx),
|
||||
|
@ -249,7 +249,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), *lims)
|
||||
}
|
||||
ExprKind::Underscore => {
|
||||
let guar = self.tcx.sess.emit_err(UnderscoreExprLhsAssign { span: e.span });
|
||||
let guar = self.dcx().emit_err(UnderscoreExprLhsAssign { span: e.span });
|
||||
hir::ExprKind::Err(guar)
|
||||
}
|
||||
ExprKind::Path(qself, path) => {
|
||||
@ -294,8 +294,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let rest = match &se.rest {
|
||||
StructRest::Base(e) => Some(self.lower_expr(e)),
|
||||
StructRest::Rest(sp) => {
|
||||
let guar =
|
||||
self.tcx.sess.emit_err(BaseExpressionDoubleDot { span: *sp });
|
||||
let guar = self.dcx().emit_err(BaseExpressionDoubleDot { span: *sp });
|
||||
Some(&*self.arena.alloc(self.expr_err(*sp, guar)))
|
||||
}
|
||||
StructRest::None => None,
|
||||
@ -332,9 +331,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
|this| this.with_new_scopes(e.span, |this| this.lower_block_expr(block)),
|
||||
),
|
||||
ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()),
|
||||
ExprKind::Err => hir::ExprKind::Err(
|
||||
self.tcx.sess.span_delayed_bug(e.span, "lowered ExprKind::Err"),
|
||||
),
|
||||
ExprKind::Err => {
|
||||
hir::ExprKind::Err(self.dcx().span_delayed_bug(e.span, "lowered ExprKind::Err"))
|
||||
}
|
||||
ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr),
|
||||
|
||||
ExprKind::Paren(_) | ExprKind::ForLoop { .. } => {
|
||||
@ -584,13 +583,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
if self.tcx.features().never_patterns {
|
||||
// If the feature is off we already emitted the error after parsing.
|
||||
let suggestion = span.shrink_to_hi();
|
||||
self.tcx.sess.emit_err(MatchArmWithNoBody { span, suggestion });
|
||||
self.dcx().emit_err(MatchArmWithNoBody { span, suggestion });
|
||||
}
|
||||
} else if let Some(body) = &arm.body {
|
||||
self.tcx.sess.emit_err(NeverPatternWithBody { span: body.span });
|
||||
self.dcx().emit_err(NeverPatternWithBody { span: body.span });
|
||||
guard = None;
|
||||
} else if let Some(g) = &arm.guard {
|
||||
self.tcx.sess.emit_err(NeverPatternWithGuard { span: g.span });
|
||||
self.dcx().emit_err(NeverPatternWithGuard { span: g.span });
|
||||
guard = None;
|
||||
}
|
||||
|
||||
@ -902,7 +901,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
Some(hir::CoroutineKind::Coroutine)
|
||||
| Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _))
|
||||
| None => {
|
||||
return hir::ExprKind::Err(self.tcx.sess.emit_err(AwaitOnlyInAsyncFnAndBlocks {
|
||||
return hir::ExprKind::Err(self.dcx().emit_err(AwaitOnlyInAsyncFnAndBlocks {
|
||||
await_kw_span,
|
||||
item_span: self.current_item,
|
||||
}));
|
||||
@ -1129,7 +1128,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
match coroutine_kind {
|
||||
Some(hir::CoroutineKind::Coroutine) => {
|
||||
if decl.inputs.len() > 1 {
|
||||
self.tcx.sess.emit_err(CoroutineTooManyParameters { fn_decl_span });
|
||||
self.dcx().emit_err(CoroutineTooManyParameters { fn_decl_span });
|
||||
}
|
||||
Some(movability)
|
||||
}
|
||||
@ -1142,7 +1141,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
None => {
|
||||
if movability == Movability::Static {
|
||||
self.tcx.sess.emit_err(ClosureCannotBeStatic { fn_decl_span });
|
||||
self.dcx().emit_err(ClosureCannotBeStatic { fn_decl_span });
|
||||
}
|
||||
None
|
||||
}
|
||||
@ -1181,7 +1180,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
};
|
||||
|
||||
if let &ClosureBinder::For { span, .. } = binder {
|
||||
self.tcx.sess.emit_err(NotSupportedForLifetimeBinderAsyncClosure { span });
|
||||
self.dcx().emit_err(NotSupportedForLifetimeBinderAsyncClosure { span });
|
||||
}
|
||||
|
||||
let (binder_clause, generic_params) = self.lower_closure_binder(binder);
|
||||
@ -1192,7 +1191,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let body = self.with_new_scopes(fn_decl_span, |this| {
|
||||
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
|
||||
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
|
||||
this.tcx.sess.emit_err(AsyncNonMoveClosureNotSupported { fn_decl_span });
|
||||
this.dcx().emit_err(AsyncNonMoveClosureNotSupported { fn_decl_span });
|
||||
}
|
||||
|
||||
// Transform `async |x: u8| -> X { ... }` into
|
||||
@ -1448,7 +1447,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
);
|
||||
let fields_omitted = match &se.rest {
|
||||
StructRest::Base(e) => {
|
||||
self.tcx.sess.emit_err(FunctionalRecordUpdateDestructuringAssignment {
|
||||
self.dcx().emit_err(FunctionalRecordUpdateDestructuringAssignment {
|
||||
span: e.span,
|
||||
});
|
||||
true
|
||||
@ -1544,7 +1543,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
|
||||
(Some(..), Some(..), Closed) => unreachable!(),
|
||||
(start, None, Closed) => {
|
||||
self.tcx.sess.emit_err(InclusiveRangeWithNoEnd { span });
|
||||
self.dcx().emit_err(InclusiveRangeWithNoEnd { span });
|
||||
match start {
|
||||
Some(..) => hir::LangItem::RangeFrom,
|
||||
None => hir::LangItem::RangeFull,
|
||||
@ -1653,7 +1652,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _)) => true,
|
||||
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async, _)) => {
|
||||
return hir::ExprKind::Err(
|
||||
self.tcx.sess.emit_err(AsyncCoroutinesNotSupported { span }),
|
||||
self.dcx().emit_err(AsyncCoroutinesNotSupported { span }),
|
||||
);
|
||||
}
|
||||
Some(hir::CoroutineKind::Coroutine) | None => {
|
||||
|
@ -267,7 +267,7 @@ fn make_count<'hir>(
|
||||
ctx.expr(
|
||||
sp,
|
||||
hir::ExprKind::Err(
|
||||
ctx.tcx.sess.span_delayed_bug(sp, "lowered bad format_args count"),
|
||||
ctx.dcx().span_delayed_bug(sp, "lowered bad format_args count"),
|
||||
),
|
||||
)
|
||||
}
|
||||
@ -306,7 +306,7 @@ fn make_format_spec<'hir>(
|
||||
}
|
||||
Err(_) => ctx.expr(
|
||||
sp,
|
||||
hir::ExprKind::Err(ctx.tcx.sess.span_delayed_bug(sp, "lowered bad format_args count")),
|
||||
hir::ExprKind::Err(ctx.dcx().span_delayed_bug(sp, "lowered bad format_args count")),
|
||||
),
|
||||
};
|
||||
let &FormatOptions {
|
||||
|
@ -265,7 +265,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
||||
|this| match ty {
|
||||
None => {
|
||||
let guar = this.tcx.sess.span_delayed_bug(
|
||||
let guar = this.dcx().span_delayed_bug(
|
||||
span,
|
||||
"expected to lower type alias type, but it was missing",
|
||||
);
|
||||
@ -879,7 +879,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
|
||||
|this| match ty {
|
||||
None => {
|
||||
let guar = this.tcx.sess.span_delayed_bug(
|
||||
let guar = this.dcx().span_delayed_bug(
|
||||
i.span,
|
||||
"expected to lower associated type, but it was missing",
|
||||
);
|
||||
@ -1012,7 +1012,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Expr<'hir> {
|
||||
match block {
|
||||
Some(block) => self.lower_block_expr(block),
|
||||
None => self.expr_err(span, self.tcx.sess.span_delayed_bug(span, "no block")),
|
||||
None => self.expr_err(span, self.dcx().span_delayed_bug(span, "no block")),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1022,7 +1022,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
&[],
|
||||
match expr {
|
||||
Some(expr) => this.lower_expr_mut(expr),
|
||||
None => this.expr_err(span, this.tcx.sess.span_delayed_bug(span, "no block")),
|
||||
None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")),
|
||||
},
|
||||
)
|
||||
})
|
||||
@ -1296,7 +1296,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
.map(|s| Symbol::intern(s))
|
||||
.collect::<Vec<_>>();
|
||||
let suggested_name = find_best_match_for_name(&abi_names, abi.symbol_unescaped, None);
|
||||
self.tcx.sess.emit_err(InvalidAbi {
|
||||
self.dcx().emit_err(InvalidAbi {
|
||||
abi: abi.symbol_unescaped,
|
||||
span: abi.span,
|
||||
explain: match err {
|
||||
@ -1383,7 +1383,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
}
|
||||
let is_param = *is_param.get_or_insert_with(compute_is_param);
|
||||
if !is_param {
|
||||
self.tcx.sess.emit_err(MisplacedRelaxTraitBound { span: bound.span() });
|
||||
self.dcx().emit_err(MisplacedRelaxTraitBound { span: bound.span() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::sorted_map::SortedMap;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{DiagnosticArgFromDisplay, StashKey};
|
||||
use rustc_errors::{DiagCtxt, DiagnosticArgFromDisplay, StashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
|
||||
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
@ -183,6 +183,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
host_param_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn dcx(&self) -> &'hir DiagCtxt {
|
||||
self.tcx.dcx()
|
||||
}
|
||||
}
|
||||
|
||||
trait ResolverAstLoweringExt {
|
||||
@ -1035,11 +1039,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
&& first_char.is_ascii_lowercase()
|
||||
{
|
||||
let mut err = if !data.inputs.is_empty() {
|
||||
self.tcx.sess.create_err(errors::BadReturnTypeNotation::Inputs {
|
||||
self.dcx().create_err(errors::BadReturnTypeNotation::Inputs {
|
||||
span: data.inputs_span,
|
||||
})
|
||||
} else if let FnRetTy::Ty(ty) = &data.output {
|
||||
self.tcx.sess.create_err(errors::BadReturnTypeNotation::Output {
|
||||
self.dcx().create_err(errors::BadReturnTypeNotation::Output {
|
||||
span: data.inputs_span.shrink_to_hi().to(ty.span),
|
||||
})
|
||||
} else {
|
||||
@ -1163,7 +1167,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
hir::TypeBindingKind::Constraint { bounds }
|
||||
}
|
||||
DesugarKind::Error(position) => {
|
||||
let guar = self.tcx.sess.emit_err(errors::MisplacedAssocTyBinding {
|
||||
let guar = self.dcx().emit_err(errors::MisplacedAssocTyBinding {
|
||||
span: constraint.span,
|
||||
position: DiagnosticArgFromDisplay(position),
|
||||
});
|
||||
@ -1205,7 +1209,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
data.inputs.last().unwrap().span.shrink_to_hi().to(data.inputs_span.shrink_to_hi());
|
||||
AssocTyParenthesesSub::NotEmpty { open_param, close_param }
|
||||
};
|
||||
self.tcx.sess.emit_err(AssocTyParentheses { span: data.span, sub });
|
||||
self.dcx().emit_err(AssocTyParentheses { span: data.span, sub });
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
@ -1347,20 +1351,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
let kind = match &t.kind {
|
||||
TyKind::Infer => hir::TyKind::Infer,
|
||||
TyKind::Err => {
|
||||
hir::TyKind::Err(self.tcx.sess.span_delayed_bug(t.span, "TyKind::Err lowered"))
|
||||
hir::TyKind::Err(self.dcx().span_delayed_bug(t.span, "TyKind::Err lowered"))
|
||||
}
|
||||
// FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
TyKind::AnonStruct(ref _fields) => hir::TyKind::Err(
|
||||
self.tcx.sess.span_err(t.span, "anonymous structs are unimplemented"),
|
||||
),
|
||||
TyKind::AnonStruct(ref _fields) => {
|
||||
hir::TyKind::Err(self.dcx().span_err(t.span, "anonymous structs are unimplemented"))
|
||||
}
|
||||
// FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
TyKind::AnonUnion(ref _fields) => hir::TyKind::Err(
|
||||
self.tcx.sess.span_err(t.span, "anonymous unions are unimplemented"),
|
||||
),
|
||||
TyKind::AnonUnion(ref _fields) => {
|
||||
hir::TyKind::Err(self.dcx().span_err(t.span, "anonymous unions are unimplemented"))
|
||||
}
|
||||
TyKind::Slice(ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)),
|
||||
TyKind::Ptr(mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)),
|
||||
TyKind::Ref(region, mt) => {
|
||||
@ -1518,7 +1522,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
hir::TyKind::Err(guar)
|
||||
}
|
||||
ImplTraitContext::Disallowed(position) => {
|
||||
let guar = self.tcx.sess.emit_err(MisplacedImplTrait {
|
||||
let guar = self.dcx().emit_err(MisplacedImplTrait {
|
||||
span: t.span,
|
||||
position: DiagnosticArgFromDisplay(position),
|
||||
});
|
||||
@ -1528,7 +1532,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
|
||||
TyKind::CVarArgs => {
|
||||
let guar = self.tcx.sess.span_delayed_bug(
|
||||
let guar = self.dcx().span_delayed_bug(
|
||||
t.span,
|
||||
"`TyKind::CVarArgs` should have been handled elsewhere",
|
||||
);
|
||||
@ -1672,8 +1676,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
if let Some(old_def_id) = self.orig_opt_local_def_id(param) {
|
||||
old_def_id
|
||||
} else {
|
||||
self.tcx
|
||||
.sess
|
||||
self.dcx()
|
||||
.span_delayed_bug(lifetime.ident.span, "no def-id for fresh lifetime");
|
||||
continue;
|
||||
}
|
||||
@ -2569,7 +2572,7 @@ impl<'hir> GenericArgsCtor<'hir> {
|
||||
let hir_id = lcx.next_id();
|
||||
|
||||
let Some(host_param_id) = lcx.host_param_id else {
|
||||
lcx.tcx.sess.span_delayed_bug(
|
||||
lcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
"no host param id for call in const yet no errors reported",
|
||||
);
|
||||
|
@ -140,7 +140,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// This is not allowed as a sub-tuple pattern
|
||||
PatKind::Ident(_, ident, Some(sub)) if sub.is_rest() => {
|
||||
let sp = pat.span;
|
||||
self.tcx.sess.emit_err(SubTupleBinding {
|
||||
self.dcx().emit_err(SubTupleBinding {
|
||||
span: sp,
|
||||
ident_name: ident.name,
|
||||
ident: *ident,
|
||||
@ -289,12 +289,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
/// Emit a friendly error for extra `..` patterns in a tuple/tuple struct/slice pattern.
|
||||
pub(crate) fn ban_extra_rest_pat(&self, sp: Span, prev_sp: Span, ctx: &str) {
|
||||
self.tcx.sess.emit_err(ExtraDoubleDot { span: sp, prev_span: prev_sp, ctx });
|
||||
self.dcx().emit_err(ExtraDoubleDot { span: sp, prev_span: prev_sp, ctx });
|
||||
}
|
||||
|
||||
/// Used to ban the `..` pattern in places it shouldn't be semantically.
|
||||
fn ban_illegal_rest_pat(&self, sp: Span) -> hir::PatKind<'hir> {
|
||||
self.tcx.sess.emit_err(MisplacedDoubleDot { span: sp });
|
||||
self.dcx().emit_err(MisplacedDoubleDot { span: sp });
|
||||
|
||||
// We're not in a list context so `..` can be reasonably treated
|
||||
// as `_` because it should always be valid and roughly matches the
|
||||
@ -334,7 +334,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
ExprKind::Path(..) if allow_paths => {}
|
||||
ExprKind::Unary(UnOp::Neg, inner) if matches!(inner.kind, ExprKind::Lit(_)) => {}
|
||||
_ => {
|
||||
let guar = self.tcx.sess.emit_err(ArbitraryExpressionInPattern { span: expr.span });
|
||||
let guar = self.dcx().emit_err(ArbitraryExpressionInPattern { span: expr.span });
|
||||
return self.arena.alloc(self.expr_err(expr.span, guar));
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
|
||||
// We should've returned in the for loop above.
|
||||
|
||||
self.tcx.sess.dcx().span_bug(
|
||||
self.dcx().span_bug(
|
||||
p.span,
|
||||
format!(
|
||||
"lower_qpath: no final extension segment in {}..{}",
|
||||
@ -214,7 +214,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.tcx.sess.emit_err(GenericTypeWithParentheses { span: data.span, sub });
|
||||
self.dcx().emit_err(GenericTypeWithParentheses { span: data.span, sub });
|
||||
(
|
||||
self.lower_angle_bracketed_parameter_data(
|
||||
&data.as_angle_bracketed_args(),
|
||||
|
@ -228,13 +228,13 @@ impl<'a> AstValidator<'a> {
|
||||
fn check_lifetime(&self, ident: Ident) {
|
||||
let valid_names = [kw::UnderscoreLifetime, kw::StaticLifetime, kw::Empty];
|
||||
if !valid_names.contains(&ident.name) && ident.without_first_quote().is_reserved() {
|
||||
self.session.emit_err(errors::KeywordLifetime { span: ident.span });
|
||||
self.dcx().emit_err(errors::KeywordLifetime { span: ident.span });
|
||||
}
|
||||
}
|
||||
|
||||
fn check_label(&self, ident: Ident) {
|
||||
if ident.without_first_quote().is_reserved() {
|
||||
self.session.emit_err(errors::InvalidLabel { span: ident.span, name: ident.name });
|
||||
self.dcx().emit_err(errors::InvalidLabel { span: ident.span, name: ident.name });
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ impl<'a> AstValidator<'a> {
|
||||
return;
|
||||
}
|
||||
|
||||
self.session.emit_err(errors::VisibilityNotPermitted { span: vis.span, note });
|
||||
self.dcx().emit_err(errors::VisibilityNotPermitted { span: vis.span, note });
|
||||
}
|
||||
|
||||
fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) {
|
||||
@ -293,7 +293,7 @@ impl<'a> AstValidator<'a> {
|
||||
|
||||
fn check_trait_fn_not_const(&self, constness: Const) {
|
||||
if let Const::Yes(span) = constness {
|
||||
self.session.emit_err(errors::TraitFnConst { span });
|
||||
self.dcx().emit_err(errors::TraitFnConst { span });
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ impl<'a> AstValidator<'a> {
|
||||
let max_num_args: usize = u16::MAX.into();
|
||||
if fn_decl.inputs.len() > max_num_args {
|
||||
let Param { span, .. } = fn_decl.inputs[0];
|
||||
self.session.emit_fatal(errors::FnParamTooMany { span, max_num_args });
|
||||
self.dcx().emit_fatal(errors::FnParamTooMany { span, max_num_args });
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,13 +318,13 @@ impl<'a> AstValidator<'a> {
|
||||
match &*fn_decl.inputs {
|
||||
[Param { ty, span, .. }] => {
|
||||
if let TyKind::CVarArgs = ty.kind {
|
||||
self.session.emit_err(errors::FnParamCVarArgsOnly { span: *span });
|
||||
self.dcx().emit_err(errors::FnParamCVarArgsOnly { span: *span });
|
||||
}
|
||||
}
|
||||
[ps @ .., _] => {
|
||||
for Param { ty, span, .. } in ps {
|
||||
if let TyKind::CVarArgs = ty.kind {
|
||||
self.session.emit_err(errors::FnParamCVarArgsNotLast { span: *span });
|
||||
self.dcx().emit_err(errors::FnParamCVarArgsNotLast { span: *span });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -351,9 +351,9 @@ impl<'a> AstValidator<'a> {
|
||||
})
|
||||
.for_each(|attr| {
|
||||
if attr.is_doc_comment() {
|
||||
self.session.emit_err(errors::FnParamDocComment { span: attr.span });
|
||||
self.dcx().emit_err(errors::FnParamDocComment { span: attr.span });
|
||||
} else {
|
||||
self.session.emit_err(errors::FnParamForbiddenAttr { span: attr.span });
|
||||
self.dcx().emit_err(errors::FnParamForbiddenAttr { span: attr.span });
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -361,7 +361,7 @@ impl<'a> AstValidator<'a> {
|
||||
fn check_decl_self_param(&self, fn_decl: &FnDecl, self_semantic: SelfSemantic) {
|
||||
if let (SelfSemantic::No, [param, ..]) = (self_semantic, &*fn_decl.inputs) {
|
||||
if param.is_self() {
|
||||
self.session.emit_err(errors::FnParamForbiddenSelf { span: param.span });
|
||||
self.dcx().emit_err(errors::FnParamForbiddenSelf { span: param.span });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -369,7 +369,7 @@ impl<'a> AstValidator<'a> {
|
||||
fn check_defaultness(&self, span: Span, defaultness: Defaultness) {
|
||||
if let Defaultness::Default(def_span) = defaultness {
|
||||
let span = self.session.source_map().guess_head_span(span);
|
||||
self.session.emit_err(errors::ForbiddenDefault { span, def_span });
|
||||
self.dcx().emit_err(errors::ForbiddenDefault { span, def_span });
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,24 +532,24 @@ impl<'a> AstValidator<'a> {
|
||||
return;
|
||||
}
|
||||
let span = self.session.source_map().guess_head_span(item_span);
|
||||
self.session.emit_err(errors::NoMangleAscii { span });
|
||||
self.dcx().emit_err(errors::NoMangleAscii { span });
|
||||
}
|
||||
|
||||
fn check_mod_file_item_asciionly(&self, ident: Ident) {
|
||||
if ident.name.as_str().is_ascii() {
|
||||
return;
|
||||
}
|
||||
self.session.emit_err(errors::ModuleNonAscii { span: ident.span, name: ident.name });
|
||||
self.dcx().emit_err(errors::ModuleNonAscii { span: ident.span, name: ident.name });
|
||||
}
|
||||
|
||||
fn deny_generic_params(&self, generics: &Generics, ident: Span) {
|
||||
if !generics.params.is_empty() {
|
||||
self.session.emit_err(errors::AutoTraitGeneric { span: generics.span, ident });
|
||||
self.dcx().emit_err(errors::AutoTraitGeneric { span: generics.span, ident });
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_e0568(&self, span: Span, ident: Span) {
|
||||
self.session.emit_err(errors::AutoTraitBounds { span, ident });
|
||||
self.dcx().emit_err(errors::AutoTraitBounds { span, ident });
|
||||
}
|
||||
|
||||
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
|
||||
@ -569,7 +569,7 @@ impl<'a> AstValidator<'a> {
|
||||
if !trait_items.is_empty() {
|
||||
let spans: Vec<_> = trait_items.iter().map(|i| i.ident.span).collect();
|
||||
let total = trait_items.first().unwrap().span.to(trait_items.last().unwrap().span);
|
||||
self.session.emit_err(errors::AutoTraitItems { spans, total, ident });
|
||||
self.dcx().emit_err(errors::AutoTraitItems { spans, total, ident });
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@ impl<'a> AstValidator<'a> {
|
||||
TyKind::BareFn(bfty) => {
|
||||
self.check_fn_decl(&bfty.decl, SelfSemantic::No);
|
||||
Self::check_decl_no_pat(&bfty.decl, |span, _, _| {
|
||||
self.session.emit_err(errors::PatternFnPointer { span });
|
||||
self.dcx().emit_err(errors::PatternFnPointer { span });
|
||||
});
|
||||
if let Extern::Implicit(_) = bfty.ext {
|
||||
let sig_span = self.session.source_map().next_point(ty.span.shrink_to_lo());
|
||||
@ -645,7 +645,7 @@ impl<'a> AstValidator<'a> {
|
||||
for bound in bounds {
|
||||
if let GenericBound::Outlives(lifetime) = bound {
|
||||
if any_lifetime_bounds {
|
||||
self.session
|
||||
self.dcx()
|
||||
.emit_err(errors::TraitObjectBound { span: lifetime.ident.span });
|
||||
break;
|
||||
}
|
||||
@ -655,11 +655,11 @@ impl<'a> AstValidator<'a> {
|
||||
}
|
||||
TyKind::ImplTrait(_, bounds) => {
|
||||
if self.is_impl_trait_banned {
|
||||
self.session.emit_err(errors::ImplTraitPath { span: ty.span });
|
||||
self.dcx().emit_err(errors::ImplTraitPath { span: ty.span });
|
||||
}
|
||||
|
||||
if let Some(outer_impl_trait_sp) = self.outer_impl_trait {
|
||||
self.session.emit_err(errors::NestedImplTrait {
|
||||
self.dcx().emit_err(errors::NestedImplTrait {
|
||||
span: ty.span,
|
||||
outer: outer_impl_trait_sp,
|
||||
inner: ty.span,
|
||||
@ -827,7 +827,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
}
|
||||
if let (&Unsafe::Yes(span), &ImplPolarity::Negative(sp)) = (unsafety, polarity)
|
||||
{
|
||||
this.session.emit_err(errors::UnsafeNegativeImpl {
|
||||
this.dcx().emit_err(errors::UnsafeNegativeImpl {
|
||||
span: sp.to(t.path.span),
|
||||
negative: sp,
|
||||
r#unsafe: span,
|
||||
@ -902,7 +902,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
self.check_defaultness(item.span, *defaultness);
|
||||
|
||||
if body.is_none() {
|
||||
self.session.emit_err(errors::FnWithoutBody {
|
||||
self.dcx().emit_err(errors::FnWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
extern_block_suggestion: match sig.header.ext {
|
||||
@ -1031,14 +1031,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
ItemKind::Const(box ConstItem { defaultness, expr, .. }) => {
|
||||
self.check_defaultness(item.span, *defaultness);
|
||||
if expr.is_none() {
|
||||
self.session.emit_err(errors::ConstWithoutBody {
|
||||
self.dcx().emit_err(errors::ConstWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
});
|
||||
}
|
||||
}
|
||||
ItemKind::Static(box StaticItem { expr: None, .. }) => {
|
||||
self.session.emit_err(errors::StaticWithoutBody {
|
||||
self.dcx().emit_err(errors::StaticWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
});
|
||||
@ -1048,7 +1048,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
) => {
|
||||
self.check_defaultness(item.span, *defaultness);
|
||||
if ty.is_none() {
|
||||
self.session.emit_err(errors::TyAliasWithoutBody {
|
||||
self.dcx().emit_err(errors::TyAliasWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
});
|
||||
@ -1357,14 +1357,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
if ctxt == AssocCtxt::Impl {
|
||||
match &item.kind {
|
||||
AssocItemKind::Const(box ConstItem { expr: None, .. }) => {
|
||||
self.session.emit_err(errors::AssocConstWithoutBody {
|
||||
self.dcx().emit_err(errors::AssocConstWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
});
|
||||
}
|
||||
AssocItemKind::Fn(box Fn { body, .. }) => {
|
||||
if body.is_none() {
|
||||
self.session.emit_err(errors::AssocFnWithoutBody {
|
||||
self.dcx().emit_err(errors::AssocFnWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
});
|
||||
@ -1372,7 +1372,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
}
|
||||
AssocItemKind::Type(box TyAlias { bounds, ty, .. }) => {
|
||||
if ty.is_none() {
|
||||
self.session.emit_err(errors::AssocTypeWithoutBody {
|
||||
self.dcx().emit_err(errors::AssocTypeWithoutBody {
|
||||
span: item.span,
|
||||
replace_span: self.ending_semi_or_hi(item.span),
|
||||
});
|
||||
|
@ -168,7 +168,7 @@ impl<'a> PostExpansionVisitor<'a> {
|
||||
for param in params {
|
||||
if !param.bounds.is_empty() {
|
||||
let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect();
|
||||
self.sess.emit_err(errors::ForbiddenBound { spans });
|
||||
self.sess.dcx().emit_err(errors::ForbiddenBound { spans });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
|| attr.has_name(sym::rustc_const_stable)
|
||||
|| attr.has_name(sym::rustc_default_body_unstable)
|
||||
{
|
||||
self.sess.emit_err(errors::StabilityOutsideStd { span: attr.span });
|
||||
self.sess.dcx().emit_err(errors::StabilityOutsideStd { span: attr.span });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -579,7 +579,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
|
||||
.emit();
|
||||
} else {
|
||||
let suggestion = span.shrink_to_hi();
|
||||
sess.emit_err(errors::MatchArmWithNoBody { span, suggestion });
|
||||
sess.dcx().emit_err(errors::MatchArmWithNoBody { span, suggestion });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -587,7 +587,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
|
||||
|
||||
if !visitor.features.negative_bounds {
|
||||
for &span in spans.get(&sym::negative_bounds).iter().copied().flatten() {
|
||||
sess.emit_err(errors::NegativeBoundUnsupported { span });
|
||||
sess.dcx().emit_err(errors::NegativeBoundUnsupported { span });
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,7 +677,11 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
|
||||
if let Some((f2_name, f2_span)) = declared_features.clone().find(|(name, _)| name == f2)
|
||||
{
|
||||
let spans = vec![f1_span, f2_span];
|
||||
sess.emit_err(errors::IncompatibleFeatures { spans, f1: f1_name, f2: f2_name });
|
||||
sess.dcx().emit_err(errors::IncompatibleFeatures {
|
||||
spans,
|
||||
f1: f1_name,
|
||||
f2: f2_name,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,8 @@ pub fn find_stability(
|
||||
sym::rustc_allowed_through_unstable_modules => allowed_through_unstable_modules = true,
|
||||
sym::unstable => {
|
||||
if stab.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
sess.dcx()
|
||||
.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
break;
|
||||
}
|
||||
|
||||
@ -217,7 +218,8 @@ pub fn find_stability(
|
||||
}
|
||||
sym::stable => {
|
||||
if stab.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
sess.dcx()
|
||||
.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
break;
|
||||
}
|
||||
if let Some((feature, level)) = parse_stability(sess, attr) {
|
||||
@ -238,7 +240,8 @@ pub fn find_stability(
|
||||
_,
|
||||
)) => *allowed_through_unstable_modules = true,
|
||||
_ => {
|
||||
sess.emit_err(session_diagnostics::RustcAllowedUnstablePairing { span: item_sp });
|
||||
sess.dcx()
|
||||
.emit_err(session_diagnostics::RustcAllowedUnstablePairing { span: item_sp });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -261,7 +264,8 @@ pub fn find_const_stability(
|
||||
sym::rustc_promotable => promotable = true,
|
||||
sym::rustc_const_unstable => {
|
||||
if const_stab.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
sess.dcx()
|
||||
.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
break;
|
||||
}
|
||||
|
||||
@ -272,7 +276,8 @@ pub fn find_const_stability(
|
||||
}
|
||||
sym::rustc_const_stable => {
|
||||
if const_stab.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
sess.dcx()
|
||||
.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
break;
|
||||
}
|
||||
if let Some((feature, level)) = parse_stability(sess, attr) {
|
||||
@ -288,7 +293,11 @@ pub fn find_const_stability(
|
||||
if promotable {
|
||||
match &mut const_stab {
|
||||
Some((stab, _)) => stab.promotable = promotable,
|
||||
_ => _ = sess.emit_err(session_diagnostics::RustcPromotablePairing { span: item_sp }),
|
||||
_ => {
|
||||
_ = sess
|
||||
.dcx()
|
||||
.emit_err(session_diagnostics::RustcPromotablePairing { span: item_sp })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +315,8 @@ pub fn find_body_stability(
|
||||
for attr in attrs {
|
||||
if attr.has_name(sym::rustc_default_body_unstable) {
|
||||
if body_stab.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
sess.dcx()
|
||||
.emit_err(session_diagnostics::MultipleStabilityLevels { span: attr.span });
|
||||
break;
|
||||
}
|
||||
|
||||
@ -321,7 +331,7 @@ pub fn find_body_stability(
|
||||
|
||||
fn insert_or_error(sess: &Session, meta: &MetaItem, item: &mut Option<Symbol>) -> Option<()> {
|
||||
if item.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleItem {
|
||||
sess.dcx().emit_err(session_diagnostics::MultipleItem {
|
||||
span: meta.span,
|
||||
item: pprust::path_to_string(&meta.path),
|
||||
});
|
||||
@ -330,7 +340,7 @@ fn insert_or_error(sess: &Session, meta: &MetaItem, item: &mut Option<Symbol>) -
|
||||
*item = Some(v);
|
||||
Some(())
|
||||
} else {
|
||||
sess.emit_err(session_diagnostics::IncorrectMetaItem { span: meta.span });
|
||||
sess.dcx().emit_err(session_diagnostics::IncorrectMetaItem { span: meta.span });
|
||||
None
|
||||
}
|
||||
}
|
||||
@ -345,7 +355,7 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||
let mut since = None;
|
||||
for meta in metas {
|
||||
let Some(mi) = meta.meta_item() else {
|
||||
sess.emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
sess.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
span: meta.span(),
|
||||
reason: UnsupportedLiteralReason::Generic,
|
||||
is_bytestr: false,
|
||||
@ -358,7 +368,7 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||
sym::feature => insert_or_error(sess, mi, &mut feature)?,
|
||||
sym::since => insert_or_error(sess, mi, &mut since)?,
|
||||
_ => {
|
||||
sess.emit_err(session_diagnostics::UnknownMetaItem {
|
||||
sess.dcx().emit_err(session_diagnostics::UnknownMetaItem {
|
||||
span: meta.span(),
|
||||
item: pprust::path_to_string(&mi.path),
|
||||
expected: &["feature", "since"],
|
||||
@ -371,9 +381,9 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||
let feature = match feature {
|
||||
Some(feature) if rustc_lexer::is_ident(feature.as_str()) => Ok(feature),
|
||||
Some(_bad_feature) => {
|
||||
Err(sess.emit_err(session_diagnostics::NonIdentFeature { span: attr.span }))
|
||||
Err(sess.dcx().emit_err(session_diagnostics::NonIdentFeature { span: attr.span }))
|
||||
}
|
||||
None => Err(sess.emit_err(session_diagnostics::MissingFeature { span: attr.span })),
|
||||
None => Err(sess.dcx().emit_err(session_diagnostics::MissingFeature { span: attr.span })),
|
||||
};
|
||||
|
||||
let since = if let Some(since) = since {
|
||||
@ -382,11 +392,11 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||
} else if let Some(version) = parse_version(since) {
|
||||
StableSince::Version(version)
|
||||
} else {
|
||||
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
||||
StableSince::Err
|
||||
}
|
||||
} else {
|
||||
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
|
||||
sess.dcx().emit_err(session_diagnostics::MissingSince { span: attr.span });
|
||||
StableSince::Err
|
||||
};
|
||||
|
||||
@ -413,7 +423,7 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
|
||||
let mut implied_by = None;
|
||||
for meta in metas {
|
||||
let Some(mi) = meta.meta_item() else {
|
||||
sess.emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
sess.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
span: meta.span(),
|
||||
reason: UnsupportedLiteralReason::Generic,
|
||||
is_bytestr: false,
|
||||
@ -435,7 +445,7 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
|
||||
issue => match issue.parse::<NonZeroU32>() {
|
||||
Ok(num) => Some(num),
|
||||
Err(err) => {
|
||||
sess.emit_err(
|
||||
sess.dcx().emit_err(
|
||||
session_diagnostics::InvalidIssueString {
|
||||
span: mi.span,
|
||||
cause: session_diagnostics::InvalidIssueStringCause::from_int_error_kind(
|
||||
@ -451,13 +461,13 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
|
||||
}
|
||||
sym::soft => {
|
||||
if !mi.is_word() {
|
||||
sess.emit_err(session_diagnostics::SoftNoArgs { span: mi.span });
|
||||
sess.dcx().emit_err(session_diagnostics::SoftNoArgs { span: mi.span });
|
||||
}
|
||||
is_soft = true;
|
||||
}
|
||||
sym::implied_by => insert_or_error(sess, mi, &mut implied_by)?,
|
||||
_ => {
|
||||
sess.emit_err(session_diagnostics::UnknownMetaItem {
|
||||
sess.dcx().emit_err(session_diagnostics::UnknownMetaItem {
|
||||
span: meta.span(),
|
||||
item: pprust::path_to_string(&mi.path),
|
||||
expected: &["feature", "reason", "issue", "soft", "implied_by"],
|
||||
@ -470,13 +480,13 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
|
||||
let feature = match feature {
|
||||
Some(feature) if rustc_lexer::is_ident(feature.as_str()) => Ok(feature),
|
||||
Some(_bad_feature) => {
|
||||
Err(sess.emit_err(session_diagnostics::NonIdentFeature { span: attr.span }))
|
||||
Err(sess.dcx().emit_err(session_diagnostics::NonIdentFeature { span: attr.span }))
|
||||
}
|
||||
None => Err(sess.emit_err(session_diagnostics::MissingFeature { span: attr.span })),
|
||||
None => Err(sess.dcx().emit_err(session_diagnostics::MissingFeature { span: attr.span })),
|
||||
};
|
||||
|
||||
let issue =
|
||||
issue.ok_or_else(|| sess.emit_err(session_diagnostics::MissingIssue { span: attr.span }));
|
||||
let issue = issue
|
||||
.ok_or_else(|| sess.dcx().emit_err(session_diagnostics::MissingIssue { span: attr.span }));
|
||||
|
||||
match (feature, issue) {
|
||||
(Ok(feature), Ok(_)) => {
|
||||
@ -790,7 +800,7 @@ pub fn find_deprecation(
|
||||
MetaItemKind::List(list) => {
|
||||
let get = |meta: &MetaItem, item: &mut Option<Symbol>| {
|
||||
if item.is_some() {
|
||||
sess.emit_err(session_diagnostics::MultipleItem {
|
||||
sess.dcx().emit_err(session_diagnostics::MultipleItem {
|
||||
span: meta.span,
|
||||
item: pprust::path_to_string(&meta.path),
|
||||
});
|
||||
@ -801,14 +811,14 @@ pub fn find_deprecation(
|
||||
true
|
||||
} else {
|
||||
if let Some(lit) = meta.name_value_literal() {
|
||||
sess.emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
sess.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
span: lit.span,
|
||||
reason: UnsupportedLiteralReason::DeprecatedString,
|
||||
is_bytestr: lit.kind.is_bytestr(),
|
||||
start_point_span: sess.source_map().start_point(lit.span),
|
||||
});
|
||||
} else {
|
||||
sess.emit_err(session_diagnostics::IncorrectMetaItem {
|
||||
sess.dcx().emit_err(session_diagnostics::IncorrectMetaItem {
|
||||
span: meta.span,
|
||||
});
|
||||
}
|
||||
@ -832,11 +842,13 @@ pub fn find_deprecation(
|
||||
}
|
||||
sym::suggestion => {
|
||||
if !features.deprecated_suggestion {
|
||||
sess.emit_err(session_diagnostics::DeprecatedItemSuggestion {
|
||||
span: mi.span,
|
||||
is_nightly: sess.is_nightly_build().then_some(()),
|
||||
details: (),
|
||||
});
|
||||
sess.dcx().emit_err(
|
||||
session_diagnostics::DeprecatedItemSuggestion {
|
||||
span: mi.span,
|
||||
is_nightly: sess.is_nightly_build().then_some(()),
|
||||
details: (),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if !get(mi, &mut suggestion) {
|
||||
@ -844,7 +856,7 @@ pub fn find_deprecation(
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
sess.emit_err(session_diagnostics::UnknownMetaItem {
|
||||
sess.dcx().emit_err(session_diagnostics::UnknownMetaItem {
|
||||
span: meta.span(),
|
||||
item: pprust::path_to_string(&mi.path),
|
||||
expected: if features.deprecated_suggestion {
|
||||
@ -857,7 +869,7 @@ pub fn find_deprecation(
|
||||
}
|
||||
},
|
||||
NestedMetaItem::Lit(lit) => {
|
||||
sess.emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
sess.dcx().emit_err(session_diagnostics::UnsupportedLiteral {
|
||||
span: lit.span,
|
||||
reason: UnsupportedLiteralReason::DeprecatedKvPair,
|
||||
is_bytestr: false,
|
||||
@ -878,18 +890,18 @@ pub fn find_deprecation(
|
||||
} else if let Some(version) = parse_version(since) {
|
||||
DeprecatedSince::RustcVersion(version)
|
||||
} else {
|
||||
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidSince { span: attr.span });
|
||||
DeprecatedSince::Err
|
||||
}
|
||||
} else if is_rustc {
|
||||
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
|
||||
sess.dcx().emit_err(session_diagnostics::MissingSince { span: attr.span });
|
||||
DeprecatedSince::Err
|
||||
} else {
|
||||
DeprecatedSince::Unspecified
|
||||
};
|
||||
|
||||
if is_rustc && note.is_none() {
|
||||
sess.emit_err(session_diagnostics::MissingNote { span: attr.span });
|
||||
sess.dcx().emit_err(session_diagnostics::MissingNote { span: attr.span });
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -957,7 +969,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
sym::simd => Some(ReprSimd),
|
||||
sym::transparent => Some(ReprTransparent),
|
||||
sym::align => {
|
||||
sess.emit_err(session_diagnostics::InvalidReprAlignNeedArg {
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidReprAlignNeedArg {
|
||||
span: item.span(),
|
||||
});
|
||||
recognised = true;
|
||||
@ -988,13 +1000,13 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
|| int_type_of_word(name).is_some()
|
||||
{
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::InvalidReprHintNoParen {
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidReprHintNoParen {
|
||||
span: item.span(),
|
||||
name: name.to_ident_string(),
|
||||
});
|
||||
}
|
||||
if let Some(literal_error) = literal_error {
|
||||
sess.emit_err(session_diagnostics::InvalidReprGeneric {
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidReprGeneric {
|
||||
span: item.span(),
|
||||
repr_arg: name.to_ident_string(),
|
||||
error_part: literal_error,
|
||||
@ -1006,7 +1018,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
if meta_item.has_name(sym::align) || meta_item.has_name(sym::packed) {
|
||||
let name = meta_item.name_or_empty().to_ident_string();
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::IncorrectReprFormatGeneric {
|
||||
sess.dcx().emit_err(session_diagnostics::IncorrectReprFormatGeneric {
|
||||
span: item.span(),
|
||||
repr_arg: &name,
|
||||
cause: IncorrectReprFormatGenericCause::from_lit_kind(
|
||||
@ -1021,7 +1033,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
) || int_type_of_word(meta_item.name_or_empty()).is_some()
|
||||
{
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::InvalidReprHintNoValue {
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidReprHintNoValue {
|
||||
span: meta_item.span,
|
||||
name: meta_item.name_or_empty().to_ident_string(),
|
||||
});
|
||||
@ -1030,12 +1042,14 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
MetaItemKind::List(_) => {
|
||||
if meta_item.has_name(sym::align) {
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::IncorrectReprFormatAlignOneArg {
|
||||
span: meta_item.span,
|
||||
});
|
||||
sess.dcx().emit_err(
|
||||
session_diagnostics::IncorrectReprFormatAlignOneArg {
|
||||
span: meta_item.span,
|
||||
},
|
||||
);
|
||||
} else if meta_item.has_name(sym::packed) {
|
||||
recognised = true;
|
||||
sess.emit_err(
|
||||
sess.dcx().emit_err(
|
||||
session_diagnostics::IncorrectReprFormatPackedOneOrZeroArg {
|
||||
span: meta_item.span,
|
||||
},
|
||||
@ -1046,7 +1060,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
|
||||
) || int_type_of_word(meta_item.name_or_empty()).is_some()
|
||||
{
|
||||
recognised = true;
|
||||
sess.emit_err(session_diagnostics::InvalidReprHintNoParen {
|
||||
sess.dcx().emit_err(session_diagnostics::InvalidReprHintNoParen {
|
||||
span: meta_item.span,
|
||||
name: meta_item.name_or_empty().to_ident_string(),
|
||||
});
|
||||
@ -1148,7 +1162,7 @@ fn allow_unstable<'a>(
|
||||
let list = attrs
|
||||
.filter_map(move |attr| {
|
||||
attr.meta_item_list().or_else(|| {
|
||||
sess.emit_err(session_diagnostics::ExpectsFeatureList {
|
||||
sess.dcx().emit_err(session_diagnostics::ExpectsFeatureList {
|
||||
span: attr.span,
|
||||
name: symbol.to_ident_string(),
|
||||
});
|
||||
@ -1160,7 +1174,7 @@ fn allow_unstable<'a>(
|
||||
list.into_iter().filter_map(move |it| {
|
||||
let name = it.ident().map(|ident| ident.name);
|
||||
if name.is_none() {
|
||||
sess.emit_err(session_diagnostics::ExpectsFeatures {
|
||||
sess.dcx().emit_err(session_diagnostics::ExpectsFeatures {
|
||||
span: it.span(),
|
||||
name: symbol.to_ident_string(),
|
||||
});
|
||||
|
@ -1,10 +1,14 @@
|
||||
use rustc_errors::{
|
||||
struct_span_err, DiagnosticBuilder, DiagnosticId, DiagnosticMessage, MultiSpan,
|
||||
struct_span_err, DiagCtxt, DiagnosticBuilder, DiagnosticId, DiagnosticMessage, MultiSpan,
|
||||
};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
|
||||
impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
pub fn dcx(&self) -> &'tcx DiagCtxt {
|
||||
self.infcx.dcx()
|
||||
}
|
||||
|
||||
pub(crate) fn cannot_move_when_borrowed(
|
||||
&self,
|
||||
span: Span,
|
||||
@ -13,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
borrow_place: &str,
|
||||
value_place: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
self.infcx.tcx.sess.create_err(crate::session_diagnostics::MoveBorrow {
|
||||
self.dcx().create_err(crate::session_diagnostics::MoveBorrow {
|
||||
place,
|
||||
span,
|
||||
borrow_place,
|
||||
@ -30,7 +34,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
borrow_desc: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0503,
|
||||
"cannot use {} because it was mutably borrowed",
|
||||
@ -53,7 +57,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
new_loan_span,
|
||||
E0499,
|
||||
"cannot borrow {}{} as mutable more than once at a time",
|
||||
@ -99,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
old_load_end_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
new_loan_span,
|
||||
E0524,
|
||||
"two closures require unique access to {} at the same time",
|
||||
@ -132,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
previous_end_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
new_loan_span,
|
||||
E0500,
|
||||
"closure requires unique access to {} but {} is already borrowed{}",
|
||||
@ -164,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
second_borrow_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
new_loan_span,
|
||||
E0501,
|
||||
"cannot borrow {}{} as {} because previous closure requires unique access",
|
||||
@ -197,7 +201,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0502,
|
||||
"cannot borrow {}{} as {} because {} is also borrowed as {}{}",
|
||||
@ -237,7 +241,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
desc: &str,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0506,
|
||||
"cannot assign to {} because it is borrowed",
|
||||
@ -286,7 +290,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
_ => span_bug!(move_from_span, "this path should not cause illegal move"),
|
||||
};
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
move_from_span,
|
||||
E0508,
|
||||
"cannot move out of type `{}`, a non-copy {}",
|
||||
@ -303,7 +307,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
container_ty: Ty<'_>,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
move_from_span,
|
||||
E0509,
|
||||
"cannot move out of type `{}`, which implements the `Drop` trait",
|
||||
@ -323,7 +327,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default();
|
||||
|
||||
struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
use_span,
|
||||
E0382,
|
||||
"{} of {}moved value{}",
|
||||
@ -351,7 +355,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
action: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
mutate_span,
|
||||
E0510,
|
||||
"cannot {} {} in {}",
|
||||
@ -371,7 +375,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind;
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0626,
|
||||
"borrow may still be in use when {coroutine_kind:#} yields",
|
||||
@ -385,7 +389,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
borrow_span: Span,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
borrow_span,
|
||||
E0713,
|
||||
"borrow may still be in use when destructor runs",
|
||||
@ -408,7 +412,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
path_desc: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0515,
|
||||
"cannot {RETURN} {REFERENCE} {LOCAL}",
|
||||
@ -434,7 +438,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
scope: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
self.dcx(),
|
||||
closure_span,
|
||||
E0373,
|
||||
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
|
||||
@ -467,7 +471,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
|
||||
self.dcx().struct_span_err_with_code(sp, msg, code)
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,7 +481,7 @@ pub(crate) fn borrowed_data_escapes_closure<'tcx>(
|
||||
escapes_from: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
escape_span,
|
||||
E0521,
|
||||
"borrowed data escapes outside of {}",
|
||||
|
@ -77,7 +77,7 @@ impl<'tcx> UniverseInfo<'tcx> {
|
||||
// up in the existing UI tests. Consider investigating this
|
||||
// some more.
|
||||
mbcx.buffer_error(
|
||||
mbcx.infcx.tcx.sess.create_err(HigherRankedSubtypeError { span: cause.span }),
|
||||
mbcx.dcx().create_err(HigherRankedSubtypeError { span: cause.span }),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -221,7 +221,7 @@ struct PredicateQuery<'tcx> {
|
||||
|
||||
impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
|
||||
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
tcx.sess.create_err(HigherRankedLifetimeError {
|
||||
tcx.dcx().create_err(HigherRankedLifetimeError {
|
||||
cause: Some(HigherRankedErrorCause::CouldNotProve {
|
||||
predicate: self.canonical_query.value.value.predicate.to_string(),
|
||||
}),
|
||||
@ -258,7 +258,7 @@ where
|
||||
T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx,
|
||||
{
|
||||
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
tcx.sess.create_err(HigherRankedLifetimeError {
|
||||
tcx.dcx().create_err(HigherRankedLifetimeError {
|
||||
cause: Some(HigherRankedErrorCause::CouldNotNormalize {
|
||||
value: self.canonical_query.value.value.value.to_string(),
|
||||
}),
|
||||
@ -303,7 +303,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
|
||||
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
|
||||
// and is only the fallback when the nice error fails. Consider improving this some more.
|
||||
tcx.sess.create_err(HigherRankedLifetimeError { cause: None, span })
|
||||
tcx.dcx().create_err(HigherRankedLifetimeError { cause: None, span })
|
||||
}
|
||||
|
||||
fn base_universe(&self) -> ty::UniverseIndex {
|
||||
@ -329,7 +329,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
|
||||
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
|
||||
// and is only the fallback when the nice error fails. Consider improving this some more.
|
||||
tcx.sess.create_err(HigherRankedLifetimeError { cause: None, span })
|
||||
tcx.dcx().create_err(HigherRankedLifetimeError { cause: None, span })
|
||||
}
|
||||
|
||||
fn base_universe(&self) -> ty::UniverseIndex {
|
||||
|
@ -1136,7 +1136,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
});
|
||||
} else {
|
||||
issued_spans.var_subdiag(
|
||||
Some(self.infcx.tcx.sess.dcx()),
|
||||
Some(self.dcx()),
|
||||
&mut err,
|
||||
Some(issued_borrow.kind),
|
||||
|kind, var_span| {
|
||||
@ -1153,7 +1153,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
);
|
||||
|
||||
borrow_spans.var_subdiag(
|
||||
Some(self.infcx.tcx.sess.dcx()),
|
||||
Some(self.dcx()),
|
||||
&mut err,
|
||||
Some(gen_borrow_kind),
|
||||
|kind, var_span| {
|
||||
|
@ -124,7 +124,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let did = did.expect_local();
|
||||
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
|
||||
diag.eager_subdiagnostic(
|
||||
self.infcx.tcx.sess.dcx(),
|
||||
self.dcx(),
|
||||
OnClosureNote::InvokedTwice {
|
||||
place_name: &ty::place_to_string_for_capture(
|
||||
self.infcx.tcx,
|
||||
@ -146,7 +146,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let did = did.expect_local();
|
||||
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
|
||||
diag.eager_subdiagnostic(
|
||||
self.infcx.tcx.sess.dcx(),
|
||||
self.dcx(),
|
||||
OnClosureNote::MovedTwice {
|
||||
place_name: &ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
|
||||
span: *span,
|
||||
@ -1150,7 +1150,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&& self.infcx.can_eq(self.param_env, ty, self_ty)
|
||||
{
|
||||
err.eager_subdiagnostic(
|
||||
self.infcx.tcx.sess.dcx(),
|
||||
self.dcx(),
|
||||
CaptureReasonSuggest::FreshReborrow {
|
||||
span: move_span.shrink_to_hi(),
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ impl OutlivesSuggestionBuilder {
|
||||
// If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a
|
||||
// list of diagnostics.
|
||||
let mut diag = if suggested.len() == 1 {
|
||||
mbcx.infcx.tcx.sess.dcx().struct_help(match suggested.last().unwrap() {
|
||||
mbcx.dcx().struct_help(match suggested.last().unwrap() {
|
||||
SuggestedConstraint::Outlives(a, bs) => {
|
||||
let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect();
|
||||
format!("add bound `{a}: {}`", bs.join(" + "))
|
||||
@ -222,7 +222,6 @@ impl OutlivesSuggestionBuilder {
|
||||
let mut diag = mbcx
|
||||
.infcx
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_help("the following changes may resolve your lifetime errors");
|
||||
|
||||
|
@ -84,7 +84,7 @@ impl<'tcx> RegionErrors<'tcx> {
|
||||
#[track_caller]
|
||||
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
|
||||
let val = val.into();
|
||||
self.1.sess.span_delayed_bug(DUMMY_SP, format!("{val:?}"));
|
||||
self.1.sess.dcx().span_delayed_bug(DUMMY_SP, format!("{val:?}"));
|
||||
self.0.push(val);
|
||||
}
|
||||
pub fn is_empty(&self) -> bool {
|
||||
@ -327,11 +327,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
// to report it; we could probably handle it by
|
||||
// iterating over the universal regions and reporting
|
||||
// an error that multiple bounds are required.
|
||||
let mut diag =
|
||||
self.infcx.tcx.sess.create_err(GenericDoesNotLiveLongEnough {
|
||||
kind: type_test.generic_kind.to_string(),
|
||||
span: type_test_span,
|
||||
});
|
||||
let mut diag = self.dcx().create_err(GenericDoesNotLiveLongEnough {
|
||||
kind: type_test.generic_kind.to_string(),
|
||||
span: type_test_span,
|
||||
});
|
||||
|
||||
// Add notes and suggestions for the case of 'static lifetime
|
||||
// implied but not specified when a generic associated types
|
||||
@ -596,7 +595,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
},
|
||||
};
|
||||
|
||||
let mut diag = self.infcx.tcx.sess.create_err(err);
|
||||
let mut diag = self.dcx().create_err(err);
|
||||
|
||||
if let ReturnConstraint::ClosureUpvar(upvar_field) = kind {
|
||||
let def_id = match self.regioncx.universal_regions().defining_ty {
|
||||
@ -758,7 +757,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
let mir_def_name = self.infcx.tcx.def_descr(self.mir_def_id().to_def_id());
|
||||
|
||||
let err = LifetimeOutliveErr { span: *span };
|
||||
let mut diag = self.infcx.tcx.sess.create_err(err);
|
||||
let mut diag = self.dcx().create_err(err);
|
||||
|
||||
// In certain scenarios, such as the one described in issue #118021,
|
||||
// we might encounter a lifetime that cannot be named.
|
||||
|
@ -620,7 +620,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||
) => {
|
||||
// HIR lowering sometimes doesn't catch this in erroneous
|
||||
// programs, so we need to use span_delayed_bug here. See #82126.
|
||||
self.infcx.tcx.sess.span_delayed_bug(
|
||||
self.dcx().span_delayed_bug(
|
||||
hir_arg.span(),
|
||||
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
|
||||
);
|
||||
|
@ -2134,7 +2134,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
// 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
|
||||
// been emitted (#52262).
|
||||
self.infcx.tcx.sess.span_delayed_bug(
|
||||
self.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!(
|
||||
"Accessing `{place:?}` with the kind `{kind:?}` shouldn't be possible",
|
||||
@ -2428,7 +2428,7 @@ mod error {
|
||||
|
||||
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_>) {
|
||||
if let None = self.tainted_by_errors {
|
||||
self.tainted_by_errors = Some(self.tcx.sess.span_delayed_bug(
|
||||
self.tainted_by_errors = Some(self.tcx.dcx().span_delayed_bug(
|
||||
t.span.clone_ignoring_labels(),
|
||||
"diagnostic buffered but not emitted",
|
||||
))
|
||||
@ -2497,8 +2497,9 @@ mod error {
|
||||
if !self.errors.buffered.is_empty() {
|
||||
self.errors.buffered.sort_by_key(|diag| diag.sort_span);
|
||||
|
||||
let dcx = self.dcx();
|
||||
for diag in self.errors.buffered.drain(..) {
|
||||
self.infcx.tcx.sess.dcx().emit_diagnostic(diag);
|
||||
dcx.emit_diagnostic(diag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
||||
|
||||
if !nll_errors.is_empty() {
|
||||
// Suppress unhelpful extra errors in `infer_opaque_types`.
|
||||
infcx.set_tainted_by_errors(infcx.tcx.sess.span_delayed_bug(
|
||||
infcx.set_tainted_by_errors(infcx.dcx().span_delayed_bug(
|
||||
body.span,
|
||||
"`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 mut err = if let Some(closure_region_requirements) = closure_region_requirements {
|
||||
let mut err = tcx.sess.dcx().struct_span_note(def_span, "external requirements");
|
||||
let mut err = tcx.dcx().struct_span_note(def_span, "external requirements");
|
||||
|
||||
regioncx.annotate(tcx, &mut err);
|
||||
|
||||
@ -299,7 +299,7 @@ pub(super) fn dump_annotation<'tcx>(
|
||||
|
||||
err
|
||||
} else {
|
||||
let mut err = tcx.sess.dcx().struct_span_note(def_span, "no external requirements");
|
||||
let mut err = tcx.dcx().struct_span_note(def_span, "no external requirements");
|
||||
regioncx.annotate(tcx, &mut err);
|
||||
|
||||
err
|
||||
|
@ -402,7 +402,7 @@ fn check_opaque_type_parameter_valid(
|
||||
let opaque_param = opaque_generics.param_at(i, tcx);
|
||||
let kind = opaque_param.kind.descr();
|
||||
|
||||
return Err(tcx.sess.emit_err(NonGenericOpaqueTypeParam {
|
||||
return Err(tcx.dcx().emit_err(NonGenericOpaqueTypeParam {
|
||||
ty: arg,
|
||||
kind,
|
||||
span,
|
||||
@ -419,7 +419,7 @@ fn check_opaque_type_parameter_valid(
|
||||
.map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id))
|
||||
.collect();
|
||||
return Err(tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_span_err(span, "non-defining opaque type use in defining scope")
|
||||
.span_note(spans, format!("{descr} used multiple times"))
|
||||
.emit());
|
||||
|
@ -76,7 +76,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() {
|
||||
if argument_index + 1 >= body.local_decls.len() {
|
||||
self.tcx()
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(body.span, "found more normalized_input_ty than local_decls");
|
||||
break;
|
||||
}
|
||||
@ -104,7 +104,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
// 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.
|
||||
if body.yield_ty().is_some() != universal_regions.yield_ty.is_some() {
|
||||
self.tcx().sess.span_delayed_bug(
|
||||
self.tcx().dcx().span_delayed_bug(
|
||||
body.span,
|
||||
format!(
|
||||
"Expected body to have yield_ty ({:?}) iff we have a UR yield_ty ({:?})",
|
||||
|
@ -224,7 +224,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
||||
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
|
||||
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
|
||||
if hidden_type.has_non_region_infer() {
|
||||
let reported = infcx.tcx.sess.span_delayed_bug(
|
||||
let reported = infcx.dcx().span_delayed_bug(
|
||||
decl.hidden_type.span,
|
||||
format!("could not resolve {:#?}", hidden_type.ty.kind()),
|
||||
);
|
||||
@ -268,7 +268,7 @@ fn mirbug(tcx: TyCtxt<'_>, span: Span, msg: String) {
|
||||
// We sometimes see MIR failures (notably predicate failures) due to
|
||||
// the fact that we check rvalue sized predicates here. So use `span_delayed_bug`
|
||||
// to avoid reporting bugs in those cases.
|
||||
tcx.sess.dcx().span_delayed_bug(span, msg);
|
||||
tcx.dcx().span_delayed_bug(span, msg);
|
||||
}
|
||||
|
||||
enum FieldAccessError {
|
||||
@ -1067,7 +1067,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
);
|
||||
|
||||
if result.is_err() {
|
||||
self.infcx.tcx.sess.span_delayed_bug(
|
||||
self.infcx.dcx().span_delayed_bug(
|
||||
self.body.span,
|
||||
"failed re-defining predefined opaques in mir typeck",
|
||||
);
|
||||
@ -1573,7 +1573,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
sym::simd_shuffle => {
|
||||
if !matches!(args[2], Operand::Constant(_)) {
|
||||
self.tcx()
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_err(SimdShuffleLastConst { span: term.source_info.span });
|
||||
}
|
||||
}
|
||||
@ -1752,7 +1752,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
// While this is located in `nll::typeck` this error is not
|
||||
// an NLL error, it's a required check to prevent creation
|
||||
// of unsized rvalues in a call expression.
|
||||
self.tcx().sess.emit_err(MoveUnsized { ty, span });
|
||||
self.tcx().dcx().emit_err(MoveUnsized { ty, span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ fn report_bad_target(
|
||||
let bad_target =
|
||||
!matches!(item_kind, Some(ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..)));
|
||||
if bad_target {
|
||||
return Err(sess.emit_err(errors::BadDeriveTarget { span, item: item.span() }));
|
||||
return Err(sess.dcx().emit_err(errors::BadDeriveTarget { span, item: item.span() }));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -134,7 +134,7 @@ fn report_unexpected_meta_item_lit(sess: &Session, lit: &ast::MetaItemLit) {
|
||||
}
|
||||
_ => errors::BadDeriveLitHelp::Other,
|
||||
};
|
||||
sess.emit_err(errors::BadDeriveLit { span: lit.span, help });
|
||||
sess.dcx().emit_err(errors::BadDeriveLit { span: lit.span, help });
|
||||
}
|
||||
|
||||
fn report_path_args(sess: &Session, meta: &ast::MetaItem) {
|
||||
@ -143,10 +143,10 @@ fn report_path_args(sess: &Session, meta: &ast::MetaItem) {
|
||||
match meta.kind {
|
||||
MetaItemKind::Word => {}
|
||||
MetaItemKind::List(..) => {
|
||||
sess.emit_err(errors::DerivePathArgsList { span });
|
||||
sess.dcx().emit_err(errors::DerivePathArgsList { span });
|
||||
}
|
||||
MetaItemKind::NameValue(..) => {
|
||||
sess.emit_err(errors::DerivePathArgsValue { span });
|
||||
sess.dcx().emit_err(errors::DerivePathArgsValue { span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,12 +47,12 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
|
||||
}
|
||||
|
||||
Conv::X86Intr | Conv::RiscvInterrupt { .. } => {
|
||||
sess.fatal(format!("interrupt call conv {c:?} not yet implemented"))
|
||||
sess.dcx().fatal(format!("interrupt call conv {c:?} not yet implemented"))
|
||||
}
|
||||
|
||||
Conv::ArmAapcs => sess.fatal("aapcs call conv not yet implemented"),
|
||||
Conv::ArmAapcs => sess.dcx().fatal("aapcs call conv not yet implemented"),
|
||||
Conv::CCmseNonSecureCall => {
|
||||
sess.fatal("C-cmse-nonsecure-call call conv is not yet implemented");
|
||||
sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented");
|
||||
}
|
||||
|
||||
Conv::Msp430Intr
|
||||
@ -88,10 +88,10 @@ pub(crate) fn import_function<'tcx>(
|
||||
let sig = get_function_sig(tcx, module.target_config().default_call_conv, inst);
|
||||
match module.declare_function(name, Linkage::Import, &sig) {
|
||||
Ok(func_id) => func_id,
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{name}` as function, but it was already declared as static"
|
||||
)),
|
||||
Err(ModuleError::IncompatibleSignature(_, prev_sig, new_sig)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleSignature(_, prev_sig, new_sig)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{name}` with signature {new_sig:?}, \
|
||||
but it was already declared with signature {prev_sig:?}"
|
||||
)),
|
||||
@ -181,7 +181,7 @@ fn make_local_place<'tcx>(
|
||||
is_ssa: bool,
|
||||
) -> CPlace<'tcx> {
|
||||
if layout.is_unsized() {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.local_decls[local].source_info.span,
|
||||
"unsized locals are not yet supported",
|
||||
);
|
||||
@ -226,7 +226,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
|
||||
|
||||
// FIXME implement variadics in cranelift
|
||||
if fn_abi.c_variadic {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
"Defining variadic functions is not yet supported by Cranelift",
|
||||
);
|
||||
@ -543,7 +543,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
// FIXME find a cleaner way to support varargs
|
||||
if fn_sig.c_variadic() {
|
||||
if !matches!(fn_sig.abi(), Abi::C { .. }) {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
format!("Variadic call for non-C abi {:?}", fn_sig.abi()),
|
||||
);
|
||||
@ -555,7 +555,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
let ty = fx.bcx.func.dfg.value_type(arg);
|
||||
if !ty.is_int() {
|
||||
// FIXME set %al to upperbound on float args once floats are supported
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
format!("Non int ty {:?} for variadic call", ty),
|
||||
);
|
||||
|
@ -236,13 +236,13 @@ pub(crate) fn verify_func(
|
||||
match cranelift_codegen::verify_function(&func, &flags) {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
tcx.sess.err(format!("{:?}", err));
|
||||
tcx.dcx().err(format!("{:?}", err));
|
||||
let pretty_error = cranelift_codegen::print_errors::pretty_verifier_error(
|
||||
&func,
|
||||
Some(Box::new(writer)),
|
||||
err,
|
||||
);
|
||||
tcx.sess.fatal(format!("cranelift verify error:\n{}", pretty_error));
|
||||
tcx.dcx().fatal(format!("cranelift verify error:\n{}", pretty_error));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -450,7 +450,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
||||
unwind: _,
|
||||
} => {
|
||||
if options.contains(InlineAsmOptions::MAY_UNWIND) {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
"cranelift doesn't support unwinding from inline assembly.",
|
||||
);
|
||||
@ -812,7 +812,7 @@ fn codegen_stmt<'tcx>(
|
||||
| StatementKind::PlaceMention(..)
|
||||
| StatementKind::AscribeUserType(..) => {}
|
||||
|
||||
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),
|
||||
StatementKind::Coverage { .. } => fx.tcx.dcx().fatal("-Zcoverage is unimplemented"),
|
||||
StatementKind::Intrinsic(ref intrinsic) => match &**intrinsic {
|
||||
// We ignore `assume` intrinsics, they are only useful for optimizations
|
||||
NonDivergingIntrinsic::Assume(_) => {}
|
||||
|
@ -465,9 +465,12 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
|
||||
self.0.sess.span_fatal(span, err.to_string())
|
||||
self.0.sess.dcx().span_fatal(span, err.to_string())
|
||||
} else {
|
||||
self.0.sess.span_fatal(span, format!("failed to get layout for `{}`: {}", ty, err))
|
||||
self.0
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(span, format!("failed to get layout for `{}`: {}", ty, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -483,7 +486,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
fn_abi_request: FnAbiRequest<'tcx>,
|
||||
) -> ! {
|
||||
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
|
||||
self.0.sess.emit_fatal(Spanned { span, node: err })
|
||||
self.0.sess.dcx().emit_fatal(Spanned { span, node: err })
|
||||
} else {
|
||||
match fn_abi_request {
|
||||
FnAbiRequest::OfFnPtr { sig, extra_args } => {
|
||||
|
@ -263,7 +263,7 @@ fn data_id_for_static(
|
||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||
) {
|
||||
Ok(data_id) => data_id,
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{symbol_name}` as static, but it was already declared as function"
|
||||
)),
|
||||
Err(err) => Err::<_, _>(err).unwrap(),
|
||||
@ -311,7 +311,7 @@ fn data_id_for_static(
|
||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||
) {
|
||||
Ok(data_id) => data_id,
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{symbol_name}` as static, but it was already declared as function"
|
||||
)),
|
||||
Err(err) => Err::<_, _>(err).unwrap(),
|
||||
@ -360,7 +360,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
if let Some(names) = section_name.split_once(',') {
|
||||
names
|
||||
} else {
|
||||
tcx.sess.fatal(format!(
|
||||
tcx.dcx().fatal(format!(
|
||||
"#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma",
|
||||
section_name
|
||||
));
|
||||
@ -406,7 +406,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)
|
||||
{
|
||||
tcx.sess.fatal(format!(
|
||||
tcx.dcx().fatal(format!(
|
||||
"Allocation {:?} contains reference to TLS value {:?}",
|
||||
alloc_id, def_id
|
||||
));
|
||||
|
@ -69,7 +69,7 @@ impl OngoingCodegen {
|
||||
|
||||
let module_codegen_result = match module_codegen_result {
|
||||
Ok(module_codegen_result) => module_codegen_result,
|
||||
Err(err) => sess.fatal(err),
|
||||
Err(err) => sess.dcx().fatal(err),
|
||||
};
|
||||
let ModuleCodegenResult { module_regular, module_global_asm, existing_work_product } =
|
||||
module_codegen_result;
|
||||
@ -422,7 +422,7 @@ pub(crate) fn run_aot(
|
||||
backend_config.clone(),
|
||||
global_asm_config.clone(),
|
||||
cgu.name(),
|
||||
concurrency_limiter.acquire(tcx.sess.dcx()),
|
||||
concurrency_limiter.acquire(tcx.dcx()),
|
||||
),
|
||||
module_codegen,
|
||||
Some(rustc_middle::dep_graph::hash_result),
|
||||
@ -455,7 +455,7 @@ pub(crate) fn run_aot(
|
||||
"allocator_shim".to_owned(),
|
||||
) {
|
||||
Ok(allocator_module) => Some(allocator_module),
|
||||
Err(err) => tcx.sess.fatal(err),
|
||||
Err(err) => tcx.dcx().fatal(err),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
@ -478,7 +478,7 @@ pub(crate) fn run_aot(
|
||||
let obj = create_compressed_metadata_file(tcx.sess, &metadata, &symbol_name);
|
||||
|
||||
if let Err(err) = std::fs::write(&tmp_file, obj) {
|
||||
tcx.sess.fatal(format!("error writing metadata object file: {}", err));
|
||||
tcx.dcx().fatal(format!("error writing metadata object file: {}", err));
|
||||
}
|
||||
|
||||
(metadata_cgu_name, tmp_file)
|
||||
|
@ -94,11 +94,11 @@ fn create_jit_module(
|
||||
|
||||
pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
||||
if !tcx.sess.opts.output_types.should_codegen() {
|
||||
tcx.sess.fatal("JIT mode doesn't work with `cargo check`");
|
||||
tcx.dcx().fatal("JIT mode doesn't work with `cargo check`");
|
||||
}
|
||||
|
||||
if !tcx.crate_types().contains(&rustc_session::config::CrateType::Executable) {
|
||||
tcx.sess.fatal("can't jit non-executable crate");
|
||||
tcx.dcx().fatal("can't jit non-executable crate");
|
||||
}
|
||||
|
||||
let (mut jit_module, mut cx) = create_jit_module(
|
||||
@ -141,14 +141,14 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
||||
}
|
||||
MonoItem::GlobalAsm(item_id) => {
|
||||
let item = tcx.hir().item(item_id);
|
||||
tcx.sess.span_fatal(item.span, "Global asm is not supported in JIT mode");
|
||||
tcx.dcx().span_fatal(item.span, "Global asm is not supported in JIT mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if !cx.global_asm.is_empty() {
|
||||
tcx.sess.fatal("Inline asm is not supported in JIT mode");
|
||||
tcx.dcx().fatal("Inline asm is not supported in JIT mode");
|
||||
}
|
||||
|
||||
tcx.sess.abort_if_errors();
|
||||
|
@ -47,7 +47,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
|
||||
}
|
||||
InlineAsmOperand::SymFn { anon_const } => {
|
||||
if cfg!(not(feature = "inline_asm_sym")) {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
item.span,
|
||||
"asm! and global_asm! sym operands are not yet supported",
|
||||
);
|
||||
@ -65,7 +65,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
|
||||
}
|
||||
InlineAsmOperand::SymStatic { path: _, def_id } => {
|
||||
if cfg!(not(feature = "inline_asm_sym")) {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
item.span,
|
||||
"asm! and global_asm! sym operands are not yet supported",
|
||||
);
|
||||
|
@ -84,7 +84,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>(
|
||||
InlineAsmOperand::SymFn { ref value } => {
|
||||
if cfg!(not(feature = "inline_asm_sym")) {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_err(span, "asm! and global_asm! sym operands are not yet supported");
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
|
||||
}
|
||||
_ => self
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.fatal(format!("Unsupported binary format for inline asm: {binary_format:?}")),
|
||||
}
|
||||
|
||||
@ -563,7 +563,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
|
||||
BinaryFormat::Macho | BinaryFormat::Coff => {}
|
||||
_ => self
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.fatal(format!("Unsupported binary format for inline asm: {binary_format:?}")),
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
|
||||
|
||||
_ => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.warn(format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic));
|
||||
crate::trap::trap_unimplemented(fx, intrinsic);
|
||||
return;
|
||||
|
@ -309,7 +309,7 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
|
||||
}
|
||||
*/
|
||||
_ => {
|
||||
fx.tcx.sess.warn(format!(
|
||||
fx.tcx.dcx().warn(format!(
|
||||
"unsupported AArch64 llvm intrinsic {}; replacing with trap",
|
||||
intrinsic
|
||||
));
|
||||
|
@ -960,7 +960,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
|
||||
fx.tcx
|
||||
.dcx()
|
||||
.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
|
||||
};
|
||||
|
||||
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
|
||||
@ -1011,7 +1013,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
|
||||
fx.tcx
|
||||
.dcx()
|
||||
.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
|
||||
};
|
||||
|
||||
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
|
||||
@ -1056,7 +1060,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
"Index argument for `_mm_clmulepi64_si128` is not a constant",
|
||||
);
|
||||
@ -1093,7 +1097,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
"Index argument for `_mm_aeskeygenassist_si128` is not a constant",
|
||||
);
|
||||
@ -1361,7 +1365,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
|
||||
|
||||
_ => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.warn(format!("unsupported x86 llvm intrinsic {}; replacing with trap", intrinsic));
|
||||
crate::trap::trap_unimplemented(fx, intrinsic);
|
||||
return;
|
||||
|
@ -37,7 +37,7 @@ fn report_atomic_type_validation_error<'tcx>(
|
||||
span: Span,
|
||||
ty: Ty<'tcx>,
|
||||
) {
|
||||
fx.tcx.sess.span_err(
|
||||
fx.tcx.dcx().span_err(
|
||||
span,
|
||||
format!(
|
||||
"`{}` intrinsic: expected basic integer or raw pointer type, found `{:?}`",
|
||||
@ -785,7 +785,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
return;
|
||||
} else {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(source_info.span, "128bit atomics not yet supported");
|
||||
}
|
||||
}
|
||||
@ -816,7 +816,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
return;
|
||||
} else {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(source_info.span, "128bit atomics not yet supported");
|
||||
}
|
||||
}
|
||||
@ -1245,7 +1245,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
|
||||
// FIXME implement variadics in cranelift
|
||||
sym::va_copy | sym::va_arg | sym::va_end => {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
"Defining variadic functions is not yet supported by Cranelift",
|
||||
);
|
||||
@ -1253,7 +1253,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
|
||||
_ => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(source_info.span, format!("unsupported intrinsic {}", intrinsic));
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ fn report_simd_type_validation_error(
|
||||
span: Span,
|
||||
ty: Ty<'_>,
|
||||
) {
|
||||
fx.tcx.sess.span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty));
|
||||
fx.tcx.dcx().span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty));
|
||||
// Prevent verifier error
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
@ -192,7 +192,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
_ => {
|
||||
fx.tcx.sess.span_err(
|
||||
fx.tcx.dcx().span_err(
|
||||
span,
|
||||
format!("simd_shuffle index must be an array of `u32`, got `{}`", idx_ty),
|
||||
);
|
||||
@ -278,7 +278,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
{
|
||||
idx_const
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "Index argument for `simd_insert` is not a constant");
|
||||
fx.tcx.dcx().span_fatal(span, "Index argument for `simd_insert` is not a constant");
|
||||
};
|
||||
|
||||
let idx: u32 = idx_const
|
||||
@ -286,7 +286,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
.unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const));
|
||||
let (lane_count, _lane_ty) = base.layout().ty.simd_size_and_type(fx.tcx);
|
||||
if u64::from(idx) >= lane_count {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count),
|
||||
);
|
||||
@ -316,7 +316,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
{
|
||||
idx_const
|
||||
} else {
|
||||
fx.tcx.sess.span_warn(span, "Index argument for `simd_extract` is not a constant");
|
||||
fx.tcx.dcx().span_warn(span, "Index argument for `simd_extract` is not a constant");
|
||||
let trap_block = fx.bcx.create_block();
|
||||
let true_ = fx.bcx.ins().iconst(types::I8, 1);
|
||||
let ret_block = fx.get_block(target);
|
||||
@ -334,7 +334,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
.unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const));
|
||||
let (lane_count, _lane_ty) = v.layout().ty.simd_size_and_type(fx.tcx);
|
||||
if u64::from(idx) >= lane_count {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count),
|
||||
);
|
||||
@ -859,7 +859,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
match lane_ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {}
|
||||
_ => {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
format!(
|
||||
"invalid monomorphization of `simd_bitmask` intrinsic: \
|
||||
@ -899,7 +899,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
|
||||
== Some(expected_bytes) => {}
|
||||
_ => {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
format!(
|
||||
"invalid monomorphization of `simd_bitmask` intrinsic: \
|
||||
@ -1086,7 +1086,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
}
|
||||
|
||||
_ => {
|
||||
fx.tcx.sess.span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic));
|
||||
fx.tcx.dcx().span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic));
|
||||
// Prevent verifier error
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
return;
|
||||
|
@ -177,13 +177,15 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
use rustc_session::config::Lto;
|
||||
match sess.lto() {
|
||||
Lto::No | Lto::ThinLocal => {}
|
||||
Lto::Thin | Lto::Fat => sess.warn("LTO is not supported. You may get a linker error."),
|
||||
Lto::Thin | Lto::Fat => {
|
||||
sess.dcx().warn("LTO is not supported. You may get a linker error.")
|
||||
}
|
||||
}
|
||||
|
||||
let mut config = self.config.borrow_mut();
|
||||
if config.is_none() {
|
||||
let new_config = BackendConfig::from_opts(&sess.opts.cg.llvm_args)
|
||||
.unwrap_or_else(|err| sess.fatal(err));
|
||||
.unwrap_or_else(|err| sess.dcx().fatal(err));
|
||||
*config = Some(new_config);
|
||||
}
|
||||
}
|
||||
@ -211,7 +213,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
driver::jit::run_jit(tcx, config);
|
||||
|
||||
#[cfg(not(feature = "jit"))]
|
||||
tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift");
|
||||
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,7 +245,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
fn target_triple(sess: &Session) -> target_lexicon::Triple {
|
||||
match sess.target.llvm_target.parse() {
|
||||
Ok(triple) => triple,
|
||||
Err(err) => sess.fatal(format!("target not recognized: {}", err)),
|
||||
Err(err) => sess.dcx().fatal(format!("target not recognized: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,17 +312,18 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn isa::Tar
|
||||
Some(value) => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
|
||||
sess.fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
});
|
||||
if let Err(_) = builder.enable(value) {
|
||||
sess.fatal("the specified target cpu isn't currently supported by Cranelift.");
|
||||
sess.dcx()
|
||||
.fatal("the specified target cpu isn't currently supported by Cranelift.");
|
||||
}
|
||||
builder
|
||||
}
|
||||
None => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
|
||||
sess.fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
});
|
||||
if target_triple.architecture == target_lexicon::Architecture::X86_64 {
|
||||
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
|
||||
@ -333,7 +336,7 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn isa::Tar
|
||||
|
||||
match isa_builder.finish(flags) {
|
||||
Ok(target_isa) => target_isa,
|
||||
Err(err) => sess.fatal(format!("failed to build TargetIsa: {}", err)),
|
||||
Err(err) => sess.dcx().fatal(format!("failed to build TargetIsa: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
let cmain_func_id = match m.declare_function(entry_name, Linkage::Export, &cmain_sig) {
|
||||
Ok(func_id) => func_id,
|
||||
Err(err) => {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.fatal(format!("entry symbol `{entry_name}` declared multiple times: {err}"));
|
||||
}
|
||||
};
|
||||
@ -171,7 +171,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
}
|
||||
|
||||
if let Err(err) = m.define_function(cmain_func_id, &mut ctx) {
|
||||
tcx.sess.fatal(format!("entry symbol `{entry_name}` defined multiple times: {err}"));
|
||||
tcx.dcx().fatal(format!("entry symbol `{entry_name}` defined multiple times: {err}"));
|
||||
}
|
||||
|
||||
unwind_context.add_function(cmain_func_id, &ctx, m.isa());
|
||||
|
@ -397,7 +397,7 @@ impl<'tcx> CPlace<'tcx> {
|
||||
|
||||
if layout.size.bytes() >= u64::from(u32::MAX - 16) {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.fatal(format!("values of type {} are too big to store on the stack", layout.ty));
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ enum ConstraintOrRegister {
|
||||
impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) {
|
||||
if options.contains(InlineAsmOptions::MAY_UNWIND) {
|
||||
self.sess()
|
||||
self.sess().dcx()
|
||||
.create_err(UnwindingInlineAsm { span: span[0] })
|
||||
.emit();
|
||||
return;
|
||||
|
@ -80,7 +80,7 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
|
||||
let span = cx.tcx
|
||||
.get_attr(instance.def_id(), sym::target_feature)
|
||||
.map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span);
|
||||
cx.tcx.sess.create_err(TiedTargetFeatures {
|
||||
cx.tcx.dcx().create_err(TiedTargetFeatures {
|
||||
features: features.join(", "),
|
||||
span,
|
||||
})
|
||||
|
@ -24,7 +24,7 @@ fn set_global_alignment<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, gv: LValue<'gcc>
|
||||
match Align::from_bits(min) {
|
||||
Ok(min) => align = align.max(min),
|
||||
Err(err) => {
|
||||
cx.sess().emit_err(InvalidMinimumAlignment { err: err.to_string() });
|
||||
cx.sess().dcx().emit_err(InvalidMinimumAlignment { err: err.to_string() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -500,9 +500,9 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
|
||||
self.sess().emit_fatal(respan(span, err.into_diagnostic()))
|
||||
self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic()))
|
||||
} else {
|
||||
self.tcx.sess.emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
|
||||
self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -518,7 +518,7 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||
fn_abi_request: FnAbiRequest<'tcx>,
|
||||
) -> ! {
|
||||
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
|
||||
self.sess().emit_fatal(respan(span, err))
|
||||
self.tcx.dcx().emit_fatal(respan(span, err))
|
||||
} else {
|
||||
match fn_abi_request {
|
||||
FnAbiRequest::OfFnPtr { sig, extra_args } => {
|
||||
|
@ -52,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
|
||||
Some(c @ ('+' | '-')) => c,
|
||||
Some(_) => {
|
||||
if diagnostics {
|
||||
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
||||
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
||||
}
|
||||
return None;
|
||||
}
|
||||
@ -79,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
|
||||
else {
|
||||
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
|
||||
};
|
||||
sess.emit_warning(unknown_feature);
|
||||
sess.dcx().emit_warning(unknown_feature);
|
||||
}
|
||||
|
||||
if diagnostics {
|
||||
@ -114,7 +114,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
|
||||
|
||||
if diagnostics {
|
||||
if let Some(f) = check_tied_features(sess, &featsmap) {
|
||||
sess.emit_err(TargetFeatureDisableOrEnable {
|
||||
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
|
||||
features: f,
|
||||
span: None,
|
||||
missing_features: None,
|
||||
|
@ -262,7 +262,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||
_ => bug!(),
|
||||
},
|
||||
None => {
|
||||
tcx.sess.emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
|
||||
tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
||||
// macros for error handling:
|
||||
macro_rules! return_error {
|
||||
($err:expr) => {{
|
||||
bx.sess().emit_err($err);
|
||||
bx.tcx.dcx().emit_err($err);
|
||||
return Err(());
|
||||
}};
|
||||
}
|
||||
@ -390,7 +390,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
|
||||
) -> Result<RValue<'gcc>, ()> {
|
||||
macro_rules! return_error {
|
||||
($err:expr) => {{
|
||||
bx.sess().emit_err($err);
|
||||
bx.tcx.dcx().emit_err($err);
|
||||
return Err(());
|
||||
}};
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ impl CodegenBackend for GccCodegenBackend {
|
||||
#[cfg(feature="master")]
|
||||
gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
|
||||
if sess.lto() == Lto::Thin {
|
||||
sess.emit_warning(LTONotSupported {});
|
||||
sess.dcx().emit_warning(LTONotSupported {});
|
||||
}
|
||||
|
||||
#[cfg(not(feature="master"))]
|
||||
|
@ -82,7 +82,7 @@ pub fn sanitize_attrs<'ll>(
|
||||
let mte_feature =
|
||||
features.iter().map(|s| &s[..]).rfind(|n| ["+mte", "-mte"].contains(&&n[..]));
|
||||
if let None | Some("-mte") = mte_feature {
|
||||
cx.tcx.sess.emit_err(SanitizerMemtagRequiresMte);
|
||||
cx.tcx.dcx().emit_err(SanitizerMemtagRequiresMte);
|
||||
}
|
||||
|
||||
attrs.push(llvm::AttributeKind::SanitizeMemTag.create_attr(cx.llcx));
|
||||
@ -444,7 +444,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
|
||||
.next()
|
||||
.map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span);
|
||||
cx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.create_err(TargetFeatureDisableOrEnable {
|
||||
features: f,
|
||||
span: Some(span),
|
||||
|
@ -99,7 +99,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
|
||||
fn build(mut self: Box<Self>, output: &Path) -> bool {
|
||||
match self.build_with_llvm(output) {
|
||||
Ok(any_members) => any_members,
|
||||
Err(e) => self.sess.emit_fatal(ArchiveBuildFailure { error: e }),
|
||||
Err(e) => self.sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
||||
match std::fs::write(&def_file_path, def_file_content) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
sess.emit_fatal(ErrorWritingDEFFile { error: e });
|
||||
sess.dcx().emit_fatal(ErrorWritingDEFFile { error: e });
|
||||
}
|
||||
};
|
||||
|
||||
@ -217,14 +217,14 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
||||
|
||||
match dlltool_cmd.output() {
|
||||
Err(e) => {
|
||||
sess.emit_fatal(ErrorCallingDllTool {
|
||||
sess.dcx().emit_fatal(ErrorCallingDllTool {
|
||||
dlltool_path: dlltool.to_string_lossy(),
|
||||
error: e,
|
||||
});
|
||||
}
|
||||
// dlltool returns '0' on failure, so check for error output instead.
|
||||
Ok(output) if !output.stderr.is_empty() => {
|
||||
sess.emit_fatal(DlltoolFailImportLibrary {
|
||||
sess.dcx().emit_fatal(DlltoolFailImportLibrary {
|
||||
dlltool_path: dlltool.to_string_lossy(),
|
||||
dlltool_args: dlltool_cmd
|
||||
.get_args()
|
||||
@ -282,7 +282,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
|
||||
};
|
||||
|
||||
if result == crate::llvm::LLVMRustResult::Failure {
|
||||
sess.emit_fatal(ErrorCreatingImportLibrary {
|
||||
sess.dcx().emit_fatal(ErrorCreatingImportLibrary {
|
||||
lib_name,
|
||||
error: llvm::last_error().unwrap_or("unknown LLVM error".to_string()),
|
||||
});
|
||||
@ -354,7 +354,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
||||
let kind = kind
|
||||
.parse::<ArchiveKind>()
|
||||
.map_err(|_| kind)
|
||||
.unwrap_or_else(|kind| self.sess.emit_fatal(UnknownArchiveKind { kind }));
|
||||
.unwrap_or_else(|kind| self.sess.dcx().emit_fatal(UnknownArchiveKind { kind }));
|
||||
|
||||
let mut additions = mem::take(&mut self.additions);
|
||||
let mut strings = Vec::new();
|
||||
|
@ -126,7 +126,7 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMach
|
||||
tcx.backend_optimization_level(()),
|
||||
tcx.global_backend_features(()),
|
||||
)(config)
|
||||
.unwrap_or_else(|err| llvm_err(tcx.sess.dcx(), err).raise())
|
||||
.unwrap_or_else(|err| llvm_err(tcx.dcx(), err).raise())
|
||||
}
|
||||
|
||||
pub fn to_llvm_opt_settings(
|
||||
@ -245,12 +245,12 @@ pub fn target_machine_factory(
|
||||
match sess.opts.debuginfo_compression {
|
||||
rustc_session::config::DebugInfoCompression::Zlib => {
|
||||
if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } {
|
||||
sess.emit_warning(UnknownCompression { algorithm: "zlib" });
|
||||
sess.dcx().emit_warning(UnknownCompression { algorithm: "zlib" });
|
||||
}
|
||||
}
|
||||
rustc_session::config::DebugInfoCompression::Zstd => {
|
||||
if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } {
|
||||
sess.emit_warning(UnknownCompression { algorithm: "zstd" });
|
||||
sess.dcx().emit_warning(UnknownCompression { algorithm: "zstd" });
|
||||
}
|
||||
}
|
||||
rustc_session::config::DebugInfoCompression::None => {}
|
||||
|
@ -131,10 +131,10 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
|
||||
Ok(min) => align = align.max(min),
|
||||
Err(err) => match err {
|
||||
AlignFromBytesError::NotPowerOfTwo(align) => {
|
||||
cx.sess().emit_err(InvalidMinimumAlignmentNotPowerOfTwo { align });
|
||||
cx.sess().dcx().emit_err(InvalidMinimumAlignmentNotPowerOfTwo { align });
|
||||
}
|
||||
AlignFromBytesError::TooLarge(align) => {
|
||||
cx.sess().emit_err(InvalidMinimumAlignmentTooLarge { align });
|
||||
cx.sess().dcx().emit_err(InvalidMinimumAlignmentTooLarge { align });
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -169,7 +169,7 @@ fn check_and_apply_linkage<'ll, 'tcx>(
|
||||
let mut real_name = "_rust_extern_with_linkage_".to_string();
|
||||
real_name.push_str(sym);
|
||||
let g2 = cx.define_global(&real_name, llty).unwrap_or_else(|| {
|
||||
cx.sess().emit_fatal(SymbolAlreadyDefined {
|
||||
cx.sess().dcx().emit_fatal(SymbolAlreadyDefined {
|
||||
span: cx.tcx.def_span(def_id),
|
||||
symbol_name: sym,
|
||||
})
|
||||
|
@ -1014,9 +1014,9 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
|
||||
self.sess().emit_fatal(Spanned { span, node: err.into_diagnostic() })
|
||||
self.tcx.dcx().emit_fatal(Spanned { span, node: err.into_diagnostic() })
|
||||
} else {
|
||||
self.tcx.sess.emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
|
||||
self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1032,7 +1032,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
|
||||
fn_abi_request: FnAbiRequest<'tcx>,
|
||||
) -> ! {
|
||||
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
|
||||
self.sess().emit_fatal(Spanned { span, node: err })
|
||||
self.tcx.dcx().emit_fatal(Spanned { span, node: err })
|
||||
} else {
|
||||
match fn_abi_request {
|
||||
FnAbiRequest::OfFnPtr { sig, extra_args } => {
|
||||
|
@ -285,7 +285,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
||||
_ => bug!(),
|
||||
},
|
||||
None => {
|
||||
tcx.sess.emit_err(InvalidMonomorphization::BasicIntegerType {
|
||||
tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
|
||||
span,
|
||||
name,
|
||||
ty,
|
||||
@ -921,7 +921,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
||||
) -> Result<&'ll Value, ()> {
|
||||
macro_rules! return_error {
|
||||
($diag: expr) => {{
|
||||
bx.sess().emit_err($diag);
|
||||
bx.sess().dcx().emit_err($diag);
|
||||
return Err(());
|
||||
}};
|
||||
}
|
||||
@ -1059,7 +1059,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
||||
.map(|(arg_idx, val)| {
|
||||
let idx = val.unwrap_leaf().try_to_i32().unwrap();
|
||||
if idx >= i32::try_from(total_len).unwrap() {
|
||||
bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds {
|
||||
bx.sess().dcx().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds {
|
||||
span,
|
||||
name,
|
||||
arg_idx: arg_idx as u64,
|
||||
@ -1118,20 +1118,24 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
||||
let val = bx.const_get_elt(vector, i as u64);
|
||||
match bx.const_to_opt_u128(val, true) {
|
||||
None => {
|
||||
bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexNotConstant {
|
||||
span,
|
||||
name,
|
||||
arg_idx,
|
||||
});
|
||||
bx.sess().dcx().emit_err(
|
||||
InvalidMonomorphization::ShuffleIndexNotConstant {
|
||||
span,
|
||||
name,
|
||||
arg_idx,
|
||||
},
|
||||
);
|
||||
None
|
||||
}
|
||||
Some(idx) if idx >= total_len => {
|
||||
bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds {
|
||||
span,
|
||||
name,
|
||||
arg_idx,
|
||||
total_len,
|
||||
});
|
||||
bx.sess().dcx().emit_err(
|
||||
InvalidMonomorphization::ShuffleIndexOutOfBounds {
|
||||
span,
|
||||
name,
|
||||
arg_idx,
|
||||
total_len,
|
||||
},
|
||||
);
|
||||
None
|
||||
}
|
||||
Some(idx) => Some(bx.const_i32(idx as i32)),
|
||||
@ -1276,7 +1280,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
||||
) -> Result<&'ll Value, ()> {
|
||||
macro_rules! return_error {
|
||||
($diag: expr) => {{
|
||||
bx.sess().emit_err($diag);
|
||||
bx.sess().dcx().emit_err($diag);
|
||||
return Err(());
|
||||
}};
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
||||
Some(c @ ('+' | '-')) => c,
|
||||
Some(_) => {
|
||||
if diagnostics {
|
||||
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
||||
sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
|
||||
}
|
||||
return None;
|
||||
}
|
||||
@ -557,12 +557,12 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
||||
} else {
|
||||
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
|
||||
};
|
||||
sess.emit_warning(unknown_feature);
|
||||
sess.dcx().emit_warning(unknown_feature);
|
||||
} else if feature_state
|
||||
.is_some_and(|(_name, feature_gate)| !feature_gate.is_stable())
|
||||
{
|
||||
// An unstable feature. Warn about using it.
|
||||
sess.emit_warning(UnstableCTargetFeature { feature });
|
||||
sess.dcx().emit_warning(UnstableCTargetFeature { feature });
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,7 +598,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
|
||||
features.extend(feats);
|
||||
|
||||
if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) {
|
||||
sess.emit_err(TargetFeatureDisableOrEnable {
|
||||
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
|
||||
features: f,
|
||||
span: None,
|
||||
missing_features: None,
|
||||
|
@ -26,6 +26,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> {
|
||||
|
||||
let g = self.define_global(symbol_name, llty).unwrap_or_else(|| {
|
||||
self.sess()
|
||||
.dcx()
|
||||
.emit_fatal(SymbolAlreadyDefined { span: self.tcx.def_span(def_id), symbol_name })
|
||||
});
|
||||
|
||||
|
@ -88,7 +88,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
||||
sym::any => (CguReuse::PreLto, ComparisonKind::AtLeast),
|
||||
other => {
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_fatal(errors::UnknownReuseKind { span: attr.span, kind: other });
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
||||
};
|
||||
|
||||
if !self.tcx.sess.opts.unstable_opts.query_dep_graph {
|
||||
self.tcx.sess.emit_fatal(errors::MissingQueryDepGraph { span: attr.span });
|
||||
self.tcx.dcx().emit_fatal(errors::MissingQueryDepGraph { span: attr.span });
|
||||
}
|
||||
|
||||
if !self.check_config(attr) {
|
||||
@ -109,7 +109,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
||||
let crate_name = self.tcx.crate_name(LOCAL_CRATE).to_string();
|
||||
|
||||
if !user_path.starts_with(&crate_name) {
|
||||
self.tcx.sess.emit_fatal(errors::MalformedCguName {
|
||||
self.tcx.dcx().emit_fatal(errors::MalformedCguName {
|
||||
span: attr.span,
|
||||
user_path,
|
||||
crate_name,
|
||||
@ -139,7 +139,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
||||
if !self.available_cgus.contains(&cgu_name) {
|
||||
let cgu_names: Vec<&str> =
|
||||
self.available_cgus.items().map(|cgu| cgu.as_str()).into_sorted_stable_ord();
|
||||
self.tcx.sess.emit_err(errors::NoModuleNamed {
|
||||
self.tcx.dcx().emit_err(errors::NoModuleNamed {
|
||||
span: attr.span,
|
||||
user_path,
|
||||
cgu_name,
|
||||
@ -162,7 +162,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
||||
if let Some(value) = item.value_str() {
|
||||
return value;
|
||||
} else {
|
||||
self.tcx.sess.emit_fatal(errors::FieldAssociatedValueExpected {
|
||||
self.tcx.dcx().emit_fatal(errors::FieldAssociatedValueExpected {
|
||||
span: item.span(),
|
||||
name,
|
||||
});
|
||||
@ -170,7 +170,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.emit_fatal(errors::NoField { span: attr.span, name });
|
||||
self.tcx.dcx().emit_fatal(errors::NoField { span: attr.span, name });
|
||||
}
|
||||
|
||||
/// Scan for a `cfg="foo"` attribute and check whether we have a
|
||||
@ -278,7 +278,7 @@ impl CguReuseTracker {
|
||||
|
||||
if error {
|
||||
let at_least = if at_least { 1 } else { 0 };
|
||||
sess.emit_err(errors::IncorrectCguReuseType {
|
||||
sess.dcx().emit_err(errors::IncorrectCguReuseType {
|
||||
span: *error_span,
|
||||
cgu_user_name,
|
||||
actual_reuse,
|
||||
@ -287,7 +287,7 @@ impl CguReuseTracker {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
sess.emit_fatal(errors::CguNotRecorded { cgu_user_name, cgu_name });
|
||||
sess.dcx().emit_fatal(errors::CguNotRecorded { cgu_user_name, cgu_name });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||
let sess = self.sess;
|
||||
match self.build_inner(output) {
|
||||
Ok(any_members) => any_members,
|
||||
Err(e) => sess.emit_fatal(ArchiveBuildFailure { error: e }),
|
||||
Err(e) => sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ impl<'a> ArArchiveBuilder<'a> {
|
||||
"coff" => ArchiveKind::Coff,
|
||||
"aix_big" => ArchiveKind::AixBig,
|
||||
kind => {
|
||||
self.sess.emit_fatal(UnknownArchiveKind { kind });
|
||||
self.sess.dcx().emit_fatal(UnknownArchiveKind { kind });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -98,7 +98,7 @@ pub fn link_binary<'a>(
|
||||
let tmpdir = TempFileBuilder::new()
|
||||
.prefix("rustc")
|
||||
.tempdir()
|
||||
.unwrap_or_else(|error| sess.emit_fatal(errors::CreateTempDir { error }));
|
||||
.unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error }));
|
||||
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps);
|
||||
let output = out_filename(
|
||||
sess,
|
||||
@ -161,11 +161,11 @@ pub fn link_binary<'a>(
|
||||
|
||||
if output.is_stdout() {
|
||||
if output.is_tty() {
|
||||
sess.emit_err(errors::BinaryOutputToTty {
|
||||
sess.dcx().emit_err(errors::BinaryOutputToTty {
|
||||
shorthand: OutputType::Exe.shorthand(),
|
||||
});
|
||||
} else if let Err(e) = copy_to_stdout(&out_filename) {
|
||||
sess.emit_err(errors::CopyPath::new(&out_filename, output.as_path(), e));
|
||||
sess.dcx().emit_err(errors::CopyPath::new(&out_filename, output.as_path(), e));
|
||||
}
|
||||
tempfiles_for_stdout_output.push(out_filename);
|
||||
}
|
||||
@ -380,8 +380,8 @@ fn link_rlib<'a>(
|
||||
&& let Some(filename) = lib.filename
|
||||
{
|
||||
let path = find_native_static_library(filename.as_str(), true, &lib_search_paths, sess);
|
||||
let src =
|
||||
read(path).map_err(|e| sess.emit_fatal(errors::ReadFileError { message: e }))?;
|
||||
let src = read(path)
|
||||
.map_err(|e| sess.dcx().emit_fatal(errors::ReadFileError { message: e }))?;
|
||||
let (data, _) = create_wrapper_file(sess, b".bundled_lib".to_vec(), &src);
|
||||
let wrapper_file = emit_wrapper_file(sess, &data, tmpdir, filename.as_str());
|
||||
packed_bundled_libs.push(wrapper_file);
|
||||
@ -393,7 +393,7 @@ fn link_rlib<'a>(
|
||||
sess,
|
||||
);
|
||||
ab.add_archive(&path, Box::new(|_| false)).unwrap_or_else(|error| {
|
||||
sess.emit_fatal(errors::AddNativeLibrary { library_path: path, error })
|
||||
sess.dcx().emit_fatal(errors::AddNativeLibrary { library_path: path, error })
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -410,7 +410,7 @@ fn link_rlib<'a>(
|
||||
);
|
||||
|
||||
ab.add_archive(&output_path, Box::new(|_| false)).unwrap_or_else(|error| {
|
||||
sess.emit_fatal(errors::AddNativeLibrary { library_path: output_path, error });
|
||||
sess.dcx().emit_fatal(errors::AddNativeLibrary { library_path: output_path, error });
|
||||
});
|
||||
}
|
||||
|
||||
@ -475,7 +475,7 @@ fn collate_raw_dylibs<'a, 'b>(
|
||||
// FIXME: when we add support for ordinals, figure out if we need to do anything
|
||||
// if we have two DllImport values with the same name but different ordinals.
|
||||
if import.calling_convention != old_import.calling_convention {
|
||||
sess.emit_err(errors::MultipleExternalFuncDecl {
|
||||
sess.dcx().emit_err(errors::MultipleExternalFuncDecl {
|
||||
span: import.span,
|
||||
function: import.name,
|
||||
library_name: &name,
|
||||
@ -558,7 +558,7 @@ fn link_staticlib<'a>(
|
||||
|
||||
archive_builder_builder
|
||||
.extract_bundled_libs(path, tempdir.as_ref(), &relevant_libs)
|
||||
.unwrap_or_else(|e| sess.emit_fatal(e));
|
||||
.unwrap_or_else(|e| sess.dcx().emit_fatal(e));
|
||||
for filename in relevant_libs {
|
||||
let joined = tempdir.as_ref().join(filename.as_str());
|
||||
let path = joined.as_path();
|
||||
@ -570,7 +570,7 @@ fn link_staticlib<'a>(
|
||||
},
|
||||
);
|
||||
if let Err(e) = res {
|
||||
sess.emit_fatal(e);
|
||||
sess.dcx().emit_fatal(e);
|
||||
}
|
||||
|
||||
ab.build(out_filename);
|
||||
@ -596,9 +596,9 @@ fn link_staticlib<'a>(
|
||||
all_rust_dylibs.push(&**path);
|
||||
} else {
|
||||
if used_crate_source.rmeta.is_some() {
|
||||
sess.emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
|
||||
} else {
|
||||
sess.emit_fatal(errors::LinkRlibError::NotFound { crate_name });
|
||||
sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -715,7 +715,7 @@ fn link_dwarf_object<'a>(
|
||||
}) {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
sess.emit_err(errors::ThorinErrorWrapper(e));
|
||||
sess.dcx().emit_err(errors::ThorinErrorWrapper(e));
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
}
|
||||
@ -955,17 +955,17 @@ fn link_natively<'a>(
|
||||
)
|
||||
.is_some();
|
||||
|
||||
sess.emit_note(errors::LinkExeUnexpectedError);
|
||||
sess.dcx().emit_note(errors::LinkExeUnexpectedError);
|
||||
if is_vs_installed && has_linker {
|
||||
// the linker is broken
|
||||
sess.emit_note(errors::RepairVSBuildTools);
|
||||
sess.emit_note(errors::MissingCppBuildToolComponent);
|
||||
sess.dcx().emit_note(errors::RepairVSBuildTools);
|
||||
sess.dcx().emit_note(errors::MissingCppBuildToolComponent);
|
||||
} else if is_vs_installed {
|
||||
// the linker is not installed
|
||||
sess.emit_note(errors::SelectCppBuildToolWorkload);
|
||||
sess.dcx().emit_note(errors::SelectCppBuildToolWorkload);
|
||||
} else {
|
||||
// visual studio is not installed
|
||||
sess.emit_note(errors::VisualStudioNotInstalled);
|
||||
sess.dcx().emit_note(errors::VisualStudioNotInstalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -979,9 +979,9 @@ fn link_natively<'a>(
|
||||
let linker_not_found = e.kind() == io::ErrorKind::NotFound;
|
||||
|
||||
if linker_not_found {
|
||||
sess.emit_err(errors::LinkerNotFound { linker_path, error: e });
|
||||
sess.dcx().emit_err(errors::LinkerNotFound { linker_path, error: e });
|
||||
} else {
|
||||
sess.emit_err(errors::UnableToExeLinker {
|
||||
sess.dcx().emit_err(errors::UnableToExeLinker {
|
||||
linker_path,
|
||||
error: e,
|
||||
command_formatted: format!("{:?}", &cmd),
|
||||
@ -989,9 +989,9 @@ fn link_natively<'a>(
|
||||
}
|
||||
|
||||
if sess.target.is_like_msvc && linker_not_found {
|
||||
sess.emit_note(errors::MsvcMissingLinker);
|
||||
sess.emit_note(errors::CheckInstalledVisualStudio);
|
||||
sess.emit_note(errors::InsufficientVSCodeProduct);
|
||||
sess.dcx().emit_note(errors::MsvcMissingLinker);
|
||||
sess.dcx().emit_note(errors::CheckInstalledVisualStudio);
|
||||
sess.dcx().emit_note(errors::InsufficientVSCodeProduct);
|
||||
}
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
@ -1016,13 +1016,13 @@ fn link_natively<'a>(
|
||||
if !prog.status.success() {
|
||||
let mut output = prog.stderr.clone();
|
||||
output.extend_from_slice(&prog.stdout);
|
||||
sess.emit_warning(errors::ProcessingDymutilFailed {
|
||||
sess.dcx().emit_warning(errors::ProcessingDymutilFailed {
|
||||
status: prog.status,
|
||||
output: escape_string(&output),
|
||||
});
|
||||
}
|
||||
}
|
||||
Err(error) => sess.emit_fatal(errors::UnableToRunDsymutil { error }),
|
||||
Err(error) => sess.dcx().emit_fatal(errors::UnableToRunDsymutil { error }),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1091,14 +1091,14 @@ fn strip_symbols_with_external_utility<'a>(
|
||||
if !prog.status.success() {
|
||||
let mut output = prog.stderr.clone();
|
||||
output.extend_from_slice(&prog.stdout);
|
||||
sess.emit_warning(errors::StrippingDebugInfoFailed {
|
||||
sess.dcx().emit_warning(errors::StrippingDebugInfoFailed {
|
||||
util,
|
||||
status: prog.status,
|
||||
output: escape_string(&output),
|
||||
});
|
||||
}
|
||||
}
|
||||
Err(error) => sess.emit_fatal(errors::UnableToRun { util, error }),
|
||||
Err(error) => sess.dcx().emit_fatal(errors::UnableToRun { util, error }),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1311,7 +1311,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||
)),
|
||||
(Some(linker), None) => {
|
||||
let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| {
|
||||
sess.emit_fatal(errors::LinkerFileStem);
|
||||
sess.dcx().emit_fatal(errors::LinkerFileStem);
|
||||
});
|
||||
let flavor = sess.target.linker_flavor.with_linker_hints(stem);
|
||||
Some((linker, flavor))
|
||||
@ -1456,15 +1456,15 @@ fn print_native_static_libs(
|
||||
OutFileName::Real(path) => {
|
||||
out.overwrite(&lib_args.join(" "), sess);
|
||||
if !lib_args.is_empty() {
|
||||
sess.emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
|
||||
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
|
||||
}
|
||||
}
|
||||
OutFileName::Stdout => {
|
||||
if !lib_args.is_empty() {
|
||||
sess.emit_note(errors::StaticLibraryNativeArtifacts);
|
||||
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
|
||||
// Prefix for greppability
|
||||
// Note: This must not be translated as tools are allowed to depend on this exact string.
|
||||
sess.note(format!("native-static-libs: {}", &lib_args.join(" ")));
|
||||
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1703,7 +1703,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC
|
||||
// Emit an error if the user requested self-contained mode on the CLI but the target
|
||||
// explicitly refuses it.
|
||||
if sess.target.link_self_contained.is_disabled() {
|
||||
sess.emit_err(errors::UnsupportedLinkSelfContained);
|
||||
sess.dcx().emit_err(errors::UnsupportedLinkSelfContained);
|
||||
}
|
||||
self_contained
|
||||
} else {
|
||||
@ -1790,14 +1790,14 @@ fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_ty
|
||||
match (crate_type, &sess.target.link_script) {
|
||||
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
|
||||
if !sess.target.linker_flavor.is_gnu() {
|
||||
sess.emit_fatal(errors::LinkScriptUnavailable);
|
||||
sess.dcx().emit_fatal(errors::LinkScriptUnavailable);
|
||||
}
|
||||
|
||||
let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-");
|
||||
|
||||
let path = tmpdir.join(file_name);
|
||||
if let Err(error) = fs::write(&path, script.as_ref()) {
|
||||
sess.emit_fatal(errors::LinkScriptWriteFailure { path, error });
|
||||
sess.dcx().emit_fatal(errors::LinkScriptWriteFailure { path, error });
|
||||
}
|
||||
|
||||
cmd.arg("--script");
|
||||
@ -1921,7 +1921,7 @@ fn add_linked_symbol_object(
|
||||
let path = tmpdir.join("symbols.o");
|
||||
let result = std::fs::write(&path, file.write().unwrap());
|
||||
if let Err(error) = result {
|
||||
sess.emit_fatal(errors::FailedToWrite { path, error });
|
||||
sess.dcx().emit_fatal(errors::FailedToWrite { path, error });
|
||||
}
|
||||
cmd.add_object(&path);
|
||||
}
|
||||
@ -2390,7 +2390,7 @@ fn collect_natvis_visualizers(
|
||||
visualizer_paths.push(visualizer_out_file);
|
||||
}
|
||||
Err(error) => {
|
||||
sess.emit_warning(errors::UnableToWriteDebuggerVisualizer {
|
||||
sess.dcx().emit_warning(errors::UnableToWriteDebuggerVisualizer {
|
||||
path: visualizer_out_file,
|
||||
error,
|
||||
});
|
||||
@ -2425,7 +2425,7 @@ fn add_native_libs_from_crate(
|
||||
let rlib = &codegen_results.crate_info.used_crate_source[&cnum].rlib.as_ref().unwrap().0;
|
||||
archive_builder_builder
|
||||
.extract_bundled_libs(rlib, tmpdir, bundled_libs)
|
||||
.unwrap_or_else(|e| sess.emit_fatal(e));
|
||||
.unwrap_or_else(|e| sess.dcx().emit_fatal(e));
|
||||
}
|
||||
|
||||
let native_libs = match cnum {
|
||||
@ -2798,7 +2798,7 @@ fn add_static_crate<'a>(
|
||||
false
|
||||
}),
|
||||
) {
|
||||
sess.emit_fatal(errors::RlibArchiveBuildFailure { error });
|
||||
sess.dcx().emit_fatal(errors::RlibArchiveBuildFailure { error });
|
||||
}
|
||||
if archive.build(&dst) {
|
||||
link_upstream(&dst);
|
||||
@ -2872,14 +2872,14 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
("arm", "watchos") => "watchos",
|
||||
(_, "macos") => "macosx",
|
||||
_ => {
|
||||
sess.emit_err(errors::UnsupportedArch { arch, os });
|
||||
sess.dcx().emit_err(errors::UnsupportedArch { arch, os });
|
||||
return;
|
||||
}
|
||||
};
|
||||
let sdk_root = match get_apple_sdk_root(sdk_name) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
sess.emit_err(e);
|
||||
sess.dcx().emit_err(e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -446,11 +446,11 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
// FIXME(81490): ld64 doesn't support these flags but macOS 11
|
||||
// has -needed-l{} / -needed_library {}
|
||||
// but we have no way to detect that here.
|
||||
self.sess.emit_warning(errors::Ld64UnimplementedModifier);
|
||||
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
|
||||
} else if self.is_gnu && !self.sess.target.is_like_windows {
|
||||
self.linker_arg("--no-as-needed");
|
||||
} else {
|
||||
self.sess.emit_warning(errors::LinkerUnsupportedModifier);
|
||||
self.sess.dcx().emit_warning(errors::LinkerUnsupportedModifier);
|
||||
}
|
||||
}
|
||||
self.hint_dynamic();
|
||||
@ -504,7 +504,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
|
||||
// flag but we have no way to detect that here.
|
||||
// self.cmd.arg("-needed_framework").arg(framework);
|
||||
self.sess.emit_warning(errors::Ld64UnimplementedModifier);
|
||||
self.sess.dcx().emit_warning(errors::Ld64UnimplementedModifier);
|
||||
}
|
||||
self.cmd.arg("-framework").arg(framework);
|
||||
}
|
||||
@ -693,7 +693,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
}
|
||||
};
|
||||
if let Err(error) = res {
|
||||
self.sess.emit_fatal(errors::LibDefWriteFailure { error });
|
||||
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
|
||||
}
|
||||
} else if is_windows {
|
||||
let res: io::Result<()> = try {
|
||||
@ -708,7 +708,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
}
|
||||
};
|
||||
if let Err(error) = res {
|
||||
self.sess.emit_fatal(errors::LibDefWriteFailure { error });
|
||||
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
|
||||
}
|
||||
} else {
|
||||
// Write an LD version script
|
||||
@ -725,7 +725,7 @@ impl<'a> Linker for GccLinker<'a> {
|
||||
writeln!(f, "\n local:\n *;\n}};")?;
|
||||
};
|
||||
if let Err(error) = res {
|
||||
self.sess.emit_fatal(errors::VersionScriptWriteFailure { error });
|
||||
self.sess.dcx().emit_fatal(errors::VersionScriptWriteFailure { error });
|
||||
}
|
||||
}
|
||||
|
||||
@ -950,7 +950,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
self.sess.emit_warning(errors::NoNatvisDirectory { error });
|
||||
self.sess.dcx().emit_warning(errors::NoNatvisDirectory { error });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1005,7 +1005,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||
}
|
||||
};
|
||||
if let Err(error) = res {
|
||||
self.sess.emit_fatal(errors::LibDefWriteFailure { error });
|
||||
self.sess.dcx().emit_fatal(errors::LibDefWriteFailure { error });
|
||||
}
|
||||
let mut arg = OsString::from("/DEF:");
|
||||
arg.push(path);
|
||||
@ -1501,7 +1501,7 @@ impl<'a> Linker for L4Bender<'a> {
|
||||
|
||||
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
|
||||
// ToDo, not implemented, copy from GCC
|
||||
self.sess.emit_warning(errors::L4BenderExportingSymbolsUnimplemented);
|
||||
self.sess.dcx().emit_warning(errors::L4BenderExportingSymbolsUnimplemented);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1688,7 +1688,7 @@ impl<'a> Linker for AixLinker<'a> {
|
||||
}
|
||||
};
|
||||
if let Err(e) = res {
|
||||
self.sess.fatal(format!("failed to write export file: {e}"));
|
||||
self.sess.dcx().fatal(format!("failed to write export file: {e}"));
|
||||
}
|
||||
self.cmd.arg(format!("-bE:{}", path.to_str().unwrap()));
|
||||
}
|
||||
@ -1995,7 +1995,7 @@ impl<'a> Linker for BpfLinker<'a> {
|
||||
}
|
||||
};
|
||||
if let Err(error) = res {
|
||||
self.sess.emit_fatal(errors::SymbolFileWriteFailure { error });
|
||||
self.sess.dcx().emit_fatal(errors::SymbolFileWriteFailure { error });
|
||||
} else {
|
||||
self.cmd.arg("--export-symbols").arg(&path);
|
||||
}
|
||||
|
@ -534,12 +534,12 @@ fn produce_final_output_artifacts(
|
||||
let copy_gracefully = |from: &Path, to: &OutFileName| match to {
|
||||
OutFileName::Stdout => {
|
||||
if let Err(e) = copy_to_stdout(from) {
|
||||
sess.emit_err(errors::CopyPath::new(from, to.as_path(), e));
|
||||
sess.dcx().emit_err(errors::CopyPath::new(from, to.as_path(), e));
|
||||
}
|
||||
}
|
||||
OutFileName::Real(path) => {
|
||||
if let Err(e) = fs::copy(from, path) {
|
||||
sess.emit_err(errors::CopyPath::new(from, path, e));
|
||||
sess.dcx().emit_err(errors::CopyPath::new(from, path, e));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -552,7 +552,8 @@ fn produce_final_output_artifacts(
|
||||
let path = crate_output.temp_path(output_type, module_name);
|
||||
let output = crate_output.path(output_type);
|
||||
if !output_type.is_text_output() && output.is_tty() {
|
||||
sess.emit_err(errors::BinaryOutputToTty { shorthand: output_type.shorthand() });
|
||||
sess.dcx()
|
||||
.emit_err(errors::BinaryOutputToTty { shorthand: output_type.shorthand() });
|
||||
} else {
|
||||
copy_gracefully(&path, &output);
|
||||
}
|
||||
@ -572,11 +573,11 @@ fn produce_final_output_artifacts(
|
||||
if crate_output.outputs.contains_key(&output_type) {
|
||||
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
|
||||
// no good solution for this case, so warn the user.
|
||||
sess.emit_warning(errors::IgnoringEmitPath { extension });
|
||||
sess.dcx().emit_warning(errors::IgnoringEmitPath { extension });
|
||||
} else if crate_output.single_output_file.is_some() {
|
||||
// 3) Multiple codegen units, with `-o some_name`. We have
|
||||
// no good solution for this case, so warn the user.
|
||||
sess.emit_warning(errors::IgnoringOutput { extension });
|
||||
sess.dcx().emit_warning(errors::IgnoringOutput { extension });
|
||||
} else {
|
||||
// 4) Multiple codegen units, but no explicit name. We
|
||||
// just leave the `foo.0.x` files in place.
|
||||
@ -1079,7 +1080,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||
let result = fs::create_dir_all(dir).and_then(|_| dir.canonicalize());
|
||||
match result {
|
||||
Ok(dir) => Some(dir),
|
||||
Err(error) => sess.emit_fatal(ErrorCreatingRemarkDir { error }),
|
||||
Err(error) => sess.dcx().emit_fatal(ErrorCreatingRemarkDir { error }),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
@ -1885,7 +1886,7 @@ impl SharedEmitterMain {
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
Ok(SharedEmitterMessage::Fatal(msg)) => {
|
||||
sess.fatal(msg);
|
||||
sess.dcx().fatal(msg);
|
||||
}
|
||||
Err(_) => {
|
||||
break;
|
||||
|
@ -448,7 +448,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
let Some(llfn) = cx.declare_c_main(llfty) else {
|
||||
// FIXME: We should be smart and show a better diagnostic here.
|
||||
let span = cx.tcx().def_span(rust_main_def_id);
|
||||
cx.sess().emit_err(errors::MultipleMainFunctions { span });
|
||||
cx.sess().dcx().emit_err(errors::MultipleMainFunctions { span });
|
||||
cx.sess().abort_if_errors();
|
||||
bug!();
|
||||
};
|
||||
@ -620,7 +620,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
&exported_symbols::metadata_symbol_name(tcx),
|
||||
);
|
||||
if let Err(error) = std::fs::write(&file_name, data) {
|
||||
tcx.sess.emit_fatal(errors::MetadataObjectFileWrite { error });
|
||||
tcx.dcx().emit_fatal(errors::MetadataObjectFileWrite { error });
|
||||
}
|
||||
CompiledModule {
|
||||
name: metadata_cgu_name,
|
||||
@ -819,7 +819,7 @@ impl CrateInfo {
|
||||
let subsystem = attr::first_attr_value_str_by_name(crate_attrs, sym::windows_subsystem);
|
||||
let windows_subsystem = subsystem.map(|subsystem| {
|
||||
if subsystem != sym::windows && subsystem != sym::console {
|
||||
tcx.sess.emit_fatal(errors::InvalidWindowsSubsystem { subsystem });
|
||||
tcx.dcx().emit_fatal(errors::InvalidWindowsSubsystem { subsystem });
|
||||
}
|
||||
subsystem.to_string()
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: LocalDefId, name: &str) -> Linkage {
|
||||
"private" => Private,
|
||||
"weak" => WeakAny,
|
||||
"weak_odr" => WeakODR,
|
||||
_ => tcx.sess.span_fatal(tcx.def_span(def_id), "invalid linkage specified"),
|
||||
_ => tcx.dcx().span_fatal(tcx.def_span(def_id), "invalid linkage specified"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
if let Fn | AssocFn | Variant | Ctor(..) = def_kind {
|
||||
Some(tcx.fn_sig(did))
|
||||
} else {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(attr.span, "this attribute can only be applied to functions");
|
||||
None
|
||||
}
|
||||
@ -119,7 +119,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
if tcx.opt_item_name(did.to_def_id()).is_some() {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE
|
||||
} else {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(
|
||||
attr.span,
|
||||
format!(
|
||||
@ -142,7 +142,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
// coverage on a smaller scope within an excluded larger scope.
|
||||
}
|
||||
Some(_) | None => {
|
||||
tcx.sess.emit_err(ExpectedCoverageSymbol { span: attr.span });
|
||||
tcx.dcx().emit_err(ExpectedCoverageSymbol { span: attr.span });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED;
|
||||
}
|
||||
Some(_) => {
|
||||
tcx.sess.emit_err(ExpectedUsedSymbol { span: attr.span });
|
||||
tcx.dcx().emit_err(ExpectedUsedSymbol { span: attr.span });
|
||||
}
|
||||
None => {
|
||||
// Unfortunately, unconditionally using `llvm.used` causes
|
||||
@ -217,7 +217,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
&& !matches!(fn_sig.skip_binder().abi(), abi::Abi::C { .. })
|
||||
{
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0776,
|
||||
"`#[cmse_nonsecure_entry]` requires C ABI"
|
||||
@ -225,7 +225,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
.emit();
|
||||
}
|
||||
if !tcx.sess.target.llvm_target.contains("thumbv8m") {
|
||||
struct_span_err!(tcx.sess, attr.span, E0775, "`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension")
|
||||
struct_span_err!(tcx.dcx(), attr.span, E0775, "`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension")
|
||||
.emit();
|
||||
}
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY
|
||||
@ -239,7 +239,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
&& fn_sig.skip_binder().abi() != abi::Abi::Rust
|
||||
{
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0737,
|
||||
"`#[track_caller]` requires Rust ABI"
|
||||
@ -266,7 +266,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
// `#[export_name = ...]` will be converted to a null-terminated string,
|
||||
// so it may not contain any null characters.
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0648,
|
||||
"`export_name` may not contain null characters"
|
||||
@ -336,7 +336,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
if let Some(val) = attr.value_str() {
|
||||
if val.as_str().bytes().any(|b| b == 0) {
|
||||
let msg = format!("illegal null byte in link_section value: `{}`", &val);
|
||||
tcx.sess.span_err(attr.span, msg);
|
||||
tcx.dcx().span_err(attr.span, msg);
|
||||
} else {
|
||||
codegen_fn_attrs.link_section = Some(val);
|
||||
}
|
||||
@ -370,7 +370,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
codegen_fn_attrs.no_sanitize |= SanitizerSet::HWADDRESS
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.emit_err(errors::InvalidNoSanitize { span: item.span() });
|
||||
tcx.dcx().emit_err(errors::InvalidNoSanitize { span: item.span() });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -386,7 +386,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
[sym::arm, sym::a32] | [sym::arm, sym::t32] => {
|
||||
if !tcx.sess.target.has_thumb_interworking {
|
||||
struct_span_err!(
|
||||
tcx.sess.dcx(),
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0779,
|
||||
"target does not support `#[instruction_set]`"
|
||||
@ -403,7 +403,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(
|
||||
tcx.sess.dcx(),
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0779,
|
||||
"invalid instruction set specified",
|
||||
@ -415,7 +415,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
}
|
||||
[] => {
|
||||
struct_span_err!(
|
||||
tcx.sess.dcx(),
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0778,
|
||||
"`#[instruction_set]` requires an argument"
|
||||
@ -425,7 +425,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(
|
||||
tcx.sess.dcx(),
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0779,
|
||||
"cannot specify more than one instruction set"
|
||||
@ -443,7 +443,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
rustc_attr::parse_alignment(&literal.kind)
|
||||
.map_err(|msg| {
|
||||
struct_span_err!(
|
||||
tcx.sess.dcx(),
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0589,
|
||||
"invalid `repr(align)` attribute: {}",
|
||||
@ -469,15 +469,14 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
Some(MetaItemKind::List(ref items)) => {
|
||||
inline_span = Some(attr.span);
|
||||
if items.len() != 1 {
|
||||
struct_span_err!(tcx.sess.dcx(), attr.span, E0534, "expected one argument")
|
||||
.emit();
|
||||
struct_span_err!(tcx.dcx(), attr.span, E0534, "expected one argument").emit();
|
||||
InlineAttr::None
|
||||
} else if list_contains_name(items, sym::always) {
|
||||
InlineAttr::Always
|
||||
} else if list_contains_name(items, sym::never) {
|
||||
InlineAttr::Never
|
||||
} else {
|
||||
struct_span_err!(tcx.sess.dcx(), items[0].span(), E0535, "invalid argument")
|
||||
struct_span_err!(tcx.dcx(), items[0].span(), E0535, "invalid argument")
|
||||
.help("valid inline arguments are `always` and `never`")
|
||||
.emit();
|
||||
|
||||
@ -493,7 +492,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
if !attr.has_name(sym::optimize) {
|
||||
return ia;
|
||||
}
|
||||
let err = |sp, s| struct_span_err!(tcx.sess.dcx(), sp, E0722, "{}", s).emit();
|
||||
let err = |sp, s| struct_span_err!(tcx.dcx(), sp, E0722, "{}", s).emit();
|
||||
match attr.meta_kind() {
|
||||
Some(MetaItemKind::Word) => {
|
||||
err(attr.span, "expected one argument");
|
||||
@ -550,7 +549,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
if !codegen_fn_attrs.target_features.is_empty() {
|
||||
if codegen_fn_attrs.inline == InlineAttr::Always {
|
||||
if let Some(span) = inline_span {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
span,
|
||||
"cannot use `#[inline(always)]` with \
|
||||
`#[target_feature]`",
|
||||
@ -637,7 +636,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
||||
let sole_meta_list = match meta_item_list {
|
||||
Some([item]) => item.lit(),
|
||||
Some(_) => {
|
||||
tcx.sess.emit_err(errors::InvalidLinkOrdinalNargs { span: attr.span });
|
||||
tcx.dcx().emit_err(errors::InvalidLinkOrdinalNargs { span: attr.span });
|
||||
return None;
|
||||
}
|
||||
_ => None,
|
||||
@ -661,14 +660,14 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
||||
Some(*ordinal as u16)
|
||||
} else {
|
||||
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(attr.span, msg)
|
||||
.note("the value may not exceed `u16::MAX`")
|
||||
.emit();
|
||||
None
|
||||
}
|
||||
} else {
|
||||
tcx.sess.emit_err(errors::InvalidLinkOrdinalFormat { span: attr.span });
|
||||
tcx.dcx().emit_err(errors::InvalidLinkOrdinalFormat { span: attr.span });
|
||||
None
|
||||
}
|
||||
}
|
||||
@ -683,9 +682,9 @@ fn check_link_name_xor_ordinal(
|
||||
}
|
||||
let msg = "cannot use `#[link_name]` with `#[link_ordinal]`";
|
||||
if let Some(span) = inline_span {
|
||||
tcx.sess.span_err(span, msg);
|
||||
tcx.dcx().span_err(span, msg);
|
||||
} else {
|
||||
tcx.sess.err(msg);
|
||||
tcx.dcx().err(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ fn push_debuginfo_type_name<'tcx>(
|
||||
Err(e) => {
|
||||
// Computing the layout can still fail here, e.g. if the target architecture
|
||||
// cannot represent the type. See https://github.com/rust-lang/rust/issues/94961.
|
||||
tcx.sess.emit_fatal(e.into_diagnostic());
|
||||
tcx.dcx().emit_fatal(e.into_diagnostic());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -94,7 +94,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
bx.const_struct(&values, false)
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
bx.tcx().sess.emit_err(errors::ShuffleIndicesEvaluation { span: constant.span });
|
||||
bx.tcx().dcx().emit_err(errors::ShuffleIndicesEvaluation { span: constant.span });
|
||||
// We've errored, so we don't have to produce working code.
|
||||
let llty = bx.backend_type(bx.layout_of(ty));
|
||||
bx.const_undef(llty)
|
||||
|
@ -220,7 +220,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
bx.tcx().sess.emit_err(InvalidMonomorphization::BasicIntegerType {
|
||||
bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
|
||||
span,
|
||||
name,
|
||||
ty,
|
||||
@ -240,7 +240,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
_ => bug!(),
|
||||
},
|
||||
None => {
|
||||
bx.tcx().sess.emit_err(InvalidMonomorphization::BasicFloatType {
|
||||
bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicFloatType {
|
||||
span,
|
||||
name,
|
||||
ty: arg_tys[0],
|
||||
@ -252,14 +252,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
|
||||
sym::float_to_int_unchecked => {
|
||||
if float_type_width(arg_tys[0]).is_none() {
|
||||
bx.tcx().sess.emit_err(InvalidMonomorphization::FloatToIntUnchecked {
|
||||
bx.tcx().dcx().emit_err(InvalidMonomorphization::FloatToIntUnchecked {
|
||||
span,
|
||||
ty: arg_tys[0],
|
||||
});
|
||||
return;
|
||||
}
|
||||
let Some((_width, signed)) = int_type_width_signed(ret_ty, bx.tcx()) else {
|
||||
bx.tcx().sess.emit_err(InvalidMonomorphization::FloatToIntUnchecked {
|
||||
bx.tcx().dcx().emit_err(InvalidMonomorphization::FloatToIntUnchecked {
|
||||
span,
|
||||
ty: ret_ty,
|
||||
});
|
||||
@ -297,7 +297,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
use crate::common::{AtomicRmwBinOp, SynchronizationScope};
|
||||
|
||||
let Some((instruction, ordering)) = atomic.split_once('_') else {
|
||||
bx.sess().emit_fatal(errors::MissingMemoryOrdering);
|
||||
bx.sess().dcx().emit_fatal(errors::MissingMemoryOrdering);
|
||||
};
|
||||
|
||||
let parse_ordering = |bx: &Bx, s| match s {
|
||||
@ -307,11 +307,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
"release" => Release,
|
||||
"acqrel" => AcquireRelease,
|
||||
"seqcst" => SequentiallyConsistent,
|
||||
_ => bx.sess().emit_fatal(errors::UnknownAtomicOrdering),
|
||||
_ => bx.sess().dcx().emit_fatal(errors::UnknownAtomicOrdering),
|
||||
};
|
||||
|
||||
let invalid_monomorphization = |ty| {
|
||||
bx.tcx().sess.emit_err(InvalidMonomorphization::BasicIntegerType {
|
||||
bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
|
||||
span,
|
||||
name,
|
||||
ty,
|
||||
@ -321,7 +321,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
match instruction {
|
||||
"cxchg" | "cxchgweak" => {
|
||||
let Some((success, failure)) = ordering.split_once('_') else {
|
||||
bx.sess().emit_fatal(errors::AtomicCompareExchange);
|
||||
bx.sess().dcx().emit_fatal(errors::AtomicCompareExchange);
|
||||
};
|
||||
let ty = fn_args.type_at(0);
|
||||
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
|
||||
@ -437,7 +437,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
"min" => AtomicRmwBinOp::AtomicMin,
|
||||
"umax" => AtomicRmwBinOp::AtomicUMax,
|
||||
"umin" => AtomicRmwBinOp::AtomicUMin,
|
||||
_ => bx.sess().emit_fatal(errors::UnknownAtomicOperation),
|
||||
_ => bx.sess().dcx().emit_fatal(errors::UnknownAtomicOperation),
|
||||
};
|
||||
|
||||
let ty = fn_args.type_at(0);
|
||||
|
@ -25,7 +25,7 @@ pub fn from_target_feature(
|
||||
let bad_item = |span| {
|
||||
let msg = "malformed `target_feature` attribute input";
|
||||
let code = "enable = \"..\"";
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(span, msg)
|
||||
.span_suggestion(span, "must be of the form", code, Applicability::HasPlaceholders)
|
||||
.emit();
|
||||
@ -48,7 +48,7 @@ pub fn from_target_feature(
|
||||
target_features.extend(value.as_str().split(',').filter_map(|feature| {
|
||||
let Some(feature_gate) = supported_target_features.get(feature) else {
|
||||
let msg = format!("the feature named `{feature}` is not valid for this target");
|
||||
let mut err = tcx.sess.struct_span_err(item.span(), msg);
|
||||
let mut err = tcx.dcx().struct_span_err(item.span(), msg);
|
||||
err.span_label(item.span(), format!("`{feature}` is not valid for this target"));
|
||||
if let Some(stripped) = feature.strip_prefix('+') {
|
||||
let valid = supported_target_features.contains_key(stripped);
|
||||
@ -121,7 +121,7 @@ pub fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, attr_s
|
||||
if let DefKind::AssocFn = tcx.def_kind(id) {
|
||||
let parent_id = tcx.local_parent(id);
|
||||
if let DefKind::Trait | DefKind::Impl { of_trait: true } = tcx.def_kind(parent_id) {
|
||||
tcx.sess.emit_err(errors::TargetFeatureSafeTrait {
|
||||
tcx.dcx().emit_err(errors::TargetFeatureSafeTrait {
|
||||
span: attr_span,
|
||||
def: tcx.def_span(id),
|
||||
});
|
||||
|
@ -151,10 +151,10 @@ where
|
||||
let (our_span, frames) = get_span_and_frames();
|
||||
let span = span.unwrap_or(our_span);
|
||||
let err = mk(span, frames);
|
||||
let mut err = tcx.sess.create_err(err);
|
||||
let mut err = tcx.dcx().create_err(err);
|
||||
|
||||
let msg = error.diagnostic_message();
|
||||
error.add_args(tcx.sess.dcx(), &mut err);
|
||||
error.add_args(tcx.dcx(), &mut err);
|
||||
|
||||
// Use *our* span to label the interp error
|
||||
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) {
|
||||
Ok(ecx.tcx.mir_for_ctfe(def))
|
||||
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
|
||||
let guar = ecx.tcx.sess.span_delayed_bug(
|
||||
let guar = ecx.tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
"This is likely a const item that is missing from its impl",
|
||||
);
|
||||
@ -621,7 +621,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||
if is_error {
|
||||
let guard = ecx
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(span, "The deny lint should have already errored");
|
||||
throw_inval!(AlreadyReported(guard.into()));
|
||||
}
|
||||
@ -630,7 +630,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
|
||||
// way to implement exponential backoff.
|
||||
let span = ecx.cur_span();
|
||||
ecx.tcx.sess.emit_warning(LongRunningWarn { span, item_span: ecx.tcx.span });
|
||||
ecx.tcx.dcx().emit_warning(LongRunningWarn { span, item_span: ecx.tcx.span });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
|
||||
match err {
|
||||
ValTreeCreationError::NodesOverflow => {
|
||||
let span = tcx.hir().span_if_local(did);
|
||||
tcx.sess.emit_err(MaxNumNodesInConstErr { span, global_const_id });
|
||||
tcx.dcx().emit_err(MaxNumNodesInConstErr { span, global_const_id });
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
@ -439,8 +439,8 @@ pub trait ReportErrorExt {
|
||||
Self: Sized,
|
||||
{
|
||||
ty::tls::with(move |tcx| {
|
||||
let mut builder = tcx.sess.struct_allow(DiagnosticMessage::Str(String::new().into()));
|
||||
let dcx = tcx.sess.dcx();
|
||||
let dcx = tcx.dcx();
|
||||
let mut builder = dcx.struct_allow(DiagnosticMessage::Str(String::new().into()));
|
||||
let message = self.diagnostic_message();
|
||||
self.add_args(dcx, &mut builder);
|
||||
let s = dcx.eagerly_translate_to_string(message, builder.args());
|
||||
|
@ -473,9 +473,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
backtrace.print_backtrace();
|
||||
// FIXME(fee1-dead), HACK: we want to use the error as title therefore we can just extract the
|
||||
// label and arguments from the InterpError.
|
||||
let dcx = self.tcx.sess.dcx();
|
||||
let dcx = self.tcx.dcx();
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
let mut diag = self.tcx.sess.struct_allow("");
|
||||
let mut diag = dcx.struct_allow("");
|
||||
let msg = e.diagnostic_message();
|
||||
e.add_args(dcx, &mut diag);
|
||||
let s = dcx.eagerly_translate_to_string(msg, diag.args());
|
||||
|
@ -96,7 +96,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
|
||||
// in the value the dangling reference lies.
|
||||
// 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() {
|
||||
tcx.sess.span_delayed_bug(ecx.tcx.span, "tried to intern dangling pointer");
|
||||
tcx.dcx().span_delayed_bug(ecx.tcx.span, "tried to intern dangling pointer");
|
||||
}
|
||||
// treat dangling pointers like other statics
|
||||
// just to stop trying to recurse into them
|
||||
@ -185,7 +185,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx, const_eval::Memory
|
||||
} else {
|
||||
// Validation will error (with a better message) on an invalid vtable pointer.
|
||||
// Let validation show the error message, but make sure it *does* error.
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(tcx.span, "vtables pointers cannot be integer pointers");
|
||||
}
|
||||
}
|
||||
@ -375,7 +375,7 @@ pub fn intern_const_alloc_recursive<
|
||||
match res {
|
||||
Ok(()) => {}
|
||||
Err(error) => {
|
||||
ecx.tcx.sess.span_delayed_bug(
|
||||
ecx.tcx.dcx().span_delayed_bug(
|
||||
ecx.tcx.span,
|
||||
format!(
|
||||
"error during interning should later cause validation failure: {}",
|
||||
@ -424,7 +424,7 @@ pub fn intern_const_alloc_recursive<
|
||||
// something that cannot be promoted, which in constants means values that have
|
||||
// drop glue, such as the example above.
|
||||
InternKind::Constant => {
|
||||
ecx.tcx.sess.emit_err(UnsupportedUntypedPointer { span: ecx.tcx.span });
|
||||
ecx.tcx.dcx().emit_err(UnsupportedUntypedPointer { span: ecx.tcx.span });
|
||||
// For better errors later, mark the allocation as immutable.
|
||||
alloc.mutability = Mutability::Not;
|
||||
}
|
||||
@ -440,7 +440,7 @@ pub fn intern_const_alloc_recursive<
|
||||
} else if ecx.memory.dead_alloc_map.contains_key(&alloc_id) {
|
||||
// Codegen does not like dangling pointers, and generally `tcx` assumes that
|
||||
// all allocations referenced anywhere actually exist. So, make sure we error here.
|
||||
let reported = ecx.tcx.sess.emit_err(DanglingPtrInFinal { span: ecx.tcx.span });
|
||||
let reported = ecx.tcx.dcx().emit_err(DanglingPtrInFinal { span: ecx.tcx.span });
|
||||
return Err(reported);
|
||||
} else if ecx.tcx.try_get_global_alloc(alloc_id).is_none() {
|
||||
// We have hit an `AllocId` that is neither in local or global memory and isn't
|
||||
|
@ -244,7 +244,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||
// `async` functions cannot be `const fn`. This is checked during AST lowering, so there's
|
||||
// no need to emit duplicate errors here.
|
||||
if self.ccx.is_async() || body.coroutine.is_some() {
|
||||
tcx.sess.span_delayed_bug(body.span, "`async` functions cannot be `const fn`");
|
||||
tcx.dcx().span_delayed_bug(body.span, "`async` functions cannot be `const fn`");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||
let secondary_errors = mem::take(&mut self.secondary_errors);
|
||||
if self.error_emitted.is_none() {
|
||||
for error in secondary_errors {
|
||||
self.tcx.sess.dcx().emit_diagnostic(error);
|
||||
self.tcx.dcx().emit_diagnostic(error);
|
||||
}
|
||||
} else {
|
||||
assert!(self.tcx.sess.has_errors().is_some());
|
||||
@ -354,7 +354,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||
fn check_static(&mut self, def_id: DefId, span: Span) {
|
||||
if self.tcx.is_thread_local_static(def_id) {
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
|
||||
}
|
||||
self.check_op_spanned(ops::StaticAccess, span)
|
||||
@ -994,5 +994,5 @@ fn is_int_bool_or_char(ty: Ty<'_>) -> bool {
|
||||
fn emit_unstable_in_stable_error(ccx: &ConstCx<'_, '_>, span: Span, gate: Symbol) {
|
||||
let attr_span = ccx.tcx.def_span(ccx.def_id()).shrink_to_lo();
|
||||
|
||||
ccx.tcx.sess.emit_err(UnstableInStable { gate: gate.to_string(), span, attr_span });
|
||||
ccx.dcx().emit_err(UnstableInStable { gate: gate.to_string(), span, attr_span });
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
//! it finds operations that are invalid in a certain context.
|
||||
|
||||
use rustc_attr as attr;
|
||||
use rustc_errors::DiagCtxt;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::mir;
|
||||
@ -44,6 +45,10 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
|
||||
ConstCx { body, tcx, param_env, const_kind }
|
||||
}
|
||||
|
||||
pub(crate) fn dcx(&self) -> &'tcx DiagCtxt {
|
||||
self.tcx.dcx()
|
||||
}
|
||||
|
||||
pub fn def_id(&self) -> LocalDefId {
|
||||
self.body.source.def_id().expect_local()
|
||||
}
|
||||
@ -112,7 +117,7 @@ pub fn is_const_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
None if is_parent_const_stable_trait(tcx, def_id) => {
|
||||
// Remove this when `#![feature(const_trait_impl)]` is stabilized,
|
||||
// returning `true` unconditionally.
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(def_id),
|
||||
"trait implementations cannot be const stable yet",
|
||||
);
|
||||
|
@ -77,7 +77,7 @@ impl<'tcx> NonConstOp<'tcx> for FloatingPointOp {
|
||||
pub struct FnCallIndirect;
|
||||
impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::UnallowedFnPointerCall { span, kind: ccx.const_kind() })
|
||||
ccx.dcx().create_err(errors::UnallowedFnPointerCall { span, kind: ccx.const_kind() })
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
CallKind::Normal { desugaring: Some((kind, self_ty)), .. } => {
|
||||
macro_rules! error {
|
||||
($err:ident) => {
|
||||
tcx.sess.create_err(errors::$err {
|
||||
tcx.dcx().create_err(errors::$err {
|
||||
span,
|
||||
ty: self_ty,
|
||||
kind: ccx.const_kind(),
|
||||
@ -192,7 +192,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let mut err = tcx.sess.create_err(errors::NonConstClosure {
|
||||
let mut err = tcx.dcx().create_err(errors::NonConstClosure {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
note,
|
||||
@ -203,7 +203,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
}
|
||||
CallKind::Operator { trait_id, self_ty, .. } => {
|
||||
let mut err = if let CallSource::MatchCmp = call_source {
|
||||
tcx.sess.create_err(errors::NonConstMatchEq {
|
||||
tcx.dcx().create_err(errors::NonConstMatchEq {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
ty: self_ty,
|
||||
@ -248,7 +248,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
tcx.sess.create_err(errors::NonConstOperator {
|
||||
tcx.dcx().create_err(errors::NonConstOperator {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
sugg,
|
||||
@ -266,7 +266,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
None
|
||||
};
|
||||
|
||||
let mut err = tcx.sess.create_err(errors::NonConstDerefCoercion {
|
||||
let mut err = tcx.dcx().create_err(errors::NonConstDerefCoercion {
|
||||
span,
|
||||
ty: self_ty,
|
||||
kind: ccx.const_kind(),
|
||||
@ -277,11 +277,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
diag_trait(&mut err, self_ty, tcx.require_lang_item(LangItem::Deref, Some(span)));
|
||||
err
|
||||
}
|
||||
_ if tcx.opt_parent(callee) == tcx.get_diagnostic_item(sym::ArgumentMethods) => ccx
|
||||
.tcx
|
||||
.sess
|
||||
.create_err(errors::NonConstFmtMacroCall { span, kind: ccx.const_kind() }),
|
||||
_ => ccx.tcx.sess.create_err(errors::NonConstFnCall {
|
||||
_ if tcx.opt_parent(callee) == tcx.get_diagnostic_item(sym::ArgumentMethods) => {
|
||||
ccx.dcx().create_err(errors::NonConstFmtMacroCall { span, kind: ccx.const_kind() })
|
||||
}
|
||||
_ => ccx.dcx().create_err(errors::NonConstFnCall {
|
||||
span,
|
||||
def_path_str: ccx.tcx.def_path_str_with_args(callee, args),
|
||||
kind: ccx.const_kind(),
|
||||
@ -319,8 +318,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
|
||||
let FnCallUnstable(def_id, feature) = *self;
|
||||
|
||||
let mut err = ccx
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.create_err(errors::UnstableConstFn { span, def_path: ccx.tcx.def_path_str(def_id) });
|
||||
|
||||
if ccx.is_const_stable_const_fn() {
|
||||
@ -362,7 +360,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
|
||||
sym::const_async_blocks,
|
||||
)
|
||||
} else {
|
||||
ccx.tcx.sess.create_err(errors::UnallowedOpInConstContext { span, msg })
|
||||
ccx.dcx().create_err(errors::UnallowedOpInConstContext { span, msg })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -371,7 +369,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
|
||||
pub struct HeapAllocation;
|
||||
impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::UnallowedHeapAllocations {
|
||||
ccx.dcx().create_err(errors::UnallowedHeapAllocations {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(&error_code!(E0010)).then_some(()),
|
||||
@ -383,7 +381,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
|
||||
pub struct InlineAsm;
|
||||
impl<'tcx> NonConstOp<'tcx> for InlineAsm {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::UnallowedInlineAsm { span, kind: ccx.const_kind() })
|
||||
ccx.dcx().create_err(errors::UnallowedInlineAsm { span, kind: ccx.const_kind() })
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,7 +392,7 @@ pub struct LiveDrop<'tcx> {
|
||||
}
|
||||
impl<'tcx> NonConstOp<'tcx> for LiveDrop<'tcx> {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::LiveDrop {
|
||||
ccx.dcx().create_err(errors::LiveDrop {
|
||||
span,
|
||||
dropped_ty: self.dropped_ty,
|
||||
kind: ccx.const_kind(),
|
||||
@ -432,14 +430,14 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
// FIXME: Maybe a more elegant solution to this if else case
|
||||
if let hir::ConstContext::Static(_) = ccx.const_kind() {
|
||||
ccx.tcx.sess.create_err(errors::InteriorMutableDataRefer {
|
||||
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
|
||||
span,
|
||||
opt_help: Some(()),
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(&error_code!(E0492)).then_some(()),
|
||||
})
|
||||
} else {
|
||||
ccx.tcx.sess.create_err(errors::InteriorMutableDataRefer {
|
||||
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
|
||||
span,
|
||||
opt_help: None,
|
||||
kind: ccx.const_kind(),
|
||||
@ -468,12 +466,12 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
match self.0 {
|
||||
hir::BorrowKind::Raw => ccx.tcx.sess.create_err(errors::UnallowedMutableRefsRaw {
|
||||
hir::BorrowKind::Raw => ccx.dcx().create_err(errors::UnallowedMutableRefsRaw {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(&error_code!(E0764)).then_some(()),
|
||||
}),
|
||||
hir::BorrowKind::Ref => ccx.tcx.sess.create_err(errors::UnallowedMutableRefs {
|
||||
hir::BorrowKind::Ref => ccx.dcx().create_err(errors::UnallowedMutableRefs {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(&error_code!(E0764)).then_some(()),
|
||||
@ -530,7 +528,7 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref {
|
||||
pub struct PanicNonStr;
|
||||
impl<'tcx> NonConstOp<'tcx> for PanicNonStr {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::PanicNonStrErr { span })
|
||||
ccx.dcx().create_err(errors::PanicNonStrErr { span })
|
||||
}
|
||||
}
|
||||
|
||||
@ -542,7 +540,7 @@ pub struct RawPtrComparison;
|
||||
impl<'tcx> NonConstOp<'tcx> for RawPtrComparison {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
// FIXME(const_trait_impl): revert to span_bug?
|
||||
ccx.tcx.sess.create_err(errors::RawPtrComparisonErr { span })
|
||||
ccx.dcx().create_err(errors::RawPtrComparisonErr { span })
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,7 +568,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref {
|
||||
pub struct RawPtrToIntCast;
|
||||
impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::RawPtrToIntErr { span })
|
||||
ccx.dcx().create_err(errors::RawPtrToIntErr { span })
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,7 +585,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess {
|
||||
}
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::StaticAccessErr {
|
||||
ccx.dcx().create_err(errors::StaticAccessErr {
|
||||
span,
|
||||
kind: ccx.const_kind(),
|
||||
teach: ccx.tcx.sess.teach(&error_code!(E0013)).then_some(()),
|
||||
@ -600,7 +598,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess {
|
||||
pub struct ThreadLocalAccess;
|
||||
impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||
ccx.tcx.sess.create_err(errors::NonConstOpErr { span })
|
||||
ccx.dcx().create_err(errors::NonConstOpErr { span })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> {
|
||||
let span = self.body.source_info(location).span;
|
||||
// We use `span_delayed_bug` as we might see broken MIR when other errors have already
|
||||
// occurred.
|
||||
self.tcx.sess.dcx().span_delayed_bug(
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!(
|
||||
"broken MIR in {:?} ({}) at {:?}:\n{}",
|
||||
@ -527,7 +527,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
|
||||
|
||||
fn visit_source_scope(&mut self, scope: SourceScope) {
|
||||
if self.body.source_scopes.get(scope).is_none() {
|
||||
self.tcx.sess.dcx().span_delayed_bug(
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
self.body.span,
|
||||
format!(
|
||||
"broken MIR in {:?} ({}):\ninvalid source scope {:?}",
|
||||
|
@ -640,20 +640,22 @@ fn show_md_content_with_pager(content: &str, color: ColorConfig) {
|
||||
|
||||
fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
|
||||
assert!(sess.opts.unstable_opts.link_only);
|
||||
let dcx = sess.dcx();
|
||||
if let Input::File(file) = &sess.io.input {
|
||||
let rlink_data = fs::read(file).unwrap_or_else(|err| {
|
||||
sess.emit_fatal(RlinkUnableToRead { err });
|
||||
dcx.emit_fatal(RlinkUnableToRead { err });
|
||||
});
|
||||
let (codegen_results, outputs) = match CodegenResults::deserialize_rlink(sess, rlink_data) {
|
||||
Ok((codegen, outputs)) => (codegen, outputs),
|
||||
Err(err) => {
|
||||
match err {
|
||||
CodegenErrors::WrongFileType => sess.emit_fatal(RLinkWrongFileType),
|
||||
CodegenErrors::EmptyVersionNumber => sess.emit_fatal(RLinkEmptyVersionNumber),
|
||||
CodegenErrors::WrongFileType => dcx.emit_fatal(RLinkWrongFileType),
|
||||
CodegenErrors::EmptyVersionNumber => dcx.emit_fatal(RLinkEmptyVersionNumber),
|
||||
CodegenErrors::EncodingVersionMismatch { version_array, rlink_version } => sess
|
||||
.dcx()
|
||||
.emit_fatal(RLinkEncodingVersionMismatch { version_array, rlink_version }),
|
||||
CodegenErrors::RustcVersionMismatch { rustc_version } => {
|
||||
sess.emit_fatal(RLinkRustcVersionMismatch {
|
||||
dcx.emit_fatal(RLinkRustcVersionMismatch {
|
||||
rustc_version,
|
||||
current_version: sess.cfg_version,
|
||||
})
|
||||
@ -664,7 +666,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
|
||||
let result = compiler.codegen_backend.link(sess, codegen_results, &outputs);
|
||||
abort_on_err(result, sess);
|
||||
} else {
|
||||
sess.emit_fatal(RlinkNotAFile {})
|
||||
dcx.emit_fatal(RlinkNotAFile {})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,8 +546,8 @@ impl<G: EmissionGuarantee> Drop for DiagnosticBuilder<'_, G> {
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! struct_span_err {
|
||||
($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
||||
$session.struct_span_err_with_code(
|
||||
($dcx:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
||||
$dcx.struct_span_err_with_code(
|
||||
$span,
|
||||
format!($($message)*),
|
||||
$crate::error_code!($code),
|
||||
|
@ -980,10 +980,22 @@ impl DiagCtxt {
|
||||
self.struct_span_bug(span, msg).emit()
|
||||
}
|
||||
|
||||
/// For documentation on this, see `Session::span_delayed_bug`.
|
||||
/// Ensures that compilation cannot succeed.
|
||||
///
|
||||
/// If this function has been called but no errors have been emitted and
|
||||
/// compilation succeeds, it will cause an internal compiler error (ICE).
|
||||
///
|
||||
/// This can be used in code paths that should never run on successful compilations.
|
||||
/// For example, it can be used to create an [`ErrorGuaranteed`]
|
||||
/// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
|
||||
/// directly).
|
||||
///
|
||||
/// If no span is available, use [`DUMMY_SP`].
|
||||
///
|
||||
/// [`DUMMY_SP`]: rustc_span::DUMMY_SP
|
||||
///
|
||||
/// Note: this function used to be called `delay_span_bug`. It was renamed
|
||||
/// to match similar functions like `span_bug`, `span_err`, etc.
|
||||
/// to match similar functions like `span_err`, `span_warn`, etc.
|
||||
#[track_caller]
|
||||
pub fn span_delayed_bug(
|
||||
&self,
|
||||
|
@ -797,13 +797,13 @@ impl SyntaxExtension {
|
||||
let const_stability = attr::find_const_stability(sess, attrs, span);
|
||||
let body_stability = attr::find_body_stability(sess, attrs);
|
||||
if let Some((_, sp)) = const_stability {
|
||||
sess.emit_err(errors::MacroConstStability {
|
||||
sess.dcx().emit_err(errors::MacroConstStability {
|
||||
span: sp,
|
||||
head_span: sess.source_map().guess_head_span(span),
|
||||
});
|
||||
}
|
||||
if let Some((_, sp)) = body_stability {
|
||||
sess.emit_err(errors::MacroBodyStability {
|
||||
sess.dcx().emit_err(errors::MacroBodyStability {
|
||||
span: sp,
|
||||
head_span: sess.source_map().guess_head_span(span),
|
||||
});
|
||||
|
@ -51,7 +51,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
|
||||
let name = match mi.ident() {
|
||||
Some(ident) if mi.is_word() => ident.name,
|
||||
Some(ident) => {
|
||||
sess.emit_err(MalformedFeatureAttribute {
|
||||
sess.dcx().emit_err(MalformedFeatureAttribute {
|
||||
span: mi.span(),
|
||||
help: MalformedFeatureAttributeHelp::Suggestion {
|
||||
span: mi.span(),
|
||||
@ -61,7 +61,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
|
||||
continue;
|
||||
}
|
||||
None => {
|
||||
sess.emit_err(MalformedFeatureAttribute {
|
||||
sess.dcx().emit_err(MalformedFeatureAttribute {
|
||||
span: mi.span(),
|
||||
help: MalformedFeatureAttributeHelp::Label { span: mi.span() },
|
||||
});
|
||||
@ -71,7 +71,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
|
||||
|
||||
// If the declared feature has been removed, issue an error.
|
||||
if let Some(f) = REMOVED_FEATURES.iter().find(|f| name == f.feature.name) {
|
||||
sess.emit_err(FeatureRemoved {
|
||||
sess.dcx().emit_err(FeatureRemoved {
|
||||
span: mi.span(),
|
||||
reason: f.reason.map(|reason| FeatureRemovedReason { reason }),
|
||||
});
|
||||
@ -90,7 +90,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
|
||||
// issue an error.
|
||||
if let Some(allowed) = sess.opts.unstable_opts.allow_features.as_ref() {
|
||||
if allowed.iter().all(|f| name.as_str() != f) {
|
||||
sess.emit_err(FeatureNotAllowed { span: mi.span(), name });
|
||||
sess.dcx().emit_err(FeatureNotAllowed { span: mi.span(), name });
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -415,7 +415,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
// N.B., this is intentionally not part of the visit_expr() function
|
||||
// in order for filter_map_expr() to be able to avoid this check
|
||||
if let Some(attr) = expr.attrs().iter().find(|a| is_cfg(a)) {
|
||||
self.sess.emit_err(RemoveExprNotSupported { span: attr.span });
|
||||
self.sess.dcx().emit_err(RemoveExprNotSupported { span: attr.span });
|
||||
}
|
||||
|
||||
self.process_cfg_attrs(expr);
|
||||
@ -427,21 +427,21 @@ pub fn parse_cfg<'a>(meta_item: &'a MetaItem, sess: &Session) -> Option<&'a Meta
|
||||
let span = meta_item.span;
|
||||
match meta_item.meta_item_list() {
|
||||
None => {
|
||||
sess.emit_err(InvalidCfg::NotFollowedByParens { span });
|
||||
sess.dcx().emit_err(InvalidCfg::NotFollowedByParens { span });
|
||||
None
|
||||
}
|
||||
Some([]) => {
|
||||
sess.emit_err(InvalidCfg::NoPredicate { span });
|
||||
sess.dcx().emit_err(InvalidCfg::NoPredicate { span });
|
||||
None
|
||||
}
|
||||
Some([_, .., l]) => {
|
||||
sess.emit_err(InvalidCfg::MultiplePredicates { span: l.span() });
|
||||
sess.dcx().emit_err(InvalidCfg::MultiplePredicates { span: l.span() });
|
||||
None
|
||||
}
|
||||
Some([single]) => match single.meta_item() {
|
||||
Some(meta_item) => Some(meta_item),
|
||||
None => {
|
||||
sess.emit_err(InvalidCfg::PredicateLiteral { span: single.span() });
|
||||
sess.dcx().emit_err(InvalidCfg::PredicateLiteral { span: single.span() });
|
||||
None
|
||||
}
|
||||
},
|
||||
|
@ -435,7 +435,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
invocations = mem::take(&mut undetermined_invocations);
|
||||
force = !mem::replace(&mut progress, false);
|
||||
if force && self.monotonic {
|
||||
self.cx.sess.span_delayed_bug(
|
||||
self.cx.dcx().span_delayed_bug(
|
||||
invocations.last().unwrap().0.span(),
|
||||
"expansion entered force mode without producing any errors",
|
||||
);
|
||||
|
@ -34,7 +34,10 @@ pub(super) fn failed_to_match_macro<'cx>(
|
||||
if try_success_result.is_ok() {
|
||||
// Nonterminal parser recovery might turn failed matches into successful ones,
|
||||
// but for that it must have emitted an error already
|
||||
tracker.cx.sess.span_delayed_bug(sp, "Macro matching returned a success on the second try");
|
||||
tracker
|
||||
.cx
|
||||
.dcx()
|
||||
.span_delayed_bug(sp, "Macro matching returned a success on the second try");
|
||||
}
|
||||
|
||||
if let Some(result) = tracker.result {
|
||||
@ -151,7 +154,7 @@ impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx,
|
||||
Success(_) => {
|
||||
// Nonterminal parser recovery might turn failed matches into successful ones,
|
||||
// but for that it must have emitted an error already
|
||||
self.cx.sess.span_delayed_bug(
|
||||
self.cx.dcx().span_delayed_bug(
|
||||
self.root_span,
|
||||
"should not collect detailed info for successful macro match",
|
||||
);
|
||||
|
@ -260,14 +260,14 @@ impl ModError<'_> {
|
||||
|
||||
let modules = paths.join(" -> ");
|
||||
|
||||
sess.emit_err(ModuleCircular { span, modules })
|
||||
sess.dcx().emit_err(ModuleCircular { span, modules })
|
||||
}
|
||||
ModError::ModInBlock(ident) => sess.emit_err(ModuleInBlock {
|
||||
ModError::ModInBlock(ident) => sess.dcx().emit_err(ModuleInBlock {
|
||||
span,
|
||||
name: ident.map(|name| ModuleInBlockName { span, name }),
|
||||
}),
|
||||
ModError::FileNotFound(name, default_path, secondary_path) => {
|
||||
sess.emit_err(ModuleFileNotFound {
|
||||
sess.dcx().emit_err(ModuleFileNotFound {
|
||||
span,
|
||||
name,
|
||||
default_path: default_path.display().to_string(),
|
||||
@ -275,7 +275,7 @@ impl ModError<'_> {
|
||||
})
|
||||
}
|
||||
ModError::MultipleCandidates(name, default_path, secondary_path) => {
|
||||
sess.emit_err(ModuleMultipleCandidates {
|
||||
sess.dcx().emit_err(ModuleMultipleCandidates {
|
||||
span,
|
||||
name,
|
||||
default_path: default_path.display().to_string(),
|
||||
|
@ -61,7 +61,7 @@ impl base::BangProcMacro for BangProcMacro {
|
||||
let strategy = exec_strategy(ecx);
|
||||
let server = proc_macro_server::Rustc::new(ecx);
|
||||
self.client.run(&strategy, server, input, proc_macro_backtrace).map_err(|e| {
|
||||
ecx.sess.emit_err(errors::ProcMacroPanicked {
|
||||
ecx.dcx().emit_err(errors::ProcMacroPanicked {
|
||||
span,
|
||||
message: e
|
||||
.as_str()
|
||||
@ -180,7 +180,7 @@ impl MultiItemModifier for DeriveProcMacro {
|
||||
|
||||
// fail if there have been errors emitted
|
||||
if ecx.dcx().err_count() > error_count_before {
|
||||
ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span });
|
||||
ecx.dcx().emit_err(errors::ProcMacroDeriveTokens { span });
|
||||
}
|
||||
|
||||
ExpandResult::Ready(items)
|
||||
|
@ -48,7 +48,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
}
|
||||
|
||||
if unbounds.len() > 1 {
|
||||
tcx.sess.emit_err(errors::MultipleRelaxedDefaultBounds {
|
||||
tcx.dcx().emit_err(errors::MultipleRelaxedDefaultBounds {
|
||||
spans: unbounds.iter().map(|ptr| ptr.span).collect(),
|
||||
});
|
||||
}
|
||||
@ -64,7 +64,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
}
|
||||
}
|
||||
// There was a `?Trait` bound, but it was not `?Sized`; warn.
|
||||
tcx.sess.span_warn(
|
||||
tcx.dcx().span_warn(
|
||||
unbound.span,
|
||||
"relaxing a default bound only does something for `?Sized`; \
|
||||
all other traits are not bound by default",
|
||||
@ -289,7 +289,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
.expect("missing associated item");
|
||||
|
||||
if !assoc_item.visibility(tcx).is_accessible_from(def_scope, tcx) {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(
|
||||
binding.span,
|
||||
format!("{} `{}` is private", assoc_item.kind, binding.item_name),
|
||||
@ -303,7 +303,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
dup_bindings
|
||||
.entry(assoc_item.def_id)
|
||||
.and_modify(|prev_span| {
|
||||
tcx.sess.emit_err(errors::ValueOfAssociatedStructAlreadySpecified {
|
||||
tcx.dcx().emit_err(errors::ValueOfAssociatedStructAlreadySpecified {
|
||||
span: binding.span,
|
||||
prev_span: *prev_span,
|
||||
item_name: binding.item_name,
|
||||
@ -332,7 +332,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
.into(),
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
if !emitted_bad_param_err {
|
||||
tcx.sess.emit_err(
|
||||
tcx.dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationIllegalParam::Type {
|
||||
span: path_span,
|
||||
param_span: tcx.def_span(param.def_id),
|
||||
@ -352,7 +352,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
}
|
||||
ty::GenericParamDefKind::Const { .. } => {
|
||||
if !emitted_bad_param_err {
|
||||
tcx.sess.emit_err(
|
||||
tcx.dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationIllegalParam::Const {
|
||||
span: path_span,
|
||||
param_span: tcx.def_span(param.def_id),
|
||||
@ -385,7 +385,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
{
|
||||
alias_ty
|
||||
} else {
|
||||
return Err(self.tcx().sess.emit_err(
|
||||
return Err(self.tcx().dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationOnNonRpitit {
|
||||
span: binding.span,
|
||||
ty: tcx.liberate_late_bound_regions(assoc_item.def_id, output),
|
||||
@ -452,7 +452,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
late_bound_in_ty,
|
||||
|br_name| {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
binding.span,
|
||||
E0582,
|
||||
"binding for associated type `{}` references {}, \
|
||||
@ -467,7 +467,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
|
||||
match binding.kind {
|
||||
ConvertedBindingKind::Equality(..) if let ty::AssocKind::Fn = assoc_kind => {
|
||||
return Err(self.tcx().sess.emit_err(
|
||||
return Err(self.tcx().dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationEqualityBound { span: binding.span },
|
||||
));
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
return;
|
||||
}
|
||||
|
||||
self.tcx().sess.emit_err(MissingTypeParams {
|
||||
self.tcx().dcx().emit_err(MissingTypeParams {
|
||||
span,
|
||||
def_span: self.tcx().def_span(def_id),
|
||||
span_snippet: self.tcx().sess.source_map().span_to_snippet(span).ok(),
|
||||
@ -94,7 +94,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
|
||||
if is_impl {
|
||||
let trait_name = self.tcx().def_path_str(trait_def_id);
|
||||
self.tcx().sess.emit_err(ManualImplementation { span, trait_name });
|
||||
self.tcx().dcx().emit_err(ManualImplementation { span, trait_name });
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
|
||||
if is_dummy {
|
||||
err.label = Some(errors::AssocItemNotFoundLabel::NotFound { span });
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
let all_candidate_names: Vec<_> = all_candidates()
|
||||
@ -159,7 +159,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
assoc_kind: assoc_kind_str,
|
||||
suggested_name,
|
||||
});
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
// If we didn't find a good item in the supertraits (or couldn't get
|
||||
@ -224,10 +224,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
assoc_kind: assoc_kind_str,
|
||||
suggested_name,
|
||||
});
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
let mut err = tcx.sess.create_err(err);
|
||||
let mut err = tcx.dcx().create_err(err);
|
||||
if suggest_constraining_type_param(
|
||||
tcx,
|
||||
generics,
|
||||
@ -249,7 +249,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
}
|
||||
return err.emit();
|
||||
}
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
err.label = Some(errors::AssocItemNotFoundLabel::NotFound { span: assoc_name.span });
|
||||
}
|
||||
|
||||
tcx.sess.emit_err(err)
|
||||
tcx.dcx().emit_err(err)
|
||||
}
|
||||
|
||||
fn complain_about_assoc_kind_mismatch(
|
||||
@ -327,7 +327,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
(ident.span, None, assoc_kind, assoc_item.kind)
|
||||
};
|
||||
|
||||
tcx.sess.emit_err(errors::AssocKindMismatch {
|
||||
tcx.dcx().emit_err(errors::AssocKindMismatch {
|
||||
span,
|
||||
expected: super::assoc_kind_str(expected),
|
||||
got: super::assoc_kind_str(got),
|
||||
@ -346,7 +346,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
span: Span,
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx().sess,
|
||||
self.tcx().dcx(),
|
||||
name.span,
|
||||
E0034,
|
||||
"multiple applicable items in scope"
|
||||
@ -445,7 +445,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
};
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
name.span,
|
||||
E0220,
|
||||
"associated type `{name}` not found for `{self_ty}` in the current scope"
|
||||
@ -536,7 +536,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
bounds.sort();
|
||||
bounds.dedup();
|
||||
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
let mut err = tcx.dcx().struct_span_err(
|
||||
name.span,
|
||||
format!("the associated type `{name}` exists for `{self_ty}`, but its trait bounds were not satisfied")
|
||||
);
|
||||
@ -697,7 +697,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
|
||||
trait_bound_spans.sort();
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
trait_bound_spans,
|
||||
E0191,
|
||||
"the value of the associated type{} {} must be specified",
|
||||
@ -852,7 +852,7 @@ pub fn prohibit_assoc_ty_binding(
|
||||
span: Span,
|
||||
segment: Option<(&hir::PathSegment<'_>, Span)>,
|
||||
) {
|
||||
tcx.sess.emit_err(AssocTypeBindingNotAllowed {
|
||||
tcx.dcx().emit_err(AssocTypeBindingNotAllowed {
|
||||
span,
|
||||
fn_trait_expansion: if let Some((segment, span)) = segment
|
||||
&& segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar
|
||||
|
@ -28,7 +28,7 @@ fn generic_arg_mismatch_err(
|
||||
) -> ErrorGuaranteed {
|
||||
let sess = tcx.sess;
|
||||
let mut err = struct_span_err!(
|
||||
sess,
|
||||
tcx.dcx(),
|
||||
arg.span(),
|
||||
E0747,
|
||||
"{} provided when a {} was expected",
|
||||
@ -650,7 +650,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
|
||||
if position == GenericArgPosition::Value
|
||||
&& args.num_lifetime_params() != param_counts.lifetimes
|
||||
{
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0794, "{}", msg);
|
||||
let mut err = struct_span_err!(tcx.dcx(), span, E0794, "{}", msg);
|
||||
err.span_note(span_late, note);
|
||||
err.emit();
|
||||
} else {
|
||||
|
@ -97,7 +97,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let msg = "trait objects must include the `dyn` keyword";
|
||||
let label = "add `dyn` keyword before this trait";
|
||||
let mut diag =
|
||||
rustc_errors::struct_span_err!(tcx.sess, self_ty.span, E0782, "{}", msg);
|
||||
rustc_errors::struct_span_err!(tcx.dcx(), self_ty.span, E0782, "{}", msg);
|
||||
if self_ty.span.can_be_used_for_suggestions() {
|
||||
diag.multipart_suggestion_verbose(
|
||||
label,
|
||||
|
@ -564,7 +564,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
&& generics.has_self
|
||||
&& !tcx.has_attr(def_id, sym::const_trait)
|
||||
{
|
||||
let e = tcx.sess.emit_err(crate::errors::ConstBoundForNonConstTrait { span });
|
||||
let e = tcx.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait { span });
|
||||
arg_count.correct =
|
||||
Err(GenericArgCountMismatch { reported: Some(e), invalid_args: vec![] });
|
||||
}
|
||||
@ -748,7 +748,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
// since we should have emitten an error for them earlier, and they will
|
||||
// not be well-formed!
|
||||
if polarity == ty::ImplPolarity::Negative {
|
||||
self.tcx().sess.span_delayed_bug(
|
||||
self.tcx().dcx().span_delayed_bug(
|
||||
binding.span,
|
||||
"negative trait bounds should not have bindings",
|
||||
);
|
||||
@ -863,7 +863,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
traits: &[String],
|
||||
name: Symbol,
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err = struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type");
|
||||
let mut err = struct_span_err!(self.tcx().dcx(), span, E0223, "ambiguous associated type");
|
||||
if self
|
||||
.tcx()
|
||||
.resolutions(())
|
||||
@ -1079,7 +1079,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
|
||||
let assoc_kind_str = assoc_kind_str(assoc_kind);
|
||||
let ty_param_name = &ty_param_name.to_string();
|
||||
let mut err = tcx.sess.create_err(crate::errors::AmbiguousAssocItem {
|
||||
let mut err = tcx.dcx().create_err(crate::errors::AmbiguousAssocItem {
|
||||
span,
|
||||
assoc_kind: assoc_kind_str,
|
||||
assoc_name,
|
||||
@ -1312,7 +1312,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
// trait reference.
|
||||
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
|
||||
// A cycle error occurred, most likely.
|
||||
let guar = tcx.sess.span_delayed_bug(span, "expected cycle error");
|
||||
let guar = tcx.dcx().span_delayed_bug(span, "expected cycle error");
|
||||
return Err(guar);
|
||||
};
|
||||
|
||||
@ -1339,10 +1339,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let reported = if variant_resolution.is_some() {
|
||||
// Variant in type position
|
||||
let msg = format!("expected type, found variant `{assoc_ident}`");
|
||||
tcx.sess.span_err(span, msg)
|
||||
tcx.dcx().span_err(span, msg)
|
||||
} else if qself_ty.is_enum() {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
assoc_ident.span,
|
||||
E0599,
|
||||
"no variant named `{}` found for enum `{}`",
|
||||
@ -1383,7 +1383,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
} else if let ty::Alias(ty::Opaque, alias_ty) = qself_ty.kind() {
|
||||
// `<impl Trait as OtherTrait>::Assoc` makes no sense.
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(alias_ty.def_id),
|
||||
E0667,
|
||||
"`impl Trait` is not allowed in path parameters"
|
||||
@ -1643,7 +1643,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let kind = tcx.def_kind_descr(kind, item);
|
||||
let msg = format!("{kind} `{name}` is private");
|
||||
let def_span = tcx.def_span(item);
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err_with_code(span, msg, rustc_errors::error_code!(E0624))
|
||||
.span_label(span, format!("private {kind}"))
|
||||
.span_label(def_span, format!("{kind} defined here"))
|
||||
@ -1878,7 +1878,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let last_span = *arg_spans.last().unwrap();
|
||||
let span: MultiSpan = arg_spans.into();
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx().sess,
|
||||
self.tcx().dcx(),
|
||||
span,
|
||||
E0109,
|
||||
"{kind} arguments are not allowed on {this_type}",
|
||||
@ -2199,7 +2199,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
// `AlwaysApplicable` impl needs a `T: ?Sized` bound for
|
||||
// this to compile if we were to normalize here.
|
||||
if forbid_generic && ty.has_param() {
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
let mut err = tcx.dcx().struct_span_err(
|
||||
path.span,
|
||||
"generic `Self` types are currently not permitted in anonymous constants",
|
||||
);
|
||||
@ -2260,7 +2260,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
Res::Err => {
|
||||
let e = self
|
||||
.tcx()
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(path.span, "path with `Res::Err` but no error emitted");
|
||||
self.set_tainted_by_errors(e);
|
||||
Ty::new_error(self.tcx(), e)
|
||||
@ -2443,7 +2443,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
} else {
|
||||
(ty, None)
|
||||
};
|
||||
tcx.sess.emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
|
||||
tcx.dcx().emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
|
||||
|
||||
ty
|
||||
}
|
||||
@ -2629,7 +2629,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
|
||||
self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
decl.output.span(),
|
||||
E0581,
|
||||
"return type references {}, which is not constrained by the fn input types",
|
||||
@ -2751,7 +2751,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
// error.
|
||||
let r = derived_region_bounds[0];
|
||||
if derived_region_bounds[1..].iter().any(|r1| r != *r1) {
|
||||
tcx.sess.emit_err(AmbiguousLifetimeBound { span });
|
||||
tcx.dcx().emit_err(AmbiguousLifetimeBound { span });
|
||||
}
|
||||
Some(r)
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let first_trait = ®ular_traits[0];
|
||||
let additional_trait = ®ular_traits[1];
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
additional_trait.bottom().1,
|
||||
E0225,
|
||||
"only auto traits can be used as additional traits in a trait object"
|
||||
@ -126,7 +126,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
.find(|&trait_ref| tcx.is_trait_alias(trait_ref))
|
||||
.map(|trait_ref| tcx.def_span(trait_ref));
|
||||
let reported =
|
||||
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
|
||||
tcx.dcx().emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
|
||||
return Ty::new_error(tcx, reported);
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
if references_self {
|
||||
let def_id = i.bottom().0.def_id();
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
i.bottom().1,
|
||||
E0038,
|
||||
"the {} `{}` cannot be made into an object",
|
||||
@ -326,7 +326,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
false
|
||||
});
|
||||
if references_self {
|
||||
let guar = tcx.sess.span_delayed_bug(
|
||||
let guar = tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
"trait object projection bounds reference `Self`",
|
||||
);
|
||||
@ -375,7 +375,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
} else {
|
||||
self.re_infer(None, span).unwrap_or_else(|| {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0228,
|
||||
"the lifetime bound for this object type cannot be deduced \
|
||||
|
@ -249,7 +249,7 @@ pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Spa
|
||||
Limit(0) => Limit(2),
|
||||
limit => limit * 2,
|
||||
};
|
||||
tcx.sess.emit_err(AutoDerefReachedRecursionLimit {
|
||||
tcx.dcx().emit_err(AutoDerefReachedRecursionLimit {
|
||||
span,
|
||||
ty,
|
||||
suggested_limit,
|
||||
|
@ -38,7 +38,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
||||
Some(true) => (),
|
||||
Some(false) => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0570,
|
||||
"`{abi}` is not a supported ABI for the current target",
|
||||
@ -59,7 +59,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
||||
// This ABI is only allowed on function pointers
|
||||
if abi == Abi::CCmseNonSecureCall {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0781,
|
||||
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
|
||||
@ -126,7 +126,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||
for field in &def.non_enum_variant().fields {
|
||||
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
|
||||
else {
|
||||
tcx.sess.span_delayed_bug(span, "could not normalize field type");
|
||||
tcx.dcx().span_delayed_bug(span, "could not normalize field type");
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -136,7 +136,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||
Some(Node::Field(field)) => (field.span, field.ty.span),
|
||||
_ => unreachable!("mir field has to correspond to hir field"),
|
||||
};
|
||||
tcx.sess.emit_err(errors::InvalidUnionField {
|
||||
tcx.dcx().emit_err(errors::InvalidUnionField {
|
||||
field_span,
|
||||
sugg: errors::InvalidUnionFieldSuggestion {
|
||||
lo: ty_span.shrink_to_lo(),
|
||||
@ -147,7 +147,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
||||
return false;
|
||||
} 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.
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(span, "we should never accept maybe-dropping union fields");
|
||||
}
|
||||
}
|
||||
@ -173,12 +173,12 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
if matches!(tcx.def_kind(def_id), DefKind::Static(_)
|
||||
if tcx.def_kind(tcx.local_parent(def_id)) == DefKind::ForeignMod) =>
|
||||
{
|
||||
tcx.sess.emit_err(errors::TooLargeStatic { span });
|
||||
tcx.dcx().emit_err(errors::TooLargeStatic { span });
|
||||
return;
|
||||
}
|
||||
// Generic statics are rejected, but we still reach this case.
|
||||
Err(e) => {
|
||||
tcx.sess.span_delayed_bug(span, format!("{e:?}"));
|
||||
tcx.dcx().span_delayed_bug(span, format!("{e:?}"));
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -201,7 +201,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||
let item = tcx.hir().item(id);
|
||||
let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else {
|
||||
tcx.sess.span_delayed_bug(item.span, "expected opaque item");
|
||||
tcx.dcx().span_delayed_bug(item.span, "expected opaque item");
|
||||
return;
|
||||
};
|
||||
|
||||
@ -310,7 +310,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||
Ok(()) => {}
|
||||
Err(ty_err) => {
|
||||
let ty_err = ty_err.to_string(tcx);
|
||||
return Err(tcx.sess.span_delayed_bug(
|
||||
return Err(tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
|
||||
));
|
||||
@ -435,7 +435,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, *adt_def, *args),
|
||||
_ => true,
|
||||
} {
|
||||
tcx.sess.emit_err(LinkageType { span: tcx.def_span(def_id) });
|
||||
tcx.dcx().emit_err(LinkageType { span: tcx.def_span(def_id) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -554,7 +554,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||
_ => ("type or const", "types or consts", None),
|
||||
};
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
item.span,
|
||||
E0044,
|
||||
"foreign items may not have {kinds} parameters",
|
||||
@ -652,7 +652,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
||||
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||
} else {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("parent item: {parent_impl:?} not marked as default"),
|
||||
);
|
||||
@ -681,7 +681,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
if let [first_item_ref, ..] = impl_item_refs {
|
||||
let first_item_span = tcx.def_span(first_item_ref);
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
first_item_span,
|
||||
E0749,
|
||||
"negative impls cannot have any items"
|
||||
@ -700,7 +700,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
tcx.associated_item(trait_item_id)
|
||||
} else {
|
||||
// Checked in `associated_item`.
|
||||
tcx.sess.span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait");
|
||||
tcx.dcx().span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait");
|
||||
continue;
|
||||
};
|
||||
match ty_impl_item.kind {
|
||||
@ -795,7 +795,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||
"return position `impl Trait` in traits",
|
||||
)
|
||||
};
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(tcx.def_span(def_id), msg)
|
||||
.note(format!(
|
||||
"specialization behaves in inconsistent and \
|
||||
@ -833,12 +833,12 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||
{
|
||||
let fields = &def.non_enum_variant().fields;
|
||||
if fields.is_empty() {
|
||||
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
return;
|
||||
}
|
||||
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
||||
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
||||
struct_span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous")
|
||||
struct_span_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
||||
.span_label(sp, "SIMD elements must have the same type")
|
||||
.emit();
|
||||
return;
|
||||
@ -851,11 +851,11 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||
};
|
||||
if let Some(len) = len {
|
||||
if len == 0 {
|
||||
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
return;
|
||||
} else if len > MAX_SIMD_LANES {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0075,
|
||||
"SIMD vector cannot have more than {MAX_SIMD_LANES} elements",
|
||||
@ -878,7 +878,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
||||
{ /* struct([f32; 4]) is ok */ }
|
||||
_ => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0077,
|
||||
"SIMD vector element type should be a \
|
||||
@ -901,7 +901,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||
&& pack as u64 != repr_pack.bytes()
|
||||
{
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0634,
|
||||
"type has conflicting packed representation hints"
|
||||
@ -912,7 +912,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||
}
|
||||
if repr.align.is_some() {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0587,
|
||||
"type has conflicting packed and align representation hints"
|
||||
@ -921,7 +921,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
||||
} else {
|
||||
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0588,
|
||||
"packed type cannot transitively contain a `#[repr(align)]` type"
|
||||
@ -1111,7 +1111,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
if def.variants().is_empty() {
|
||||
if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0084,
|
||||
"unsupported representation for zero-variant enum"
|
||||
@ -1150,7 +1150,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||
|
||||
if disr_non_unit || (disr_units && has_non_units) {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(def_id),
|
||||
E0732,
|
||||
"`#[repr(inttype)]` must be specified"
|
||||
@ -1236,7 +1236,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
||||
if discrs[i].1.val == discrs[o].1.val {
|
||||
let err = error.get_or_insert_with(|| {
|
||||
let mut ret = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(adt.did()),
|
||||
E0081,
|
||||
"discriminant value `{}` assigned more than once",
|
||||
@ -1302,7 +1302,7 @@ pub(super) fn check_type_params_are_used<'tcx>(
|
||||
&& let ty::GenericParamDefKind::Type { .. } = param.kind
|
||||
{
|
||||
let span = tcx.def_span(param.def_id);
|
||||
struct_span_err!(tcx.sess, span, E0091, "type parameter `{}` is unused", param.name,)
|
||||
struct_span_err!(tcx.dcx(), span, E0091, "type parameter `{}` is unused", param.name,)
|
||||
.span_label(span, "unused type parameter")
|
||||
.emit();
|
||||
}
|
||||
@ -1320,7 +1320,7 @@ pub(super) fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalModDefId
|
||||
}
|
||||
|
||||
fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) -> ErrorGuaranteed {
|
||||
struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing")
|
||||
struct_span_err!(tcx.dcx(), span, E0733, "recursion in an `async fn` requires boxing")
|
||||
.span_label(span, "recursive `async fn`")
|
||||
.note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`")
|
||||
.note(
|
||||
@ -1342,7 +1342,7 @@ fn opaque_type_cycle_error(
|
||||
opaque_def_id: LocalDefId,
|
||||
span: Span,
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type");
|
||||
let mut err = struct_span_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type");
|
||||
|
||||
let mut label = false;
|
||||
if let Some((def_id, visitor)) = get_owner_return_paths(tcx, opaque_def_id) {
|
||||
|
@ -429,7 +429,7 @@ fn compare_asyncness<'tcx>(
|
||||
}
|
||||
_ => {
|
||||
return Err(tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.create_err(crate::errors::AsyncTraitImplShouldBeAsync {
|
||||
span: tcx.def_span(impl_m.def_id),
|
||||
method_name: trait_m.name,
|
||||
@ -626,7 +626,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
Ok(()) => {}
|
||||
Err(terr) => {
|
||||
let mut diag = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
cause.span(),
|
||||
E0053,
|
||||
"method `{}` has an incompatible return type for trait",
|
||||
@ -759,7 +759,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
remapped_types.insert(def_id, ty::EarlyBinder::bind(ty));
|
||||
}
|
||||
Err(err) => {
|
||||
let reported = tcx.sess.span_delayed_bug(
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
return_span,
|
||||
format!("could not fully resolve: {ty} => {err:?}"),
|
||||
);
|
||||
@ -929,7 +929,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
||||
self.return_span
|
||||
};
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_span_err(
|
||||
return_span,
|
||||
"return type captures more lifetimes than trait definition",
|
||||
@ -943,7 +943,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
||||
.emit()
|
||||
}
|
||||
_ => {
|
||||
self.tcx.sess.span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
||||
}
|
||||
};
|
||||
return Err(guar);
|
||||
@ -973,7 +973,7 @@ fn report_trait_method_mismatch<'tcx>(
|
||||
extract_spans_for_error_reporting(infcx, terr, &cause, impl_m, trait_m);
|
||||
|
||||
let mut diag = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_err_span,
|
||||
E0053,
|
||||
"method `{}` has an incompatible type for trait",
|
||||
@ -1134,7 +1134,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
|
||||
}
|
||||
}
|
||||
let reported = tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.create_err(LifetimesOrBoundsMismatchOnTrait {
|
||||
span,
|
||||
item_kind: assoc_item_kind_str(&impl_m),
|
||||
@ -1218,7 +1218,7 @@ fn compare_self_type<'tcx>(
|
||||
let self_descr = self_string(impl_m);
|
||||
let impl_m_span = tcx.def_span(impl_m.def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_m_span,
|
||||
E0185,
|
||||
"method `{}` has a `{}` declaration in the impl, but not in the trait",
|
||||
@ -1238,7 +1238,7 @@ fn compare_self_type<'tcx>(
|
||||
let self_descr = self_string(trait_m);
|
||||
let impl_m_span = tcx.def_span(impl_m.def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_m_span,
|
||||
E0186,
|
||||
"method `{}` has a `{}` declaration in the trait, but not in the impl",
|
||||
@ -1303,7 +1303,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
// inheriting the generics from will also have mismatched arguments, and
|
||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||
if trait_.is_impl_trait_in_trait() {
|
||||
return Err(tcx.sess.span_delayed_bug(
|
||||
return Err(tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||
));
|
||||
@ -1371,7 +1371,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
let spans = arg_spans(impl_.kind, impl_item.generics);
|
||||
let span = spans.first().copied();
|
||||
|
||||
let mut err = tcx.sess.struct_span_err_with_code(
|
||||
let mut err = tcx.dcx().struct_span_err_with_code(
|
||||
spans,
|
||||
format!(
|
||||
"{} `{}` has {} {kind} parameter{} but its trait \
|
||||
@ -1464,7 +1464,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
.unwrap_or_else(|| tcx.def_span(impl_m.def_id));
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_span,
|
||||
E0050,
|
||||
"method `{}` has {} but the declaration in trait `{}` has {}",
|
||||
@ -1531,7 +1531,7 @@ fn compare_synthetic_generics<'tcx>(
|
||||
let impl_span = tcx.def_span(impl_def_id);
|
||||
let trait_span = tcx.def_span(trait_def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_span,
|
||||
E0643,
|
||||
"method `{}` has incompatible signature for trait",
|
||||
@ -1690,7 +1690,7 @@ fn compare_generic_param_kinds<'tcx>(
|
||||
let param_trait_span = tcx.def_span(param_trait.def_id);
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
param_impl_span,
|
||||
E0053,
|
||||
"{} `{}` has an incompatible generic parameter for trait `{}`",
|
||||
@ -1837,7 +1837,7 @@ fn compare_const_predicate_entailment<'tcx>(
|
||||
cause.span = ty.span;
|
||||
|
||||
let mut diag = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
cause.span,
|
||||
E0326,
|
||||
"implemented const `{}` has an incompatible type for trait",
|
||||
|
@ -153,7 +153,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
||||
trait_m_sig.inputs_and_output,
|
||||
));
|
||||
if !ocx.select_all_or_error().is_empty() {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"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);
|
||||
if !errors.is_empty() {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"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.
|
||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (resolution)",
|
||||
);
|
||||
|
@ -34,12 +34,12 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
||||
match tcx.impl_polarity(drop_impl_did) {
|
||||
ty::ImplPolarity::Positive => {}
|
||||
ty::ImplPolarity::Negative => {
|
||||
return Err(tcx.sess.emit_err(errors::DropImplPolarity::Negative {
|
||||
return Err(tcx.dcx().emit_err(errors::DropImplPolarity::Negative {
|
||||
span: tcx.def_span(drop_impl_did),
|
||||
}));
|
||||
}
|
||||
ty::ImplPolarity::Reservation => {
|
||||
return Err(tcx.sess.emit_err(errors::DropImplPolarity::Reservation {
|
||||
return Err(tcx.dcx().emit_err(errors::DropImplPolarity::Reservation {
|
||||
span: tcx.def_span(drop_impl_did),
|
||||
}));
|
||||
}
|
||||
@ -66,7 +66,7 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
||||
// already checked by coherence, but compilation may
|
||||
// not have been terminated.
|
||||
let span = tcx.def_span(drop_impl_did);
|
||||
let reported = tcx.sess.span_delayed_bug(
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("should have been rejected by coherence check: {dtor_self_type}"),
|
||||
);
|
||||
@ -89,7 +89,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
||||
let item_span = tcx.def_span(self_type_did);
|
||||
let self_descr = tcx.def_descr(self_type_did);
|
||||
let mut err =
|
||||
struct_span_err!(tcx.sess, drop_impl_span, E0366, "`Drop` impls cannot be specialized");
|
||||
struct_span_err!(tcx.dcx(), drop_impl_span, E0366, "`Drop` impls cannot be specialized");
|
||||
match arg {
|
||||
ty::util::NotUniqueParam::DuplicateParam(arg) => {
|
||||
err.note(format!("`{arg}` is mentioned multiple times"))
|
||||
@ -155,7 +155,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
|
||||
guar = Some(
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
error.root_obligation.cause.span,
|
||||
E0367,
|
||||
"`Drop` impl requires `{root_predicate}` \
|
||||
@ -187,7 +187,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
};
|
||||
guar = Some(
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
error.origin().span(),
|
||||
E0367,
|
||||
"`Drop` impl requires `{outlives}` \
|
||||
|
@ -96,12 +96,13 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
let main_asyncness = tcx.asyncness(main_def_id);
|
||||
if main_asyncness.is_async() {
|
||||
let asyncness_span = main_fn_asyncness_span(tcx, main_def_id);
|
||||
tcx.sess.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span });
|
||||
tcx.dcx()
|
||||
.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
for attr in tcx.get_attrs(main_def_id, sym::track_caller) {
|
||||
tcx.sess.emit_err(errors::TrackCallerOnMain { span: attr.span, annotated: main_span });
|
||||
tcx.dcx().emit_err(errors::TrackCallerOnMain { span: attr.span, annotated: main_span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
&& !tcx.sess.target.is_like_wasm
|
||||
&& !tcx.sess.opts.actually_rustdoc
|
||||
{
|
||||
tcx.sess.emit_err(errors::TargetFeatureOnMain { main: main_span });
|
||||
tcx.dcx().emit_err(errors::TargetFeatureOnMain { main: main_span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
@ -125,7 +126,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
let return_ty = main_fnsig.output();
|
||||
let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span);
|
||||
let Some(return_ty) = return_ty.no_bound_vars() else {
|
||||
tcx.sess.emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span });
|
||||
tcx.dcx().emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span });
|
||||
return;
|
||||
};
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
@ -180,14 +181,14 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
let main_fn_predicates = tcx.predicates_of(main_def_id);
|
||||
if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() {
|
||||
let generics_param_span = main_fn_generics_params_span(tcx, main_def_id);
|
||||
tcx.sess.emit_err(errors::MainFunctionGenericParameters {
|
||||
tcx.dcx().emit_err(errors::MainFunctionGenericParameters {
|
||||
span: generics_param_span.unwrap_or(main_span),
|
||||
label_span: generics_param_span,
|
||||
});
|
||||
} else if !main_fn_predicates.predicates.is_empty() {
|
||||
// generics may bring in implicit predicates, so we skip this check if generics is present.
|
||||
let generics_where_clauses_span = main_fn_where_clauses_span(tcx, main_def_id);
|
||||
tcx.sess.emit_err(errors::WhereClauseOnMain {
|
||||
tcx.dcx().emit_err(errors::WhereClauseOnMain {
|
||||
span: generics_where_clauses_span.unwrap_or(main_span),
|
||||
generics_span: generics_where_clauses_span,
|
||||
});
|
||||
@ -205,25 +206,25 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
||||
if let hir::ItemKind::Fn(sig, generics, _) = &it.kind {
|
||||
let mut error = false;
|
||||
if !generics.params.is_empty() {
|
||||
tcx.sess.emit_err(errors::StartFunctionParameters { span: generics.span });
|
||||
tcx.dcx().emit_err(errors::StartFunctionParameters { span: generics.span });
|
||||
error = true;
|
||||
}
|
||||
if generics.has_where_clause_predicates {
|
||||
tcx.sess.emit_err(errors::StartFunctionWhere {
|
||||
tcx.dcx().emit_err(errors::StartFunctionWhere {
|
||||
span: generics.where_clause_span,
|
||||
});
|
||||
error = true;
|
||||
}
|
||||
if sig.header.asyncness.is_async() {
|
||||
let span = tcx.def_span(it.owner_id);
|
||||
tcx.sess.emit_err(errors::StartAsync { span: span });
|
||||
tcx.dcx().emit_err(errors::StartAsync { span: span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
let attrs = tcx.hir().attrs(start_id);
|
||||
for attr in attrs {
|
||||
if attr.has_name(sym::track_caller) {
|
||||
tcx.sess.emit_err(errors::StartTrackCaller {
|
||||
tcx.dcx().emit_err(errors::StartTrackCaller {
|
||||
span: attr.span,
|
||||
start: start_span,
|
||||
});
|
||||
@ -235,7 +236,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
||||
&& !tcx.sess.target.is_like_wasm
|
||||
&& !tcx.sess.opts.actually_rustdoc
|
||||
{
|
||||
tcx.sess.emit_err(errors::StartTargetFeature {
|
||||
tcx.dcx().emit_err(errors::StartTargetFeature {
|
||||
span: attr.span,
|
||||
start: start_span,
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ fn equate_intrinsic_type<'tcx>(
|
||||
(own_counts, generics.span)
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function")
|
||||
struct_span_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
|
||||
.span_label(it.span, "expected a function")
|
||||
.emit();
|
||||
return;
|
||||
@ -38,7 +38,7 @@ fn equate_intrinsic_type<'tcx>(
|
||||
|
||||
let gen_count_ok = |found: usize, expected: usize, descr: &str| -> bool {
|
||||
if found != expected {
|
||||
tcx.sess.emit_err(WrongNumberOfGenericArgumentsToIntrinsic {
|
||||
tcx.dcx().emit_err(WrongNumberOfGenericArgumentsToIntrinsic {
|
||||
span,
|
||||
found,
|
||||
expected,
|
||||
@ -117,7 +117,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: DefId) -> hir
|
||||
};
|
||||
|
||||
if has_safe_attr != is_in_list {
|
||||
tcx.sess.struct_span_err(
|
||||
tcx.dcx().struct_span_err(
|
||||
tcx.def_span(intrinsic_id),
|
||||
DiagnosticMessage::from(format!(
|
||||
"intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `{}`",
|
||||
@ -176,7 +176,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
||||
| "umin" => (1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], param(0)),
|
||||
"fence" | "singlethreadfence" => (0, Vec::new(), Ty::new_unit(tcx)),
|
||||
op => {
|
||||
tcx.sess.emit_err(UnrecognizedAtomicOperation { span: it.span, op });
|
||||
tcx.dcx().emit_err(UnrecognizedAtomicOperation { span: it.span, op });
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -460,7 +460,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
||||
}
|
||||
|
||||
other => {
|
||||
tcx.sess.emit_err(UnrecognizedIntrinsicFunction { span: it.span, name: other });
|
||||
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span: it.span, name: other });
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -552,7 +552,7 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
|
||||
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
|
||||
_ => {
|
||||
let msg = format!("unrecognized platform-specific intrinsic function: `{name}`");
|
||||
tcx.sess.struct_span_err(it.span, msg).emit();
|
||||
tcx.dcx().struct_span_err(it.span, msg).emit();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
};
|
||||
let Some(asm_ty) = asm_ty else {
|
||||
let msg = format!("cannot use value of type `{ty}` for inline assembly");
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
err.note(
|
||||
"only integers, floats, SIMD vectors, pointers and function pointers \
|
||||
can be used as arguments for inline assembly",
|
||||
@ -166,7 +166,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
// possibly fail is for SIMD types which don't #[derive(Copy)].
|
||||
if !ty.is_copy_modulo_regions(self.tcx, self.param_env) {
|
||||
let msg = "arguments for inline assembly must be copyable";
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
err.note(format!("`{ty}` does not implement the Copy trait"));
|
||||
err.emit();
|
||||
}
|
||||
@ -183,7 +183,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
if let Some((in_expr, Some(in_asm_ty))) = tied_input {
|
||||
if in_asm_ty != asm_ty {
|
||||
let msg = "incompatible types for asm inout argument";
|
||||
let mut err = self.tcx.sess.struct_span_err(vec![in_expr.span, expr.span], msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(vec![in_expr.span, expr.span], msg);
|
||||
|
||||
let in_expr_ty = (self.get_operand_ty)(in_expr);
|
||||
err.span_label(in_expr.span, format!("type `{in_expr_ty}`"));
|
||||
@ -207,7 +207,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
let supported_tys = reg_class.supported_types(asm_arch);
|
||||
let Some((_, feature)) = supported_tys.iter().find(|&&(t, _)| t == asm_ty) else {
|
||||
let msg = format!("type `{ty}` cannot be used with this register class");
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
let supported_tys: Vec<_> = supported_tys.iter().map(|(t, _)| t.to_string()).collect();
|
||||
err.note(format!(
|
||||
"register class `{}` supports these types: {}",
|
||||
@ -234,7 +234,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
if let Some(feature) = feature {
|
||||
if !target_features.contains(feature) {
|
||||
let msg = format!("`{feature}` target feature is not enabled");
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
err.note(format!(
|
||||
"this is required to use type `{}` with register class `{}`",
|
||||
ty,
|
||||
@ -287,7 +287,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
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 Some(asm_arch) = self.tcx.sess.asm_arch else {
|
||||
self.tcx.sess.span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
||||
return;
|
||||
};
|
||||
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
||||
@ -318,7 +318,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
op.is_clobber(),
|
||||
) {
|
||||
let msg = format!("cannot use register `{}`: {}", reg.name(), msg);
|
||||
self.tcx.sess.struct_span_err(*op_sp, msg).emit();
|
||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -357,7 +357,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
reg_class.name(),
|
||||
feature
|
||||
);
|
||||
self.tcx.sess.struct_span_err(*op_sp, msg).emit();
|
||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
||||
// register isn't enabled, don't do more checks
|
||||
continue;
|
||||
}
|
||||
@ -371,7 +371,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
.intersperse(", ")
|
||||
.collect::<String>(),
|
||||
);
|
||||
self.tcx.sess.struct_span_err(*op_sp, msg).emit();
|
||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
||||
// register isn't enabled, don't do more checks
|
||||
continue;
|
||||
}
|
||||
@ -450,7 +450,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
||||
ty::FnDef(..) => {}
|
||||
_ => {
|
||||
let mut err =
|
||||
self.tcx.sess.struct_span_err(*op_sp, "invalid `sym` operand");
|
||||
self.tcx.dcx().struct_span_err(*op_sp, "invalid `sym` operand");
|
||||
err.span_label(
|
||||
self.tcx.def_span(anon_const.def_id),
|
||||
format!("is {} `{}`", ty.kind().article(), ty),
|
||||
|
@ -144,7 +144,7 @@ fn get_owner_return_paths(
|
||||
// FIXME: Move this to a more appropriate place.
|
||||
pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: Abi) {
|
||||
if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi {
|
||||
tcx.sess.span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block");
|
||||
tcx.dcx().span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block");
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
|
||||
let msg = "statics with a custom `#[link_section]` must be a \
|
||||
simple list of bytes on the wasm target with no \
|
||||
extra levels of indirection such as references";
|
||||
tcx.sess.span_err(tcx.def_span(id), msg);
|
||||
tcx.dcx().span_err(tcx.def_span(id), msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ fn report_forbidden_specialization(tcx: TyCtxt<'_>, impl_item: DefId, parent_imp
|
||||
Err(cname) => errors::ImplNotMarkedDefault::Err { span, ident, cname },
|
||||
};
|
||||
|
||||
tcx.sess.emit_err(err);
|
||||
tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
fn missing_items_err(
|
||||
@ -240,7 +240,7 @@ fn missing_items_err(
|
||||
}
|
||||
}
|
||||
|
||||
tcx.sess.emit_err(errors::MissingTraitItem {
|
||||
tcx.dcx().emit_err(errors::MissingTraitItem {
|
||||
span: tcx.span_of_impl(impl_def_id.to_def_id()).unwrap(),
|
||||
missing_items_msg,
|
||||
missing_trait_item_label,
|
||||
@ -258,7 +258,7 @@ fn missing_items_must_implement_one_of_err(
|
||||
let missing_items_msg =
|
||||
missing_items.iter().map(Ident::to_string).collect::<Vec<_>>().join("`, `");
|
||||
|
||||
tcx.sess.emit_err(errors::MissingOneOfTraitItem {
|
||||
tcx.dcx().emit_err(errors::MissingOneOfTraitItem {
|
||||
span: impl_span,
|
||||
note: annotation_span,
|
||||
missing_items_msg,
|
||||
@ -283,7 +283,7 @@ fn default_body_is_unstable(
|
||||
None => none_note = true,
|
||||
};
|
||||
|
||||
let mut err = tcx.sess.create_err(errors::MissingTraitItemUnstable {
|
||||
let mut err = tcx.dcx().create_err(errors::MissingTraitItemUnstable {
|
||||
span: impl_span,
|
||||
some_note,
|
||||
none_note,
|
||||
@ -526,7 +526,7 @@ fn bad_variant_count<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>, sp: Span, d
|
||||
spans = start.to_vec();
|
||||
many = Some(*end);
|
||||
}
|
||||
tcx.sess.emit_err(errors::TransparentEnumVariant {
|
||||
tcx.dcx().emit_err(errors::TransparentEnumVariant {
|
||||
span: sp,
|
||||
spans,
|
||||
many,
|
||||
@ -545,14 +545,14 @@ fn bad_non_zero_sized_fields<'tcx>(
|
||||
sp: Span,
|
||||
) {
|
||||
if adt.is_enum() {
|
||||
tcx.sess.emit_err(errors::TransparentNonZeroSizedEnum {
|
||||
tcx.dcx().emit_err(errors::TransparentNonZeroSizedEnum {
|
||||
span: sp,
|
||||
spans: field_spans.collect(),
|
||||
field_count,
|
||||
desc: adt.descr(),
|
||||
});
|
||||
} else {
|
||||
tcx.sess.emit_err(errors::TransparentNonZeroSized {
|
||||
tcx.dcx().emit_err(errors::TransparentNonZeroSized {
|
||||
span: sp,
|
||||
spans: field_spans.collect(),
|
||||
field_count,
|
||||
@ -616,7 +616,7 @@ pub fn check_function_signature<'tcx>(
|
||||
cause.span = extract_span_for_error_reporting(tcx, err, &cause, local_id);
|
||||
}
|
||||
let failure_code = cause.as_failure_code_diag(err, cause.span, vec![]);
|
||||
let mut diag = tcx.sess.create_err(failure_code);
|
||||
let mut diag = tcx.dcx().create_err(failure_code);
|
||||
err_ctxt.note_type_err(
|
||||
&mut diag,
|
||||
&cause,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user