Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #118655

Merged
merged 33 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
33 commits
Select commit Hold shift click to select a range
ed87ecc
Update variable name to fix `unused_variables` warning
wdunicornpro Nov 10, 2023
d1583eb
lib features ending in '_internals?' are internal
RalfJung Nov 21, 2023
74834a9
also make 'core_intrinsics' internal
RalfJung Nov 22, 2023
9ae3213
Simplify Default for tuples
DaniPopes Nov 27, 2023
13c16e3
Use OnceCell in cell module documentation
marcin-serwin Nov 29, 2023
114380d
Give `Handler::fatal` and `Session::fatal` the same return type.
nnethercote Dec 1, 2023
d4933aa
Inline and remove `DiagnosticBuilder::new_diagnostic_*` functions.
nnethercote Dec 3, 2023
ab640ca
Inline and remove more `DiagnosticBuilder::new_diagnostic_*` functions.
nnethercote Dec 3, 2023
6a95dee
Rename some arguments.
nnethercote Dec 3, 2023
ed95f39
Always use `G` for `EmissionGuarantee` type variables.
nnethercote Dec 3, 2023
32dc78e
Avoid `Diagnostic::new_with_code(..., None, ...)`.
nnethercote Dec 3, 2023
d51b3db
Remove some unused code, and downgrade some `pub`s.
nnethercote Dec 3, 2023
b7e18ca
De-genericize some `IntoDiagnostic` impls.
nnethercote Dec 3, 2023
8c20ad6
Use `DiagnosticBuilder::new` more.
nnethercote Dec 3, 2023
a8ff867
Move some `HandlerInner` functions to `Handler`.
nnethercote Dec 4, 2023
883bdb7
Remove `HandlerInner::emit`.
nnethercote Dec 4, 2023
3ab05ca
Make `Handler::{err,bug}` more like `Handler::{warn,note}`.
nnethercote Dec 4, 2023
7811c97
Inline and remove `fatal_no_raise`.
nnethercote Dec 4, 2023
d627e2a
Fix parser ICE when recovering `dyn`/`impl` after `for<...>`
sjwang05 Dec 4, 2023
a0ba895
bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_ex…
Xanewok Dec 5, 2023
334577f
Add deeply_normalize_for_diagnostics, use it in coherence
compiler-errors Nov 27, 2023
3448284
Continue folding if deep normalizer fails
compiler-errors Nov 28, 2023
b97ff8e
Add print_trait_sugared
compiler-errors Nov 24, 2023
f6c30b3
Add more
compiler-errors Nov 24, 2023
2d2a76d
Rollup merge of #117793 - wdunicornpro:patch-1, r=workingjubilee
compiler-errors Dec 5, 2023
19bf749
Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-…
compiler-errors Dec 5, 2023
ad23f30
Rollup merge of #118268 - compiler-errors:pretty-print, r=estebank
compiler-errors Dec 5, 2023
598ca0e
Rollup merge of #118346 - compiler-errors:deeply-normalize-for-diagno…
compiler-errors Dec 5, 2023
aa5f251
Rollup merge of #118350 - DaniPopes:tuple-default, r=workingjubilee
compiler-errors Dec 5, 2023
6fa93e8
Rollup merge of #118450 - marcin-serwin:master, r=workingjubilee
compiler-errors Dec 5, 2023
dbcde57
Rollup merge of #118585 - sjwang05:issue-118564, r=compiler-errors
compiler-errors Dec 5, 2023
e813370
Rollup merge of #118587 - nnethercote:cleanup-error-handlers-2, r=com…
compiler-errors Dec 5, 2023
0a8c0f7
Rollup merge of #118642 - Xanewok:patch-1, r=clubby789
compiler-errors Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
use rustc_errors::{
AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, Handler, IntoDiagnostic, MultiSpan,
AddToDiagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan,
SingleLabelManySpans,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
Expand Down Expand Up @@ -446,9 446,9 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
}

