1
Fork 0

rustc_errors: let DiagnosticBuilder::emit return a "guarantee of emission".

This commit is contained in:
Eduard-Mihai Burtescu 2022-01-27 09:44:25 +00:00
parent 0b9d70cf6d
commit b7e95dee65
83 changed files with 842 additions and 471 deletions

View file

@ -1068,8 +1068,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
.emit();
}
}
let ill_formed =
|span| struct_span_err!(self.r.session, span, E0466, "bad macro import").emit();
let ill_formed = |span| {
struct_span_err!(self.r.session, span, E0466, "bad macro import").emit();
};
match attr.meta() {
Some(meta) => match meta.kind {
MetaItemKind::Word => {

View file

@ -3,7 +3,7 @@ use std::ptr;
use rustc_ast::{self as ast, Path};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported};
use rustc_feature::BUILTIN_ATTRIBUTES;
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind};
@ -110,7 +110,7 @@ impl<'a> Resolver<'a> {
&self,
span: Span,
resolution_error: ResolutionError<'_>,
) -> DiagnosticBuilder<'_> {
) -> DiagnosticBuilder<'_, ErrorReported> {
match resolution_error {
ResolutionError::GenericParamsFromOuterFunction(outer_res, has_generic_params) => {
let mut err = struct_span_err!(
@ -624,7 +624,10 @@ impl<'a> Resolver<'a> {
}
}
crate fn report_vis_error(&self, vis_resolution_error: VisResolutionError<'_>) {
crate fn report_vis_error(
&self,
vis_resolution_error: VisResolutionError<'_>,
) -> ErrorReported {
match vis_resolution_error {
VisResolutionError::Relative2018(span, path) => {
let mut err = self.session.struct_span_err(

View file

@ -12,7 +12,9 @@ use rustc_ast::{
};
use rustc_ast_pretty::pprust::path_segment_to_string;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported,
};
use rustc_hir as hir;
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
@ -133,7 +135,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
span: Span,
source: PathSource<'_>,
res: Option<Res>,
) -> (DiagnosticBuilder<'a>, Vec<ImportSuggestion>) {
) -> (DiagnosticBuilder<'a, ErrorReported>, Vec<ImportSuggestion>) {
let ident_span = path.last().map_or(span, |ident| ident.ident.span);
let ns = source.namespace();
let is_expected = &|res| source.is_expected(res);
@ -1817,7 +1819,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
&self,
spans: Vec<Span>,
count: usize,
) -> DiagnosticBuilder<'tcx> {
) -> DiagnosticBuilder<'tcx, ErrorReported> {
struct_span_err!(
self.tcx.sess,
spans,

View file

@ -1572,6 +1572,7 @@ fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: Symbol, orig: Original, shado
name,
orig.kind.desc()
)
.forget_guarantee()
} else {
// shadowing involving a label is only a warning, due to issues with
// labels and lifetimes not being macro-hygienic.

View file

@ -40,7 +40,7 @@ use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::intern::Interned;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported};
use rustc_expand::base::{DeriveResolutions, SyntaxExtension, SyntaxExtensionKind};
use rustc_hir::def::Namespace::*;
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
@ -713,7 +713,7 @@ struct PrivacyError<'a> {
}
struct UseError<'a> {
err: DiagnosticBuilder<'a>,
err: DiagnosticBuilder<'a, ErrorReported>,
/// Candidates which user could `use` to access the missing type.
candidates: Vec<ImportSuggestion>,
/// The `DefId` of the module to place the use-statements in.