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 10 pull requests #120795

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8148053
Add supporting infrastructure for `run-make` V2 tests
jieyouxu Jan 20, 2024
e1826bf
Point to stage1-std when in stage2 rustc
jieyouxu Feb 2, 2024
6b2a824
Remove dead args from functions
compiler-errors Feb 2, 2024
c2a0d11
Fix incorrect stage std paths
jieyouxu Feb 2, 2024
0bfcafd
std::thread::available_parallelism merging linux/android/freebsd version
devnexen Feb 2, 2024
0ac1195
Invert diagnostic lints.
nnethercote Feb 5, 2024
ad3d04c
A drive-by rewrite of give_region_a_name()
amandasystems Feb 6, 2024
cd21b1d
No need to take ImplTraitContext by ref
compiler-errors Feb 7, 2024
0e4b55b
Reorder the diagnostic API methods.
nnethercote Feb 8, 2024
d1920a7
Fix inconsistencies in the diagnostic API methods.
nnethercote Feb 8, 2024
795be51
Make `RegionName` `Copy` by (transitively) interning the few string v…
amandasystems Feb 7, 2024
eb0d70e
also try to normalize opaque types in alias-relate
lcnr Jan 29, 2024
3eef669
use alias-relate to structurally normalize in the solver
lcnr Feb 1, 2024
4ced269
add revisions
lcnr Feb 1, 2024
45377df
one must imagine ci happy
lcnr Feb 8, 2024
f676c3d
Remove myself from review rotation.
m-ou-se Feb 8, 2024
9224387
Correctly generate path for non-local items in source code pages
GuillaumeGomez Feb 2, 2024
41f9b57
Add regression test for non local items link generation
GuillaumeGomez Feb 3, 2024
11bd2ea
Unify item relative path computation in one function
GuillaumeGomez Feb 3, 2024
502806a
Rollup merge of #113026 - jieyouxu:run-make-v2, r=bjorn3
matthiaskrgr Feb 8, 2024
43c6671
Rollup merge of #120549 - lcnr:errs-showcase, r=compiler-errors
matthiaskrgr Feb 8, 2024
9fd0a0b
Rollup merge of #120589 - devnexen:cpuaff_fbsd_upd, r=m-ou-se
matthiaskrgr Feb 8, 2024
e30640e
Rollup merge of #120590 - compiler-errors:dead, r=Nilstrieb
matthiaskrgr Feb 8, 2024
b34415c
Rollup merge of #120596 - GuillaumeGomez:jump-to-def-non-local-link, …
matthiaskrgr Feb 8, 2024
32ca987
Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davi…
matthiaskrgr Feb 8, 2024
66f49d6
Rollup merge of #120704 - amandasystems:silly-region-name-rewrite, r=…
matthiaskrgr Feb 8, 2024
c2529f0
Rollup merge of #120750 - compiler-errors:itctx-by-val, r=cjgillot
matthiaskrgr Feb 8, 2024
3476bcd
Rollup merge of #120765 - nnethercote:reorder-diag-API, r=compiler-er…
matthiaskrgr Feb 8, 2024
f59b48c
Rollup merge of #120772 - m-ou-se:review, r=Nilstrieb
matthiaskrgr Feb 8, 2024
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
Prev Previous commit
Next Next commit
Fix inconsistencies in the diagnostic API methods.
- Remove low-value comments about functionality that is obvious.

- Add missing `track_caller` attributes -- every method should have one.

- Adjust `rustc_lint_diagnostic` attributes. Every method involving a
  `impl Into<DiagnosticMessage>` or `impl Into<SubdiangnosticMessage>`
  argument should have one, except for those producing bugs, which
  aren't user-facing.
  • Loading branch information