// Hand-written implementation to support custom user messages.
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMessage {
impl<'a> IntoDiagnostic<'a> for EnvNotDefinedWithUserMessage {
#[track_caller]
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, G> {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
#[expect(
rustc::untranslatable_diagnostic,
reason = "cannot translate user-provided messages"
Expand Down Expand Up @@ -801,8 801,8 @@ pub(crate) struct AsmClobberNoReg {
pub(crate) clobbers: Vec<Span>,
}

impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, G> {
impl<'a> IntoDiagnostic<'a> for AsmClobberNoReg {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut diag =
handler.struct_diagnostic(crate::fluent_generated::builtin_macros_asm_clobber_no_reg);
diag.set_span(self.spans.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 64,7 @@ impl ConcurrencyLimiter {
// Make sure to drop the mutex guard first to prevent poisoning the mutex.
drop(state);
if let Some(err) = err {
handler.fatal(err).raise();
handler.fatal(err);
} else {
// The error was already emitted, but compilation continued. Raise a silent
// fatal error.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 111,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
pub(crate) struct MissingFeatures;

impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable);
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = handler.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable);
if let Some(span) = self.span {
diag.set_span(span);
};
Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_codegen_llvm/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 5,7 @@ use std::path::Path;
use crate::fluent_generated as fluent;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_errors::{
DiagnosticBuilder, EmissionGuarantee, ErrorGuaranteed, Handler, IntoDiagnostic,
DiagnosticBuilder, EmissionGuarantee, ErrorGuaranteed, FatalError, Handler, IntoDiagnostic,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span;
Expand Down Expand Up @@ -101,13 101,13 @@ pub(crate) struct DynamicLinkingWithLTO;

pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);

impl<EM: EmissionGuarantee> IntoDiagnostic<'_, EM> for ParseTargetMachineConfig<'_> {
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, EM> {
let diag: DiagnosticBuilder<'_, EM> = self.0.into_diagnostic(sess);
impl IntoDiagnostic<'_, FatalError> for ParseTargetMachineConfig<'_> {
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, FatalError> {
let diag: DiagnosticBuilder<'_, FatalError> = self.0.into_diagnostic(handler);
let (message, _) = diag.styled_message().first().expect("`LlvmError` with no message");
let message = sess.eagerly_translate_to_string(message.clone(), diag.args());
let message = handler.eagerly_translate_to_string(message.clone(), diag.args());

let mut diag = sess.struct_diagnostic(fluent::codegen_llvm_parse_target_machine_config);
let mut diag = handler.struct_diagnostic(fluent::codegen_llvm_parse_target_machine_config);
diag.set_arg("error", message);
diag
}
Expand All @@ -124,8 124,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
pub(crate) struct MissingFeatures;

impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = handler.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
if let Some(span) = self.span {
diag.set_span(span);
};
Expand Down Expand Up @@ -183,8 183,8 @@ pub enum LlvmError<'a> {

pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);

impl<EM: EmissionGuarantee> IntoDiagnostic<'_, EM> for WithLlvmError<'_> {
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, EM> {
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, G> {
use LlvmError::*;
let msg_with_llvm_err = match &self.0 {
WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err,
Expand All @@ -201,7 201,7 @@ impl<EM: EmissionGuarantee> IntoDiagnostic<'_, EM> for WithLlvmError<'_> {
PrepareThinLtoModule => fluent::codegen_llvm_prepare_thin_lto_module_with_llvm_err,
ParseBitcode => fluent::codegen_llvm_parse_bitcode_with_llvm_err,
};
let mut diag = self.0.into_diagnostic(sess);
let mut diag = self.0.into_diagnostic(handler);
diag.set_primary_message(msg_with_llvm_err);
diag.set_arg("llvm_err", self.1);
diag
Expand Down
43 changes: 6 additions & 37 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 239,7 @@ impl Diagnostic {
}

#[track_caller]
pub fn new_with_code<M: Into<DiagnosticMessage>>(
pub(crate) fn new_with_code<M: Into<DiagnosticMessage>>(
level: Level,
code: Option<DiagnosticId>,
message: M,
Expand Down Expand Up @@ -281,7 281,7 @@ impl Diagnostic {
}
}

pub fn update_unstable_expectation_id(
pub(crate) fn update_unstable_expectation_id(
&mut self,
unstable_to_stable: &FxHashMap<LintExpectationId, LintExpectationId>,
) {
Expand All @@ -307,14 307,14 @@ impl Diagnostic {
}

/// Indicates whether this diagnostic should show up in cargo's future breakage report.
pub fn has_future_breakage(&self) -> bool {
pub(crate) fn has_future_breakage(&self) -> bool {
match self.code {
Some(DiagnosticId::Lint { has_future_breakage, .. }) => has_future_breakage,
_ => false,
}
}

pub fn is_force_warn(&self) -> bool {
pub(crate) fn is_force_warn(&self) -> bool {
match self.code {
Some(DiagnosticId::Lint { is_force_warn, .. }) => is_force_warn,
_ => false,
Expand Down Expand Up @@ -391,29 391,6 @@ impl Diagnostic {
self.note_expected_found_extra(expected_label, expected, found_label, found, &"", &"")
}

pub fn note_unsuccessful_coercion(
&mut self,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
) -> &mut Self {
let mut msg: Vec<_> =
vec![(Cow::from("required when trying to coerce from type `"), Style::NoStyle)];
msg.extend(expected.0.iter().map(|x| match *x {
StringPart::Normal(ref s) => (Cow::from(s.clone()), Style::NoStyle),
StringPart::Highlighted(ref s) => (Cow::from(s.clone()), Style::Highlight),
}));
msg.push((Cow::from("` to type '"), Style::NoStyle));
msg.extend(found.0.iter().map(|x| match *x {
StringPart::Normal(ref s) => (Cow::from(s.clone()), Style::NoStyle),
StringPart::Highlighted(ref s) => (Cow::from(s.clone()), Style::Highlight),
}));
msg.push((Cow::from("`"), Style::NoStyle));

// For now, just attach these as notes
self.highlighted_note(msg);
self
}

pub fn note_expected_found_extra(
&mut self,
expected_label: &dyn fmt::Display,
Expand Down Expand Up @@ -475,7 452,7 @@ impl Diagnostic {
self
}

pub fn highlighted_note<M: Into<SubdiagnosticMessage>>(
fn highlighted_note<M: Into<SubdiagnosticMessage>>(
&mut self,
msg: Vec<(M, Style)>,
) -> &mut Self {
Expand Down Expand Up @@ -572,14 549,6 @@ impl Diagnostic {
self
}

/// Clear any existing suggestions.
pub fn clear_suggestions(&mut self) -> &mut Self {
if let Ok(suggestions) = &mut self.suggestions {
suggestions.clear();
}
self
}

/// Helper for pushing to `self.suggestions`, if available (not disable).
fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
if let Ok(suggestions) = &mut self.suggestions {
Expand Down Expand Up @@ -992,7 961,7 @@ impl Diagnostic {
/// Helper function that takes a `SubdiagnosticMessage` and returns a `DiagnosticMessage` by
/// combining it with the primary message of the diagnostic (if translatable, otherwise it just
/// passes the user's string along).
pub(crate) fn subdiagnostic_message_to_diagnostic_message(
fn subdiagnostic_message_to_diagnostic_message(
&self,
attr: impl Into<SubdiagnosticMessage>,
) -> DiagnosticMessage {
Expand Down
Loading