Skip to content

Commit 24de943

Browse files
committed
translations(rustc_session): remove lint allow rule to the methods marked with rustc_lint_diagnostic
This commit removes the allows rules for the SessionDiagnostic lint that were being used in the session.rs file. Thanks to the PR rust-lang#101230 we do not need to annotate the methods with the allow rule as they are part of the diagnostic machinery.
1 parent 0f06320 commit 24de943

File tree

5 files changed

+12
-61
lines changed

5 files changed

+12
-61
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ session_target_data_layout_parse_error = {$err}
1919
2020
session_not_circumvent_feature = `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine
2121
22-
session_profile_use_file_does_not_exist = File `{$path}` passed to `-C profile-use` does not exist.
22+
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist.
2323
24-
session_linker_plugin_lto_windows_not_supported = Linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets"
24+
session_linker_plugin_lto_windows_not_supported = linker plugin based LTO is not supported together with `-C prefer-dynamic` when targeting Windows-like targets
2525
26-
session_profile_sample_use_file_does_not_exist = File `{$path}` passed to `-C profile-sample-use` does not exist.
26+
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist.
2727
28-
session_target_requires_unwind_tables = target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`."
28+
session_target_requires_unwind_tables = target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`
2929
3030
session_sanitizer_not_supported = {$us} sanitizer is not supported for this target
3131

compiler/rustc_middle/src/ty/context.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ use rustc_query_system::ich::StableHashingContext;
5252
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
5353
use rustc_session::config::{CrateType, OutputFilenames};
5454
use rustc_session::cstore::CrateStoreDyn;
55-
use rustc_session::errors::TargetDataLayoutParseError;
5655
use rustc_session::lint::{Level, Lint};
5756
use rustc_session::Limit;
5857
use rustc_session::Session;
@@ -1252,7 +1251,7 @@ impl<'tcx> TyCtxt<'tcx> {
12521251
output_filenames: OutputFilenames,
12531252
) -> GlobalCtxt<'tcx> {
12541253
let data_layout = TargetDataLayout::parse(&s.target).unwrap_or_else(|err| {
1255-
s.emit_fatal(TargetDataLayoutParseError { err });
1254+
s.emit_fatal(err);
12561255
});
12571256
let interners = CtxtInterners::new(arena);
12581257
let common_types = CommonTypes::new(

compiler/rustc_session/src/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Contains infrastructure for configuring the compiler, including parsing
22
//! command-line options.
33
4-
use crate::errors::TargetDataLayoutParseError;
54
pub use crate::options::*;
65

76
use crate::search_paths::SearchPath;
@@ -899,7 +898,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
899898
let max_atomic_width = sess.target.max_atomic_width();
900899
let atomic_cas = sess.target.atomic_cas;
901900
let layout = TargetDataLayout::parse(&sess.target).unwrap_or_else(|err| {
902-
sess.emit_fatal(TargetDataLayoutParseError { err });
901+
sess.emit_fatal(err);
903902
});
904903

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

compiler/rustc_session/src/errors.rs

+5-10
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::parse::ParseSess;
5-
use crate::{self as rustc_session};
6-
use rustc_errors::{fluent, MultiSpan};
4+
use crate::{self as rustc_session, SessionDiagnostic};
5+
use rustc_errors::{fluent, DiagnosticBuilder, Handler, MultiSpan};
76
use rustc_macros::SessionDiagnostic;
87
use rustc_span::{Span, Symbol};
98
use rustc_target::abi::TargetDataLayoutErrors;
@@ -46,14 +45,10 @@ pub struct FeatureDiagnosticHelp {
4645
pub feature: Symbol,
4746
}
4847

49-
pub struct TargetDataLayoutParseError<'a> {
50-
pub err: TargetDataLayoutErrors<'a>,
51-
}
52-
53-
impl crate::SessionDiagnostic<'_, !> for TargetDataLayoutParseError<'_> {
54-
fn into_diagnostic(self, sess: &ParseSess) -> rustc_errors::DiagnosticBuilder<'_, !> {
48+
impl SessionDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
49+
fn into_diagnostic(self, sess: &Handler) -> DiagnosticBuilder<'_, !> {
5550
let mut diag;
56-
match self.err {
51+
match self {
5752
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
5853
diag = sess.struct_fatal(fluent::session::target_invalid_address_space);
5954
diag.set_arg("addr_space", addr_space);

compiler/rustc_session/src/session.rs

+1-43
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl Session {
241241
if !unleashed_features.is_empty() {
242242
let mut must_err = false;
243243
// Create a diagnostic pointing at where things got unleashed.
244-
// FIXME: We need to correctly migrate this. I couldn't find a way to migrate this.
244+
// FIXME(#100717): needs eager translation/lists
245245
#[allow(rustc::untranslatable_diagnostic)]
246246
#[allow(rustc::diagnostic_outside_of_impl)]
247247
let mut diag = self.struct_warn("skipping const checks");
@@ -296,8 +296,6 @@ impl Session {
296296
}
297297

298298
#[rustc_lint_diagnostics]
299-
#[allow(rustc::untranslatable_diagnostic)]
300-
#[allow(rustc::diagnostic_outside_of_impl)]
301299
pub fn struct_span_warn<S: Into<MultiSpan>>(
302300
&self,
303301
sp: S,
@@ -306,8 +304,6 @@ impl Session {
306304
self.diagnostic().struct_span_warn(sp, msg)
307305
}
308306
#[rustc_lint_diagnostics]
309-
#[allow(rustc::untranslatable_diagnostic)]
310-
#[allow(rustc::diagnostic_outside_of_impl)]
311307
pub fn struct_span_warn_with_expectation<S: Into<MultiSpan>>(
312308
&self,
313309
sp: S,
@@ -317,8 +313,6 @@ impl Session {
317313
self.diagnostic().struct_span_warn_with_expectation(sp, msg, id)
318314
}
319315
#[rustc_lint_diagnostics]
320-
#[allow(rustc::untranslatable_diagnostic)]
321-
#[allow(rustc::diagnostic_outside_of_impl)]
322316
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
323317
&self,
324318
sp: S,
@@ -328,8 +322,6 @@ impl Session {
328322
self.diagnostic().struct_span_warn_with_code(sp, msg, code)
329323
}
330324
#[rustc_lint_diagnostics]
331-
#[allow(rustc::untranslatable_diagnostic)]
332-
#[allow(rustc::diagnostic_outside_of_impl)]
333325
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
334326
self.diagnostic().struct_warn(msg)
335327
}
@@ -342,8 +334,6 @@ impl Session {
342334
self.diagnostic().struct_warn_with_expectation(msg, id)
343335
}
344336
#[rustc_lint_diagnostics]
345-
#[allow(rustc::untranslatable_diagnostic)]
346-
#[allow(rustc::diagnostic_outside_of_impl)]
347337
pub fn struct_span_allow<S: Into<MultiSpan>>(
348338
&self,
349339
sp: S,
@@ -352,14 +342,10 @@ impl Session {
352342
self.diagnostic().struct_span_allow(sp, msg)
353343
}
354344
#[rustc_lint_diagnostics]
355-
#[allow(rustc::untranslatable_diagnostic)]
356-
#[allow(rustc::diagnostic_outside_of_impl)]
357345
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
358346
self.diagnostic().struct_allow(msg)
359347
}
360348
#[rustc_lint_diagnostics]
361-
#[allow(rustc::untranslatable_diagnostic)]
362-
#[allow(rustc::diagnostic_outside_of_impl)]
363349
pub fn struct_expect(
364350
&self,
365351
msg: impl Into<DiagnosticMessage>,
@@ -368,8 +354,6 @@ impl Session {
368354
self.diagnostic().struct_expect(msg, id)
369355
}
370356
#[rustc_lint_diagnostics]
371-
#[allow(rustc::untranslatable_diagnostic)]
372-
#[allow(rustc::diagnostic_outside_of_impl)]
373357
pub fn struct_span_err<S: Into<MultiSpan>>(
374358
&self,
375359
sp: S,
@@ -378,8 +362,6 @@ impl Session {
378362
self.diagnostic().struct_span_err(sp, msg)
379363
}
380364
#[rustc_lint_diagnostics]
381-
#[allow(rustc::untranslatable_diagnostic)]
382-
#[allow(rustc::diagnostic_outside_of_impl)]
383365
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
384366
&self,
385367
sp: S,
@@ -390,17 +372,13 @@ impl Session {
390372
}
391373
// FIXME: This method should be removed (every error should have an associated error code).
392374
#[rustc_lint_diagnostics]
393-
#[allow(rustc::untranslatable_diagnostic)]
394-
#[allow(rustc::diagnostic_outside_of_impl)]
395375
pub fn struct_err(
396376
&self,
397377
msg: impl Into<DiagnosticMessage>,
398378
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
399379
self.parse_sess.struct_err(msg)
400380
}
401381
#[rustc_lint_diagnostics]
402-
#[allow(rustc::untranslatable_diagnostic)]
403-
#[allow(rustc::diagnostic_outside_of_impl)]
404382
pub fn struct_err_with_code(
405383
&self,
406384
msg: impl Into<DiagnosticMessage>,
@@ -409,8 +387,6 @@ impl Session {
409387
self.diagnostic().struct_err_with_code(msg, code)
410388
}
411389
#[rustc_lint_diagnostics]
412-
#[allow(rustc::untranslatable_diagnostic)]
413-
#[allow(rustc::diagnostic_outside_of_impl)]
414390
pub fn struct_warn_with_code(
415391
&self,
416392
msg: impl Into<DiagnosticMessage>,
@@ -419,8 +395,6 @@ impl Session {
419395
self.diagnostic().struct_warn_with_code(msg, code)
420396
}
421397
#[rustc_lint_diagnostics]
422-
#[allow(rustc::untranslatable_diagnostic)]
423-
#[allow(rustc::diagnostic_outside_of_impl)]
424398
pub fn struct_span_fatal<S: Into<MultiSpan>>(
425399
&self,
426400
sp: S,
@@ -429,8 +403,6 @@ impl Session {
429403
self.diagnostic().struct_span_fatal(sp, msg)
430404
}
431405
#[rustc_lint_diagnostics]
432-
#[allow(rustc::untranslatable_diagnostic)]
433-
#[allow(rustc::diagnostic_outside_of_impl)]
434406
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
435407
&self,
436408
sp: S,
@@ -440,21 +412,15 @@ impl Session {
440412
self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
441413
}
442414
#[rustc_lint_diagnostics]
443-
#[allow(rustc::untranslatable_diagnostic)]
444-
#[allow(rustc::diagnostic_outside_of_impl)]
445415
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
446416
self.diagnostic().struct_fatal(msg)
447417
}
448418

449419
#[rustc_lint_diagnostics]
450-
#[allow(rustc::untranslatable_diagnostic)]
451-
#[allow(rustc::diagnostic_outside_of_impl)]
452420
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
453421
self.diagnostic().span_fatal(sp, msg)
454422
}
455423
#[rustc_lint_diagnostics]
456-
#[allow(rustc::untranslatable_diagnostic)]
457-
#[allow(rustc::diagnostic_outside_of_impl)]
458424
pub fn span_fatal_with_code<S: Into<MultiSpan>>(
459425
&self,
460426
sp: S,
@@ -464,14 +430,10 @@ impl Session {
464430
self.diagnostic().span_fatal_with_code(sp, msg, code)
465431
}
466432
#[rustc_lint_diagnostics]
467-
#[allow(rustc::untranslatable_diagnostic)]
468-
#[allow(rustc::diagnostic_outside_of_impl)]
469433
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
470434
self.diagnostic().fatal(msg).raise()
471435
}
472436
#[rustc_lint_diagnostics]
473-
#[allow(rustc::untranslatable_diagnostic)]
474-
#[allow(rustc::diagnostic_outside_of_impl)]
475437
pub fn span_err_or_warn<S: Into<MultiSpan>>(
476438
&self,
477439
is_warning: bool,
@@ -485,8 +447,6 @@ impl Session {
485447
}
486448
}
487449
#[rustc_lint_diagnostics]
488-
#[allow(rustc::untranslatable_diagnostic)]
489-
#[allow(rustc::diagnostic_outside_of_impl)]
490450
pub fn span_err<S: Into<MultiSpan>>(
491451
&self,
492452
sp: S,
@@ -495,8 +455,6 @@ impl Session {
495455
self.diagnostic().span_err(sp, msg)
496456
}
497457
#[rustc_lint_diagnostics]
498-
#[allow(rustc::untranslatable_diagnostic)]
499-
#[allow(rustc::diagnostic_outside_of_impl)]
500458
pub fn span_err_with_code<S: Into<MultiSpan>>(
501459
&self,
502460
sp: S,

0 commit comments

Comments
 (0)