Skip to content

Commit 4e62d96

Browse files
committed
FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way
1 parent cf8739c commit 4e62d96

File tree

7 files changed

+46
-43
lines changed

7 files changed

+46
-43
lines changed

compiler/rustc_infer/src/errors/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use hir::GenericParamKind;
22
use rustc_errors::{
3-
fluent, AddSubdiagnostic, Applicability, DiagnosticMessage, DiagnosticStyledString, MultiSpan,
3+
fluent, AddToDiagnostic, Applicability, DiagnosticMessage, DiagnosticStyledString, MultiSpan,
44
};
55
use rustc_hir as hir;
66
use rustc_hir::{FnRetTy, Ty};
7-
use rustc_macros::SessionDiagnostic;
7+
use rustc_macros::{Diagnostic, Subdiagnostic};
88
use rustc_middle::ty::{Region, TyCtxt};
99
use rustc_span::symbol::kw;
1010
use rustc_span::{symbol::Ident, BytePos, Span};
@@ -16,7 +16,7 @@ use crate::infer::error_reporting::{
1616

1717
pub mod note_and_explain;
1818

19-
#[derive(SessionDiagnostic)]
19+
#[derive(Diagnostic)]
2020
#[diag(infer::opaque_hidden_type)]
2121
pub struct OpaqueHiddenTypeDiag {
2222
#[primary_span]
@@ -28,7 +28,7 @@ pub struct OpaqueHiddenTypeDiag {
2828
pub hidden_type: Span,
2929
}
3030

31-
#[derive(SessionDiagnostic)]
31+
#[derive(Diagnostic)]
3232
#[diag(infer::type_annotations_needed, code = "E0282")]
3333
pub struct AnnotationRequired<'a> {
3434
#[primary_span]
@@ -46,7 +46,7 @@ pub struct AnnotationRequired<'a> {
4646
}
4747

4848
// Copy of `AnnotationRequired` for E0283
49-
#[derive(SessionDiagnostic)]
49+
#[derive(Diagnostic)]
5050
#[diag(infer::type_annotations_needed, code = "E0283")]
5151
pub struct AmbigousImpl<'a> {
5252
#[primary_span]
@@ -64,7 +64,7 @@ pub struct AmbigousImpl<'a> {
6464
}
6565

6666
// Copy of `AnnotationRequired` for E0284
67-
#[derive(SessionDiagnostic)]
67+
#[derive(Diagnostic)]
6868
#[diag(infer::type_annotations_needed, code = "E0284")]
6969
pub struct AmbigousReturn<'a> {
7070
#[primary_span]
@@ -81,7 +81,7 @@ pub struct AmbigousReturn<'a> {
8181
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
8282
}
8383

84-
#[derive(SessionDiagnostic)]
84+
#[derive(Diagnostic)]
8585
#[diag(infer::need_type_info_in_generator, code = "E0698")]
8686
pub struct NeedTypeInfoInGenerator<'a> {
8787
#[primary_span]
@@ -92,7 +92,7 @@ pub struct NeedTypeInfoInGenerator<'a> {
9292
}
9393

9494
// Used when a better one isn't available
95-
#[derive(SessionSubdiagnostic)]
95+
#[derive(Subdiagnostic)]
9696
#[label(infer::label_bad)]
9797
pub struct InferenceBadError<'a> {
9898
#[primary_span]
@@ -106,7 +106,7 @@ pub struct InferenceBadError<'a> {
106106
pub name: String,
107107
}
108108

109-
#[derive(SessionSubdiagnostic)]
109+
#[derive(Subdiagnostic)]
110110
pub enum SourceKindSubdiag<'a> {
111111
#[suggestion_verbose(
112112
infer::source_kind_subdiag_let,
@@ -147,7 +147,7 @@ pub enum SourceKindSubdiag<'a> {
147147
},
148148
}
149149

150-
#[derive(SessionSubdiagnostic)]
150+
#[derive(Subdiagnostic)]
151151
pub enum SourceKindMultiSuggestion<'a> {
152152
#[multipart_suggestion_verbose(
153153
infer::source_kind_fully_qualified,
@@ -228,7 +228,7 @@ pub enum RegionOriginNote<'a> {
228228
},
229229
}
230230

231-
impl AddSubdiagnostic for RegionOriginNote<'_> {
231+
impl AddToDiagnostic for RegionOriginNote<'_> {
232232
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
233233
let mut label_or_note = |span, msg: DiagnosticMessage| {
234234
let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count();
@@ -289,7 +289,7 @@ pub enum LifetimeMismatchLabels {
289289
},
290290
}
291291

