Skip to content

Commit eda68d7

Browse files
authored
Rollup merge of rust-lang#101049 - JeanCASPAR:remove-span_fatal-from-ast_lowering, r=davidtwco
Remove span fatal from ast lowering Now the crate `rustc_ast_lowering` is fully migrated to `SessionDiagnostic`. r? `@davidtwco`
2 parents 78e1294 + 79d4f09 commit eda68d7

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-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

+9-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,13 @@ 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+
(start, None, Closed) => {
1268+
self.tcx.sess.emit_err(InclusiveRangeWithNoEnd { span });
1269+
match start {
1270+
Some(..) => hir::LangItem::RangeFrom,
1271+
None => hir::LangItem::RangeFull,
1272+
}
1273+
}
12681274
};
12691275

12701276
let fields = self.arena.alloc_from_iter(

compiler/rustc_ast_lowering/src/lib.rs

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

4042
#[macro_use]
4143
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)