mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-05 09:23:31 +00:00
Avoid some struct_foo(..).emit() chains
These can be replaced with `foo(..)`. Also make the return type of `report_unterminated_block_comment` more precise.
This commit is contained in:
@@ -800,9 +800,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
fn lower_variant(&mut self, item_kind: &ItemKind, v: &Variant) -> hir::Variant<'hir> {
|
||||
if v.ident.name == kw::Underscore && self.tcx.features().unnamed_enum_variants() {
|
||||
// FIXME(#156628): lower unnamed enum variants to HIR.
|
||||
self.dcx()
|
||||
.struct_span_fatal(v.span, "unnamed enum variants are not yet implemented")
|
||||
.emit()
|
||||
self.dcx().span_fatal(v.span, "unnamed enum variants are not yet implemented");
|
||||
}
|
||||
let hir_id = self.lower_node_id(v.id);
|
||||
self.lower_attrs(hir_id, &v.attrs, v.span, Target::Variant);
|
||||
|
||||
@@ -1795,9 +1795,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
|
||||
// FIXME(mgca): make this non-fatal once we have a better way to handle
|
||||
// nested items in invalid `direct_const_arg!()` arguments.
|
||||
self.dcx().struct_span_fatal(span, msg).emit()
|
||||
self.dcx().span_fatal(span, msg)
|
||||
} else {
|
||||
self.dcx().struct_span_err(span, msg).emit()
|
||||
self.dcx().span_err(span, msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2983,9 +2983,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let literal = self.lower_lit(literal, span);
|
||||
|
||||
let kind = if !matches!(literal.node, LitKind::Int(..)) {
|
||||
let err =
|
||||
self.dcx().struct_span_err(expr.span, "negated literal must be an integer");
|
||||
hir::ConstArgKind::Error(err.emit())
|
||||
let err = self.dcx().span_err(expr.span, "negated literal must be an integer");
|
||||
hir::ConstArgKind::Error(err)
|
||||
} else {
|
||||
hir::ConstArgKind::Literal { lit: literal.node, negated: true }
|
||||
};
|
||||
@@ -3389,9 +3388,9 @@ impl UnrepresentableConstArgError {
|
||||
// FIXME(mgca): make this non-fatal once we have a better way to handle
|
||||
// nested items in const args
|
||||
// Issue: https://github.com/rust-lang/rust/issues/154539
|
||||
lowering_context.dcx().struct_span_fatal(self.span, msg).emit()
|
||||
lowering_context.dcx().span_fatal(self.span, msg)
|
||||
} else {
|
||||
lowering_context.dcx().struct_span_err(self.span, msg).emit()
|
||||
lowering_context.dcx().span_err(self.span, msg)
|
||||
};
|
||||
|
||||
ConstArg {
|
||||
|
||||
@@ -1554,7 +1554,7 @@ fn check_scalable_vector(tcx: TyCtxt<'_>, span: Span, def_id: LocalDefId, scalab
|
||||
return;
|
||||
}
|
||||
ScalableElt::ElementCount(..) if fields.len() >= 2 => {
|
||||
tcx.dcx().struct_span_err(span, "scalable vectors cannot have multiple fields").emit();
|
||||
tcx.dcx().span_err(span, "scalable vectors cannot have multiple fields");
|
||||
return;
|
||||
}
|
||||
ScalableElt::Container if fields.is_empty() => {
|
||||
|
||||
@@ -97,12 +97,10 @@ pub(super) fn infer_clauses(
|
||||
} else {
|
||||
"overflow computing implied lifetime bounds".to_string()
|
||||
};
|
||||
tcx.dcx()
|
||||
.struct_span_fatal(
|
||||
clauses_added.iter().map(|id| tcx.def_span(*id)).collect::<Vec<_>>(),
|
||||
msg,
|
||||
)
|
||||
.emit();
|
||||
tcx.dcx().span_fatal(
|
||||
clauses_added.iter().map(|id| tcx.def_span(*id)).collect::<Vec<_>>(),
|
||||
msg,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ fn check_transmute<'tcx>(
|
||||
let normalize = |ty: Unnormalized<'tcx, Ty<'tcx>>| -> Result<Ty<'tcx>, ErrorGuaranteed> {
|
||||
tcx.try_normalize_erasing_regions(typing_env, ty).map_err(|err| {
|
||||
let err = LayoutError::NormalizationFailure(ty.skip_normalization(), err);
|
||||
tcx.dcx().struct_span_err(span, err.to_string()).emit()
|
||||
tcx.dcx().span_err(span, err.to_string())
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -1007,7 +1007,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> {
|
||||
err.emit()
|
||||
}
|
||||
|
||||
fn report_unterminated_block_comment(&self, start: BytePos, doc_style: Option<DocStyle>) {
|
||||
fn report_unterminated_block_comment(&self, start: BytePos, doc_style: Option<DocStyle>) -> ! {
|
||||
let msg = match doc_style {
|
||||
Some(_) => "unterminated block doc-comment",
|
||||
None => "unterminated block comment",
|
||||
|
||||
Reference in New Issue
Block a user