Skip to content

Commit e89d4fc

Browse files
committed
remove span_fatal from ast_lowering
1 parent 9845f4c commit e89d4fc

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

compiler/rustc_ast_lowering/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,10 @@ pub struct ArbitraryExpressionInPattern {
327327
#[primary_span]
328328
pub span: Span,
329329
}
330+
331+
#[derive(SessionDiagnostic, Clone, Copy)]
332+
#[diag(ast_lowering::inclusive_range_with_no_end)]
333+
pub struct InclusiveRangeWithNoEnd {
334+
#[primary_span]
335+
pub span: Span,
336+
}

compiler/rustc_ast_lowering/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::errors::{
22
AsyncGeneratorsNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks,
33
BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignemnt,
4-
GeneratorTooManyParameters, NotSupportedForLifetimeBinderAsyncClosure, RustcBoxAttributeError,
5-
UnderscoreExprLhsAssign,
4+
GeneratorTooManyParameters, InclusiveRangeWithNoEnd, NotSupportedForLifetimeBinderAsyncClosure,
5+
RustcBoxAttributeError, UnderscoreExprLhsAssign,
66
};
77
use super::ResolverAstLoweringExt;
88
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
@@ -1264,7 +1264,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12641264
(Some(..), Some(..), HalfOpen) => hir::LangItem::Range,
12651265
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
12661266
(Some(..), Some(..), Closed) => unreachable!(),
1267-
(_, None, Closed) => self.diagnostic().span_fatal(span, "inclusive range with no end"),
1267+
(_, None, Closed) => self.tcx.sess.emit_fatal(InclusiveRangeWithNoEnd { span }),
12681268
};
12691269

12701270
let fields = self.arena.alloc_from_iter(

compiler/rustc_ast_lowering/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#![feature(never_type)]
3636
#![recursion_limit = "256"]
3737
#![allow(rustc::potential_query_instability)]
38+
#![deny(rustc::untranslatable_diagnostic)]
39+
#![deny(rustc::diagnostic_outside_of_impl)]
3840

3941
#[macro_use]
4042
extern crate tracing;

compiler/rustc_error_messages/locales/en-US/ast_lowering.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,5 @@ ast_lowering_not_supported_for_lifetime_binder_async_closure =
129129
130130
ast_lowering_arbitrary_expression_in_pattern =
131131
arbitrary expressions aren't allowed in patterns
132+
133+
ast_lowering_inclusive_range_with_no_end = inclusive range with no end

0 commit comments

Comments
 (0)