Skip to content

Commit 7242198

Browse files
Rollup merge of #157485 - GuillaumeGomez:rename-err-to-diag, r=JonathanBrouwer
Rename `errors.rs` file to `diagnostics.rs` (1/N) `errors.rs` (and sometimes `error.rs`, depends on the crate) are not coherent with their content which can be both errors and lints. However, they're both diagnostics so it would make more sense to rename all of them into `diagnostics.rs`. I only did 3 crates for a start to confirm it's ok to go forward with this. I think it was discussed with @JonathanBrouwer so setting them as reviewer. :3 r? @JonathanBrouwer
2 parents 88eda1a + 100b35f commit 7242198

40 files changed

Lines changed: 367 additions & 308 deletions

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ use rustc_session::errors::feature_err;
99
use rustc_span::{Span, sym};
1010
use rustc_target::asm;
1111

12-
use super::LoweringContext;
13-
use super::errors::{
12+
use crate::diagnostics::{
1413
AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
1514
InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
1615
InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass,
1716
InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister,
1817
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterClassOnlyClobberStable,
1918
RegisterConflict,
2019
};
21-
use crate::{AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode};
20+
use crate::{
21+
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
22+
};
2223

2324
impl<'hir> LoweringContext<'_, 'hir> {
2425
pub(crate) fn lower_inline_asm(

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use rustc_span::symbol::kw;
5656
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
5757

5858
use crate::delegation::generics::{GenericsGenerationResult, GenericsGenerationResults};
59-
use crate::errors::{
59+
use crate::diagnostics::{
6060
CycleInDelegationSignatureResolution, DelegationAttemptedBlockWithDefsDeletion,
6161
DelegationBlockSpecifiedWhenNoParams, UnresolvedDelegationCallee,
6262
};
File renamed without changes.

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ use visit::{Visitor, walk_expr};
1919

2020
mod closure;
2121

22-
use super::errors::{
22+
use crate::diagnostics::{
2323
AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks,
24-
FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody,
25-
MoveExprOnlyInPlainClosures, NeverPatternWithBody, NeverPatternWithGuard,
26-
UnderscoreExprLhsAssign,
24+
FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd,
25+
InvalidLegacyConstGenericArg, MatchArmWithNoBody, MoveExprOnlyInPlainClosures,
26+
NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign, UseConstGenericArg,
27+
YieldInClosure,
2728
};
28-
use super::{
29-
GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt,
29+
use crate::{
30+
AllowReturnTypeNotation, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext,
31+
ParamMode, ResolverAstLoweringExt, TryBlockScope,
3032
};
31-
use crate::errors::{InvalidLegacyConstGenericArg, UseConstGenericArg, YieldInClosure};
32-
use crate::{AllowReturnTypeNotation, ImplTraitPosition, TryBlockScope};
3333

3434
pub(super) struct WillCreateDefIdsVisitor;
3535

compiler/rustc_ast_lowering/src/expr/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_span::Span;
77

88
use super::{LoweringContext, MoveExprInitializerFinder, MoveExprState};
99
use crate::FnDeclKind;
10-
use crate::errors::{ClosureCannotBeStatic, CoroutineTooManyParameters};
10+
use crate::diagnostics::{ClosureCannotBeStatic, CoroutineTooManyParameters};
1111

1212
impl<'hir> LoweringContext<'_, 'hir> {
1313
// Entry point for `ExprKind::Closure`. Plain closures go through

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ use smallvec::{SmallVec, smallvec};
1919
use thin_vec::ThinVec;
2020
use tracing::instrument;
2121

22-
use super::errors::{InvalidAbi, InvalidAbiSuggestion, TupleStructWithDefault, UnionWithDefault};
22+
use super::diagnostics::{
23+
InvalidAbi, InvalidAbiSuggestion, TupleStructWithDefault, UnionWithDefault,
24+
};
2325
use super::stability::{enabled_names, gate_unstable_abi};
2426
use super::{
2527
AstOwner, FnDeclKind, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use smallvec::SmallVec;
7070
use thin_vec::ThinVec;
7171
use tracing::{debug, instrument, trace};
7272

73-
use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
73+
use crate::diagnostics::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
7474
use crate::item::Owners;
7575

7676
macro_rules! arena_vec {
@@ -83,7 +83,7 @@ mod asm;
8383
mod block;
8484
mod contract;
8585
mod delegation;
86-
mod errors;
86+
mod diagnostics;
8787
mod expr;
8888
mod format;
8989
mod index;
@@ -1145,17 +1145,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
11451145
{
11461146
let err = match (&data.inputs[..], &data.output) {
11471147
([_, ..], FnRetTy::Default(_)) => {
1148-
errors::BadReturnTypeNotation::Inputs { span: data.inputs_span }
1148+
diagnostics::BadReturnTypeNotation::Inputs {
1149+
span: data.inputs_span,
1150+
}
11491151
}
11501152
([], FnRetTy::Default(_)) => {
1151-
errors::BadReturnTypeNotation::NeedsDots { span: data.inputs_span }
1153+
diagnostics::BadReturnTypeNotation::NeedsDots {
1154+
span: data.inputs_span,
1155+
}
11521156
}
11531157
// The case `T: Trait<method(..) -> Ret>` is handled in the parser.
11541158
(_, FnRetTy::Ty(ty)) => {
11551159
let span = data.inputs_span.shrink_to_hi().to(ty.span);
1156-
errors::BadReturnTypeNotation::Output {
1160+
diagnostics::BadReturnTypeNotation::Output {
11571161
span,
1158-
suggestion: errors::RTNSuggestion {
1162+
suggestion: diagnostics::RTNSuggestion {
11591163
output: span,
11601164
input: data.inputs_span,
11611165
},
@@ -1226,7 +1230,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12261230
_ => None,
12271231
};
12281232

1229-
let guar = self.dcx().emit_err(errors::MisplacedAssocTyBinding {
1233+
let guar = self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
12301234
span: constraint.span,
12311235
suggestion,
12321236
});
@@ -1529,7 +1533,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15291533
ast::GenericBound::Use(_, span) => Some(span),
15301534
_ => None,
15311535
}) {
1532-
self.tcx.dcx().emit_err(errors::NoPreciseCapturesOnApit { span });
1536+
self.tcx.dcx().emit_err(diagnostics::NoPreciseCapturesOnApit { span });
15331537
}
15341538

15351539
let def_id = self.local_def_id(*def_node_id);
@@ -2123,7 +2127,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21232127
.filter(|_| match source {
21242128
hir::GenericParamSource::Generics => true,
21252129
hir::GenericParamSource::Binder => {
2126-
self.dcx().emit_err(errors::GenericParamDefaultInBinder {
2130+
self.dcx().emit_err(diagnostics::GenericParamDefaultInBinder {
21272131
span: param.span(),
21282132
});
21292133

@@ -2154,7 +2158,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
21542158
.filter(|anon_const| match source {
21552159
hir::GenericParamSource::Generics => true,
21562160
hir::GenericParamSource::Binder => {
2157-
let err = errors::GenericParamDefaultInBinder { span: param.span() };
2161+
let err =
2162+
diagnostics::GenericParamDefaultInBinder { span: param.span() };
21582163
if expr::WillCreateDefIdsVisitor
21592164
.visit_expr(&anon_const.value)
21602165
.is_break()

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use rustc_hir::{self as hir, LangItem, Target};
77
use rustc_middle::span_bug;
88
use rustc_span::{DesugaringKind, Ident, Span, Spanned, respan};
99

10-
use super::errors::{
10+
use crate::diagnostics::{
1111
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
1212
};
13-
use super::{
13+
use crate::{
1414
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
1515
};
1616

compiler/rustc_ast_lowering/src/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
1111
use smallvec::smallvec;
1212
use tracing::{debug, instrument};
1313

14-
use super::errors::{
14+
use crate::diagnostics::{
1515
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
1616
GenericTypeWithParentheses, RTNSuggestion, UseAngleBrackets,
1717
};
18-
use super::{
18+
use crate::{
1919
AllowReturnTypeNotation, GenericArgsCtor, GenericArgsMode, ImplTraitContext, ImplTraitPosition,
2020
LifetimeRes, LoweringContext, ParamMode,
2121
};

0 commit comments

Comments
 (0)