nnethercote committed Feb 8, 2024
commit d1920a70c03bb6af2ab3f6dfcc21bfdc1fb3d3e9
53 changes: 21 additions & 32 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,20 +930,19 @@ impl DiagCtxt {
// Functions beginning with `struct_`/`create_` create a diagnostic. Other
// functions create and emit a diagnostic all in one go.
impl DiagCtxt {
/// Construct a builder at the `Bug` level with the `msg`.
#[rustc_lint_diagnostics]
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn struct_bug(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, BugAbort> {
DiagnosticBuilder::new(self, Bug, msg)
}

#[rustc_lint_diagnostics]
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn bug(&self, msg: impl Into<DiagnosticMessage>) -> ! {
self.struct_bug(msg).emit()
}

/// Construct a builder at the `Bug` level at the given `span` with the `msg`.
#[rustc_lint_diagnostics]
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn struct_span_bug(
&self,
Expand All @@ -953,6 +952,8 @@ impl DiagCtxt {
self.struct_bug(msg).with_span(span)
}

// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
self.struct_span_bug(span, msg).emit()
}
Expand All @@ -966,11 +967,10 @@ impl DiagCtxt {
}

#[track_caller]
pub fn emit_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, diagnostic_builder::BugAbort>) -> ! {
pub fn emit_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> ! {
self.create_bug(bug).emit()
}

/// Construct a builder at the `Fatal` level with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_fatal(
Expand All @@ -981,11 +981,11 @@ impl DiagCtxt {
}

#[rustc_lint_diagnostics]
#[track_caller]
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
self.struct_fatal(msg).emit()
}

/// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_fatal(
Expand Down Expand Up @@ -1031,7 +1031,6 @@ impl DiagCtxt {
self.create_almost_fatal(fatal).emit()
}

/// Construct a builder at the `Error` level with the `msg`.
// FIXME: This method should be removed (every error should have an associated error code).
#[rustc_lint_diagnostics]
#[track_caller]
Expand All @@ -1040,11 +1039,11 @@ impl DiagCtxt {
}

#[rustc_lint_diagnostics]
#[track_caller]
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
self.struct_err(msg).emit()
}

/// Construct a builder at the `Error` level at the given `span` and with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_err(
Expand Down Expand Up @@ -1075,24 +1074,18 @@ impl DiagCtxt {
self.create_err(err).emit()
}

/// Ensures that compilation cannot succeed.
///
/// If this function has been called but no errors have been emitted and
/// compilation succeeds, it will cause an internal compiler error (ICE).
///
/// This can be used in code paths that should never run on successful compilations.
/// For example, it can be used to create an [`ErrorGuaranteed`]
/// (but you should prefer threading through the [`ErrorGuaranteed`] from an error emission
/// directly).
/// Ensures that an error is printed. See `Level::DelayedBug`.
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn delayed_bug(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed {
DiagnosticBuilder::<ErrorGuaranteed>::new(self, DelayedBug, msg).emit()
}

/// Like `delayed_bug`, but takes an additional span.
/// Ensures that an error is printed. See `Level::DelayedBug`.
///
/// Note: this function used to be called `delay_span_bug`. It was renamed
/// to match similar functions like `span_err`, `span_warn`, etc.
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn span_delayed_bug(
&self,
Expand All @@ -1103,27 +1096,24 @@ impl DiagCtxt {
}

/// Ensures that a diagnostic is printed. See `Level::GoodPathDelayedBug`.
// No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing.
#[track_caller]
pub fn good_path_delayed_bug(&self, msg: impl Into<DiagnosticMessage>) {
DiagnosticBuilder::<()>::new(self, GoodPathDelayedBug, msg).emit()
}

/// Construct a builder at the `Warning` level with the `msg`.
///
/// An `emit` call on the builder will only emit if `can_emit_warnings` is `true`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Warning, msg)
}

#[rustc_lint_diagnostics]
#[track_caller]
pub fn warn(&self, msg: impl Into<DiagnosticMessage>) {
self.struct_warn(msg).emit()
}

/// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
///
/// An `emit` call on the builder will only emit if `can_emit_warnings` is `true`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_warn(
Expand Down Expand Up @@ -1153,20 +1143,20 @@ impl DiagCtxt {
self.create_warn(warning).emit()
}

/// Construct a builder at the `Note` level with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_note(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Note, msg)
}

#[rustc_lint_diagnostics]
#[track_caller]
pub fn note(&self, msg: impl Into<DiagnosticMessage>) {
self.struct_note(msg).emit()
}

#[track_caller]
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_note(
&self,
span: impl Into<MultiSpan>,
Expand All @@ -1175,8 +1165,8 @@ impl DiagCtxt {
DiagnosticBuilder::new(self, Note, msg).with_span(span)
}

#[track_caller]
#[rustc_lint_diagnostics]
#[track_caller]
pub fn span_note(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) {
self.struct_span_note(span, msg).emit()
}
Expand All @@ -1194,20 +1184,18 @@ impl DiagCtxt {
self.create_note(note).emit()
}

/// Construct a builder at the `Help` level with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_help(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Help, msg)
}

/// Construct a builder at the `Allow` level with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
DiagnosticBuilder::new(self, Allow, msg)
}

/// Construct a builder at the `Expect` level with the `msg`.
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_expect(
Expand Down Expand Up @@ -1576,6 +1564,7 @@ pub enum Level {
ForceWarning(Option<LintExpectationId>),

/// A warning about the code being compiled. Does not prevent compilation from finishing.
/// Will be skipped if `can_emit_warnings` is false.
Warning,

/// A message giving additional context.
Expand Down
Loading