292-
impl AddSubdiagnostic for LifetimeMismatchLabels {
292+
impl AddToDiagnostic for LifetimeMismatchLabels {
293293
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
294294
match self {
295295
LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => {
@@ -339,7 +339,7 @@ pub struct AddLifetimeParamsSuggestion<'a> {
339339
pub add_note: bool,
340340
}
341341

342-
impl AddSubdiagnostic for AddLifetimeParamsSuggestion<'_> {
342+
impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
343343
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
344344
let mut mk_suggestion = || {
345345
let (
@@ -422,7 +422,7 @@ impl AddSubdiagnostic for AddLifetimeParamsSuggestion<'_> {
422422
}
423423
}
424424

425-
#[derive(SessionDiagnostic)]
425+
#[derive(Diagnostic)]
426426
#[diag(infer::lifetime_mismatch, code = "E0623")]
427427
pub struct LifetimeMismatch<'a> {
428428
#[primary_span]
@@ -438,7 +438,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
438438
pub binding_span: Span,
439439
}
440440

441-
impl AddSubdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
441+
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
442442
fn add_to_diagnostic(mut self, diag: &mut rustc_errors::Diagnostic) {
443443
self.unmet_requirements
444444
.push_span_label(self.binding_span, fluent::infer::msl_introduces_static);
@@ -450,7 +450,7 @@ pub struct ImplNote {
450450
pub impl_span: Option<Span>,
451451
}
452452

453-
impl AddSubdiagnostic for ImplNote {
453+
impl AddToDiagnostic for ImplNote {
454454
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
455455
match self.impl_span {
456456
Some(span) => diag.span_note(span, fluent::infer::msl_impl_note),
@@ -465,7 +465,7 @@ pub enum TraitSubdiag {
465465
}
466466

467467
// FIXME(#100717) used in `Vec<TraitSubdiag>` so requires eager translation/list support
468-
impl AddSubdiagnostic for TraitSubdiag {
468+
impl AddToDiagnostic for TraitSubdiag {
469469
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
470470
match self {
471471
TraitSubdiag::Note { span } => {
@@ -483,7 +483,7 @@ impl AddSubdiagnostic for TraitSubdiag {
483483
}
484484
}
485485

486-
#[derive(SessionDiagnostic)]
486+
#[derive(Diagnostic)]
487487
#[diag(infer::mismatched_static_lifetime)]
488488
pub struct MismatchedStaticLifetime<'a> {
489489
#[primary_span]

compiler/rustc_infer/src/errors/note_and_explain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::infer::error_reporting::nice_region_error::find_anon_type;
2-
use rustc_errors::{self, fluent, AddSubdiagnostic, IntoDiagnosticArg};
2+
use rustc_errors::{self, fluent, AddToDiagnostic, IntoDiagnosticArg};
33
use rustc_middle::ty::{self, TyCtxt};
44
use rustc_span::{symbol::kw, Span};
55

@@ -165,7 +165,7 @@ impl RegionExplanation<'_> {
165165
}
166166
}
167167

168-
impl AddSubdiagnostic for RegionExplanation<'_> {
168+
impl AddToDiagnostic for RegionExplanation<'_> {
169169
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
170170
if let Some(span) = self.desc.span {
171171
diag.span_note(span, fluent::infer::region_explanation);

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
1111
use crate::infer::SubregionOrigin;
1212
use crate::infer::TyCtxt;
1313

14-
use rustc_errors::AddSubdiagnostic;
14+
use rustc_errors::AddToDiagnostic;
1515
use rustc_errors::{Diagnostic, ErrorGuaranteed};
1616
use rustc_hir::Ty;
1717
use rustc_middle::ty::Region;

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use rustc_query_system::ich::StableHashingContext;
5353
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
5454
use rustc_session::config::{CrateType, OutputFilenames};
5555
use rustc_session::cstore::CrateStoreDyn;
56+
use rustc_session::errors::TargetDataLayoutErrorsWrapper;
5657
use rustc_session::lint::{Level, Lint};
5758
use rustc_session::Limit;
5859
use rustc_session::Session;
@@ -1252,7 +1253,7 @@ impl<'tcx> TyCtxt<'tcx> {
12521253
output_filenames: OutputFilenames,
12531254
) -> GlobalCtxt<'tcx> {
12541255
let data_layout = TargetDataLayout::parse(&s.target).unwrap_or_else(|err| {
1255-
s.emit_fatal(err);
1256+
s.emit_fatal(TargetDataLayoutErrorsWrapper(err));
12561257
});
12571258
let interners = CtxtInterners::new(arena);
12581259
let common_types = CommonTypes::new(

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ pub(crate) struct RemoveLet {
713713
pub span: Span,
714714
}
715715

716-
#[derive(SessionDiagnostic)]
716+
#[derive(Diagnostic)]
717717
#[diag(parser::use_eq_instead)]
718718
pub(crate) struct UseEqInstead {
719719
#[primary_span]

compiler/rustc_session/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
pub use crate::options::*;
55

6+
use crate::errors::TargetDataLayoutErrorsWrapper;
67
use crate::search_paths::SearchPath;
78
use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
89
use crate::{early_error, early_warn, Session};
@@ -898,7 +899,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
898899
let max_atomic_width = sess.target.max_atomic_width();
899900
let atomic_cas = sess.target.atomic_cas;
900901
let layout = TargetDataLayout::parse(&sess.target).unwrap_or_else(|err| {
901-
sess.emit_fatal(err);
902+
sess.emit_fatal(TargetDataLayoutErrorsWrapper(err));
902903
});
903904

904905
let mut ret = CrateConfig::default();

compiler/rustc_session/src/errors.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::num::NonZeroU32;
22

33
use crate::cgu_reuse_tracker::CguReuse;
4-
use crate::{self as rustc_session, SessionDiagnostic};
5-
use rustc_errors::{fluent, IntoDiagnostic, Handler, MultiSpan};
6-
use rustc_macros::SessionDiagnostic;
4+
use rustc_errors::{fluent, DiagnosticBuilder, Handler, IntoDiagnostic, MultiSpan};
5+
use rustc_macros::Diagnostic;
76
use rustc_span::{Span, Symbol};
87
use rustc_target::abi::TargetDataLayoutErrors;
98
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
@@ -46,10 +45,12 @@ pub struct FeatureDiagnosticHelp {
4645
pub feature: Symbol,
4746
}
4847

49-
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
48+
pub struct TargetDataLayoutErrorsWrapper<'a>(pub TargetDataLayoutErrors<'a>);
49+
50+
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrorsWrapper<'_> {
5051
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
5152
let mut diag;
52-
match self {
53+
match self.0 {
5354
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
5455
diag = handler.struct_fatal(fluent::session::target_invalid_address_space);
5556
diag.set_arg("addr_space", addr_space);
@@ -97,75 +98,75 @@ impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
9798
}
9899
}
99100

100-
#[derive(SessionDiagnostic)]
101+
#[derive(Diagnostic)]
101102
#[diag(session::not_circumvent_feature)]
102103
pub struct NotCircumventFeature;
103104

104-
#[derive(SessionDiagnostic)]
105+
#[derive(Diagnostic)]
105106
#[diag(session::linker_plugin_lto_windows_not_supported)]
106107
pub struct LinkerPluginToWindowsNotSupported;
107108

108-
#[derive(SessionDiagnostic)]
109+
#[derive(Diagnostic)]
109110
#[diag(session::profile_use_file_does_not_exist)]
110111
pub struct ProfileUseFileDoesNotExist<'a> {
111112
pub path: &'a std::path::Path,
112113
}
113114

114-
#[derive(SessionDiagnostic)]
115+
#[derive(Diagnostic)]
115116
#[diag(session::profile_sample_use_file_does_not_exist)]
116117
pub struct ProfileSampleUseFileDoesNotExist<'a> {
117118
pub path: &'a std::path::Path,
118119
}
119120

120-
#[derive(SessionDiagnostic)]
121+
#[derive(Diagnostic)]
121122
#[diag(session::target_requires_unwind_tables)]
122123
pub struct TargetRequiresUnwindTables;
123124

124-
#[derive(SessionDiagnostic)]
125+
#[derive(Diagnostic)]
125126
#[diag(session::sanitizer_not_supported)]
126127
pub struct SanitizerNotSupported {
127128
pub us: String,
128129
}
129130

130-
#[derive(SessionDiagnostic)]
131+
#[derive(Diagnostic)]
131132
#[diag(session::sanitizers_not_supported)]
132133
pub struct SanitizersNotSupported {
133134
pub us: String,
134135
}
135136

136-
#[derive(SessionDiagnostic)]
137+
#[derive(Diagnostic)]
137138
#[diag(session::cannot_mix_and_match_sanitizers)]
138139
pub struct CannotMixAndMatchSanitizers {
139140
pub first: String,
140141
pub second: String,
141142
}
142143

143-
#[derive(SessionDiagnostic)]
144+
#[derive(Diagnostic)]
144145
#[diag(session::cannot_enable_crt_static_linux)]
145146
pub struct CannotEnableCrtStaticLinux;
146147

147-
#[derive(SessionDiagnostic)]
148+
#[derive(Diagnostic)]
148149
#[diag(session::sanitizer_cfi_enabled)]
149150
pub struct SanitizerCfiEnabled;
150151

151-
#[derive(SessionDiagnostic)]
152+
#[derive(Diagnostic)]
152153
#[diag(session::unstable_virtual_function_elimination)]
153154
pub struct UnstableVirtualFunctionElimination;
154155

155-
#[derive(SessionDiagnostic)]
156+
#[derive(Diagnostic)]
156157
#[diag(session::unsupported_dwarf_version)]
157158
pub struct UnsupportedDwarfVersion {
158159
pub dwarf_version: u32,
159160
}
160161

161-
#[derive(SessionDiagnostic)]
162+
#[derive(Diagnostic)]
162163
#[diag(session::target_stack_protector_not_supported)]
163164
pub struct StackProtectorNotSupportedForTarget<'a> {
164165
pub stack_protector: StackProtector,
165166
pub target_triple: &'a TargetTriple,
166167
}
167168

168-
#[derive(SessionDiagnostic)]
169+
#[derive(Diagnostic)]
169170
#[diag(session::split_debuginfo_unstable_platform)]
170171
pub struct SplitDebugInfoUnstablePlatform {
171172
pub debuginfo: SplitDebuginfo,

0 commit comments

Comments
 (0)