Skip to content

Commit 5155e95

Browse files
authored
Unrolled build for #157752
Rollup merge of #157752 - GuillaumeGomez:rename-err-to-diag-3, r=JonathanBrouwer Rename `errors.rs` file to `diagnostics.rs` (6/N) Follow-up of #157485. r? @JonathanBrouwer
2 parents 8d6b380 + 190a22d commit 5155e95

51 files changed

Lines changed: 411 additions & 342 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_hir_analysis/src/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_span::{ErrorGuaranteed, Span};
77
use rustc_trait_selection::traits::ObligationCtxt;
88
use tracing::{debug, instrument};
99

10-
use crate::errors::AutoDerefReachedRecursionLimit;
10+
use crate::diagnostics::AutoDerefReachedRecursionLimit;
1111
use crate::traits;
1212
use crate::traits::query::evaluate_obligation::InferCtxtExt;
1313

compiler/rustc_hir_analysis/src/check/always_applicable.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_span::sym;
1616
use rustc_trait_selection::regions::InferCtxtRegionExt;
1717
use rustc_trait_selection::traits::{self, ObligationCtxt};
1818

19-
use crate::errors;
19+
use crate::diagnostics;
2020
use crate::hir::def_id::{DefId, LocalDefId};
2121

2222
/// This function confirms that the `Drop` implementation identified by
@@ -42,12 +42,12 @@ pub(crate) fn check_drop_impl(
4242
match tcx.impl_polarity(drop_impl_did) {
4343
ty::ImplPolarity::Positive => {}
4444
ty::ImplPolarity::Negative => {
45-
return Err(tcx.dcx().emit_err(errors::DropImplPolarity::Negative {
45+
return Err(tcx.dcx().emit_err(diagnostics::DropImplPolarity::Negative {
4646
span: tcx.def_span(drop_impl_did),
4747
}));
4848
}
4949
ty::ImplPolarity::Reservation => {
50-
return Err(tcx.dcx().emit_err(errors::DropImplPolarity::Reservation {
50+
return Err(tcx.dcx().emit_err(diagnostics::DropImplPolarity::Reservation {
5151
span: tcx.def_span(drop_impl_did),
5252
}));
5353
}
@@ -393,7 +393,7 @@ fn check_drop_xor_pin_drop<'tcx>(
393393
match (drop_span, pin_drop_span) {
394394
(None, None) => {
395395
if tcx.features().pin_ergonomics() {
396-
return Err(tcx.dcx().emit_err(crate::errors::MissingOneOfTraitItem {
396+
return Err(tcx.dcx().emit_err(crate::diagnostics::MissingOneOfTraitItem {
397397
span: tcx.def_span(drop_impl_did),
398398
note: None,
399399
missing_items_msg: "drop`, `pin_drop".to_string(),
@@ -408,7 +408,7 @@ fn check_drop_xor_pin_drop<'tcx>(
408408
if tcx.adt_def(adt_def_id).is_pin_project() {
409409
let pin_v2_span = rustc_hir::find_attr!(tcx, adt_def_id, PinV2(attr) => *attr);
410410
let adt_name = tcx.item_name(adt_def_id);
411-
return Err(tcx.dcx().emit_err(crate::errors::PinV2WithoutPinDrop {
411+
return Err(tcx.dcx().emit_err(crate::diagnostics::PinV2WithoutPinDrop {
412412
span,
413413
pin_v2_span,
414414
adt_name,
@@ -424,7 +424,7 @@ fn check_drop_xor_pin_drop<'tcx>(
424424
}
425425
}
426426
(Some(drop_span), Some(pin_drop_span)) => {
427-
return Err(tcx.dcx().emit_err(crate::errors::ConflictImplDropAndPinDrop {
427+
return Err(tcx.dcx().emit_err(crate::diagnostics::ConflictImplDropAndPinDrop {
428428
span: tcx.def_span(drop_impl_did),
429429
drop_span,
430430
pin_drop_span,

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use crate::check::wfcheck::{
3838
check_associated_item, check_trait_item, check_type_defn, check_variances_for_type_defn,
3939
check_where_clauses, enter_wf_checking_ctxt,
4040
};
41+
use crate::diagnostics;
4142

4243
fn add_abi_diag_help<T: EmissionGuarantee>(abi: ExternAbi, diag: &mut Diag<'_, T>) {
4344
if let ExternAbi::Cdecl { unwind } = abi {
@@ -95,7 +96,7 @@ pub fn check_custom_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, fn_sig: FnSig<'_>,
9596
if fn_sig.abi() == ExternAbi::Custom {
9697
// Function definitions that use `extern "custom"` must be naked functions.
9798
if !find_attr!(tcx, def_id, Naked(_)) {
98-
tcx.dcx().emit_err(crate::errors::AbiCustomClothedFunction {
99+
tcx.dcx().emit_err(crate::diagnostics::AbiCustomClothedFunction {
99100
span: fn_sig_span,
100101
naked_span: tcx.def_span(def_id).shrink_to_lo(),
101102
});
@@ -181,9 +182,9 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
181182
Some(Node::Field(field)) => (field.span, field.ty.span),
182183
_ => unreachable!("mir field has to correspond to hir field"),
183184
};
184-
tcx.dcx().emit_err(errors::InvalidUnionField {
185+
tcx.dcx().emit_err(diagnostics::InvalidUnionField {
185186
field_span,
186-
sugg: errors::InvalidUnionFieldSuggestion {
187+
sugg: diagnostics::InvalidUnionFieldSuggestion {
187188
lo: ty_span.shrink_to_lo(),
188189
hi: ty_span.shrink_to_hi(),
189190
},
@@ -217,7 +218,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
217218
if matches!(tcx.def_kind(def_id), DefKind::Static{ .. }
218219
if tcx.def_kind(tcx.local_parent(def_id)) == DefKind::ForeignMod) =>
219220
{
220-
tcx.dcx().emit_err(errors::TooLargeStatic { span });
221+
tcx.dcx().emit_err(diagnostics::TooLargeStatic { span });
221222
return;
222223
}
223224
// SIMD types with invalid layout (e.g., zero-length) should emit an error
@@ -599,7 +600,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
599600
}
600601
hir::PreciseCapturingArg::Lifetime(&hir::Lifetime { hir_id, ident, .. }) => {
601602
if let Some(prev_non_lifetime_param) = prev_non_lifetime_param {
602-
tcx.dcx().emit_err(errors::LifetimesMustBeFirst {
603+
tcx.dcx().emit_err(diagnostics::LifetimesMustBeFirst {
603604
lifetime_span: ident.span,
604605
name: ident.name,
605606
other_span: prev_non_lifetime_param.span,
@@ -611,7 +612,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
611612

612613
let ident = ident.normalize_to_macros_2_0();
613614
if let Some(span) = seen_params.insert(ident, ident.span) {
614-
tcx.dcx().emit_err(errors::DuplicatePreciseCapture {
615+
tcx.dcx().emit_err(diagnostics::DuplicatePreciseCapture {
615616
name: ident.name,
616617
first_span: span,
617618
second_span: ident.span,
@@ -675,14 +676,14 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
675676
.map_opaque_lifetime_to_parent_lifetime(param.def_id.expect_local())
676677
.opt_param_def_id(tcx, tcx.parent(opaque_def_id.to_def_id()))
677678
{
678-
tcx.dcx().emit_err(errors::LifetimeNotCaptured {
679+
tcx.dcx().emit_err(diagnostics::LifetimeNotCaptured {
679680
opaque_span,
680681
use_span,
681682
param_span: tcx.def_span(def_id),
682683
});
683684
} else {
684685
if tcx.def_kind(tcx.parent(param.def_id)) == DefKind::Trait {
685-
tcx.dcx().emit_err(errors::LifetimeImplicitlyCaptured {
686+
tcx.dcx().emit_err(diagnostics::LifetimeImplicitlyCaptured {
686687
opaque_span,
687688
param_span: tcx.def_span(param.def_id),
688689
});
@@ -691,7 +692,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
691692
// have not duplicated the lifetime but captured the original.
692693
// The "effective" `use_span` will be the span of the opaque itself,
693694
// and the param span will be the def span of the param.
694-
tcx.dcx().emit_err(errors::LifetimeNotCaptured {
695+
tcx.dcx().emit_err(diagnostics::LifetimeNotCaptured {
695696
opaque_span,
696697
use_span: opaque_span,
697698
param_span: use_span,
@@ -704,13 +705,13 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
704705
ty::GenericParamDefKind::Type { .. } => {
705706
if matches!(tcx.def_kind(param.def_id), DefKind::Trait | DefKind::TraitAlias) {
706707
// FIXME(precise_capturing): Structured suggestion for this would be useful
707-
tcx.dcx().emit_err(errors::SelfTyNotCaptured {
708+
tcx.dcx().emit_err(diagnostics::SelfTyNotCaptured {
708709
trait_span: tcx.def_span(param.def_id),
709710
opaque_span: tcx.def_span(opaque_def_id),
710711
});
711712
} else {
712713
// FIXME(precise_capturing): Structured suggestion for this would be useful
713-
tcx.dcx().emit_err(errors::ParamNotCaptured {
714+
tcx.dcx().emit_err(diagnostics::ParamNotCaptured {
714715
param_span: tcx.def_span(param.def_id),
715716
opaque_span: tcx.def_span(opaque_def_id),
716717
kind: "type",
@@ -719,7 +720,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
719720
}
720721
ty::GenericParamDefKind::Const { .. } => {
721722
// FIXME(precise_capturing): Structured suggestion for this would be useful
722-
tcx.dcx().emit_err(errors::ParamNotCaptured {
723+
tcx.dcx().emit_err(diagnostics::ParamNotCaptured {
723724
param_span: tcx.def_span(param.def_id),
724725
opaque_span: tcx.def_span(opaque_def_id),
725726
kind: "const",
@@ -755,7 +756,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
755756
ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, *adt_def, *args),
756757
_ => true,
757758
} {
758-
tcx.dcx().emit_err(errors::LinkageType { span: tcx.def_span(def_id) });
759+
tcx.dcx().emit_err(diagnostics::LinkageType { span: tcx.def_span(def_id) });
759760
}
760761
}
761762
}
@@ -1238,8 +1239,8 @@ pub(super) fn check_specialization_validity<'tcx>(
12381239
let ident = tcx.item_ident(impl_item);
12391240

12401241
let err = match tcx.span_of_impl(parent_impl) {
1241-
Ok(sp) => errors::ImplNotMarkedDefault::Ok { span, ident, ok_label: sp },
1242-
Err(cname) => errors::ImplNotMarkedDefault::Err { span, ident, cname },
1242+
Ok(sp) => diagnostics::ImplNotMarkedDefault::Ok { span, ident, ok_label: sp },
1243+
Err(cname) => diagnostics::ImplNotMarkedDefault::Err { span, ident, cname },
12431244
};
12441245

12451246
tcx.dcx().emit_err(err);
@@ -1255,7 +1256,7 @@ fn check_overriding_final_trait_item<'tcx>(
12551256
impl_item: ty::AssocItem,
12561257
) {
12571258
if trait_item.defaultness(tcx).is_final() {
1258-
tcx.dcx().emit_err(errors::OverridingFinalTraitFunction {
1259+
tcx.dcx().emit_err(diagnostics::OverridingFinalTraitFunction {
12591260
impl_span: tcx.def_span(impl_item.def_id),
12601261
trait_span: tcx.def_span(trait_item.def_id),
12611262
ident: tcx.item_ident(impl_item.def_id),
@@ -1330,7 +1331,7 @@ fn check_impl_items_against_trait<'tcx>(
13301331
rustc_lint_defs::builtin::DEAD_CODE,
13311332
tcx.local_def_id_to_hir_id(ty_impl_item.def_id.expect_local()),
13321333
tcx.def_span(ty_impl_item.def_id),
1333-
errors::UselessImplItem,
1334+
diagnostics::UselessImplItem,
13341335
)
13351336
}
13361337

@@ -1638,7 +1639,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
16381639
// over-aligned field to an aligned location before running its destructor, which would
16391640
// move a structurally pinned field out from under a `Pin<&mut _>` that was handed out.
16401641
if def.is_pin_project() {
1641-
tcx.dcx().emit_err(errors::PinV2OnPacked {
1642+
tcx.dcx().emit_err(diagnostics::PinV2OnPacked {
16421643
span: sp,
16431644
pin_v2_span: find_attr!(tcx, def.did(), PinV2(span) => *span),
16441645
adt_name: tcx.item_name(def.did()),
@@ -2119,11 +2120,11 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
21192120
|| (*bounded_params).get(&param.index).is_some_and(|&&pred_sp| pred_sp != span);
21202121
let const_param_help = !has_explicit_bounds;
21212122

2122-
let mut diag = tcx.dcx().create_err(errors::UnusedGenericParameter {
2123+
let mut diag = tcx.dcx().create_err(diagnostics::UnusedGenericParameter {
21232124
span,
21242125
param_name,
21252126
param_def_kind: tcx.def_descr(param.def_id),
2126-
help: errors::UnusedGenericParameterHelp::TyAlias { param_name },
2127+
help: diagnostics::UnusedGenericParameterHelp::TyAlias { param_name },
21272128
usage_spans: vec![],
21282129
const_param_help,
21292130
});

compiler/rustc_hir_analysis/src/check/compare_eii.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::potentially_plural_count;
2626
use crate::check::compare_impl_item::{
2727
CheckNumberOfEarlyBoundRegionsError, check_number_of_early_bound_regions,
2828
};
29-
use crate::errors::{
29+
use crate::diagnostics::{
3030
EiiDefkindMismatch, EiiDefkindMismatchStaticMutability, EiiDefkindMismatchStaticSafety,
3131
EiiWithGenerics, LifetimesOrBoundsMismatchOnEii,
3232
};

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_trait_selection::traits::{
2929
use tracing::{debug, instrument};
3030

3131
use super::potentially_plural_count;
32-
use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture};
32+
use crate::diagnostics::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture};
3333

3434
pub(super) mod refine;
3535

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fn report_mismatched_rpitit_signature<'tcx>(
367367
if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
368368
tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()),
369369
span,
370-
crate::errors::ReturnPositionImplTraitInTraitRefined {
370+
crate::diagnostics::ReturnPositionImplTraitInTraitRefined {
371371
impl_return_span,
372372
trait_return_span,
373373
pre,
@@ -464,7 +464,7 @@ fn report_mismatched_rpitit_captures<'tcx>(
464464
if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE },
465465
tcx.local_def_id_to_hir_id(impl_opaque_def_id),
466466
use_bound_span,
467-
crate::errors::ReturnPositionImplTraitInTraitRefinedLifetimes {
467+
crate::diagnostics::ReturnPositionImplTraitInTraitRefinedLifetimes {
468468
suggestion_span: use_bound_span,
469469
suggestion,
470470
},

compiler/rustc_hir_analysis/src/check/entry.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_trait_selection::regions::InferCtxtRegionExt;
1313
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};
1414

1515
use super::check_function_signature;
16-
use crate::errors;
16+
use crate::diagnostics;
1717

1818
pub(crate) fn check_for_entry_fn(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
1919
match tcx.entry_fn(()) {
@@ -92,23 +92,24 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) -> Result<(), ErrorGuar
9292
let main_asyncness = tcx.asyncness(main_def_id);
9393
if main_asyncness.is_async() {
9494
let asyncness_span = main_fn_asyncness_span(tcx, main_def_id);
95-
return Err(tcx
96-
.dcx()
97-
.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span }));
95+
return Err(tcx.dcx().emit_err(diagnostics::MainFunctionAsync {
96+
span: main_span,
97+
asyncness: asyncness_span,
98+
}));
9899
}
99100

100101
if let Some(attr_span) = find_attr!(tcx, main_def_id, TrackCaller(span) => *span) {
101102
return Err(tcx
102103
.dcx()
103-
.emit_err(errors::TrackCallerOnMain { span: attr_span, annotated: main_span }));
104+
.emit_err(diagnostics::TrackCallerOnMain { span: attr_span, annotated: main_span }));
104105
}
105106

106107
if !tcx.codegen_fn_attrs(main_def_id).target_features.is_empty()
107108
// Calling functions with `#[target_feature]` is not unsafe on WASM, see #84988
108109
&& !tcx.sess.target.is_like_wasm
109110
&& !tcx.sess.opts.actually_rustdoc
110111
{
111-
return Err(tcx.dcx().emit_err(errors::TargetFeatureOnMain { main: main_span }));
112+
return Err(tcx.dcx().emit_err(diagnostics::TargetFeatureOnMain { main: main_span }));
112113
}
113114

114115
// Main should have no WC, so empty param env is OK here.
@@ -120,7 +121,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) -> Result<(), ErrorGuar
120121
let Some(return_ty) = return_ty.no_bound_vars() else {
121122
return Err(tcx
122123
.dcx()
123-
.emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span }));
124+
.emit_err(diagnostics::MainFunctionReturnTypeGeneric { span: return_ty_span }));
124125
};
125126
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
126127
let cause = traits::ObligationCause::new(
@@ -168,14 +169,14 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) -> Result<(), ErrorGuar
168169
let main_fn_predicates = tcx.predicates_of(main_def_id);
169170
if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() {
170171
let generics_param_span = main_fn_generics_params_span(tcx, main_def_id);
171-
return Err(tcx.dcx().emit_err(errors::MainFunctionGenericParameters {
172+
return Err(tcx.dcx().emit_err(diagnostics::MainFunctionGenericParameters {
172173
span: generics_param_span.unwrap_or(main_span),
173174
label_span: generics_param_span,
174175
}));
175176
} else if !main_fn_predicates.predicates.is_empty() {
176177
// generics may bring in implicit predicates, so we skip this check if generics is present.
177178
let generics_where_clauses_span = main_fn_where_clauses_span(tcx, main_def_id);
178-
return Err(tcx.dcx().emit_err(errors::WhereClauseOnMain {
179+
return Err(tcx.dcx().emit_err(diagnostics::WhereClauseOnMain {
179180
span: generics_where_clauses_span.unwrap_or(main_span),
180181
generics_span: generics_where_clauses_span,
181182
}));

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_span::def_id::LocalDefId;
88
use rustc_span::{Span, Symbol, sym};
99

1010
use crate::check::check_function_signature;
11-
use crate::errors::{UnrecognizedIntrinsicFunction, WrongNumberOfGenericArgumentsToIntrinsic};
11+
use crate::diagnostics::{UnrecognizedIntrinsicFunction, WrongNumberOfGenericArgumentsToIntrinsic};
1212

1313
fn equate_intrinsic_type<'tcx>(
1414
tcx: TyCtxt<'tcx>,

0 commit comments

Comments
 (0)