Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bf62d59
Give `TRACK_DIAGNOSTIC` a return value.
nnethercote Feb 9, 2024
ecd3718
Inline and remove `Level::get_diagnostic_id`.
nnethercote Feb 13, 2024
272e60b
Move `DelayedBug` handling into the `match`.
nnethercote Feb 13, 2024
c81767e
Reorder `has_future_breakage` handling.
nnethercote Feb 13, 2024
aec4bdb
Move `Expect`/`ForceWarning` handling into the `match`.
nnethercote Feb 13, 2024
a7d9262
Add comments about `TRACK_DIAGNOSTIC` use.
nnethercote Feb 13, 2024
7ef605b
Make the `match` in `emit_diagnostic` complete.
nnethercote Mar 1, 2024
2d48a3a
Move generic `NonZero` `rustc_layout_scalar_valid_range_start` attrib…
reitermarkus Mar 2, 2024
85dfb47
Fix lint.
reitermarkus Mar 2, 2024
b5c11d1
Fix `miri` tests.
reitermarkus Mar 2, 2024
0b3a8a0
Hide implementation details for `NonZero` auto traits.
reitermarkus Mar 2, 2024
31fef34
Fix lint.
reitermarkus Mar 6, 2024
52fc093
Try fixing `debuginfo` test.
reitermarkus Mar 9, 2024
17924a0
Fix `StdNonZeroNumberSummaryProvider`.
reitermarkus Mar 10, 2024
5aeae7f
Deduplicate `lldb_commands`.
reitermarkus Mar 10, 2024
ec75906
Remove LLDB persistent results in `compiletest`.
reitermarkus Mar 10, 2024
e02cc56
Add comment about `NonZero` printing as character literal.
reitermarkus Mar 10, 2024
781ce7c
Fix `StdNonZeroNumberProvider` for `gdb`.
reitermarkus Mar 10, 2024
15b71f4
Add CStr::bytes iterator
clarfonthey Nov 13, 2022
c076509
Add methods to create constants
celinval Mar 1, 2024
893a910
Add a test to SMIR body transformation
celinval Mar 12, 2024
a38a556
Reduce unsafe code, use more NonNull APIs per @cuviper review
clarfonthey Mar 12, 2024
f2fcfe8
Various style improvements to `rustc_lint::levels`
Zalathar Mar 13, 2024
bf71825
CFI: Break tests into smaller files
rcvalle Mar 12, 2024
90acda1
Fix accidental re-addition of removed code in a previous PR
oli-obk Mar 13, 2024
f10ebfe
Generalize `eval_in_interpreter` with a helper trait
oli-obk Mar 11, 2024
44b1f8a
Move only usage of `take_static_root_alloc` to its definition and inl…
oli-obk Mar 11, 2024
31fa142
Move error handling into const_validate_mplace
oli-obk Mar 11, 2024
71ef9e2
Move InterpCx into eval_in_interpreter
oli-obk Mar 11, 2024
bd7580b
Move generate_stacktrace_from_stack away from InterpCx to avoid havin…
oli-obk Mar 11, 2024
7aee665
Directly pass in the stack instead of computing it from a machine
oli-obk Mar 11, 2024
ffaf082
Remove an argument that can be computed cheaply
oli-obk Mar 12, 2024
66a46bb
Share the `InterpCx` creation between static and const evaluation
oli-obk Mar 12, 2024
af59eec
Move validation into eval_body_using_ecx
oli-obk Mar 12, 2024
2a1a6fa
Move the entire success path into `eval_body_using_ecx`
oli-obk Mar 12, 2024
3393227
Rename some things around validation error reporting to signal that i…
oli-obk Mar 13, 2024
b6312eb
Create some minimal HIR for associated opaque types
petrochenkov Feb 11, 2024
12cd322
Make incremental sessions identity no longer depend on the crate name…
Zoxc Feb 28, 2024
514b274
const-eval: organize and extend tests for required-consts
RalfJung Mar 13, 2024
9403eb4
Rollup merge of #104353 - clarfonthey:cstr-bytes-iter, r=cuviper
matthiaskrgr Mar 13, 2024
5bf23d9
Rollup merge of #120699 - nnethercote:rm-useless-TRACK_DIAGNOSTIC-cal…
matthiaskrgr Mar 13, 2024
de9163a
Rollup merge of #120943 - petrochenkov:somehir3, r=oli-obk
matthiaskrgr Mar 13, 2024
6948dc6
Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk
matthiaskrgr Mar 13, 2024
c996d95
Rollup merge of #121885 - reitermarkus:generic-nonzero-inner, r=oli-o…
matthiaskrgr Mar 13, 2024
2a8600e
Rollup merge of #122375 - rcvalle:rust-cfi-break-tests-into-smaller-f…
matthiaskrgr Mar 13, 2024
2d61416
Rollup merge of #122397 - oli-obk:machine-read-hook2, r=RalfJung
matthiaskrgr Mar 13, 2024
e4f4e9a
Rollup merge of #122405 - celinval:smir-new-const, r=oli-obk
matthiaskrgr Mar 13, 2024
7325c2f
Rollup merge of #122416 - Zalathar:levels, r=petrochenkov
matthiaskrgr Mar 13, 2024
e8c661e
Rollup merge of #122440 - RalfJung:required-consts, r=oli-obk
matthiaskrgr Mar 13, 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
Make the match in emit_diagnostic complete.
This match is complex enough that it's a good idea to enumerate every
variant.

This also means `can_be_top_or_sub` can just be `can_be_subdiag`.
  • Loading branch information
nnethercote committed Mar 1, 2024
commit 7ef605be3fa24f93194a3faf4f75d3a05ceca78a
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ impl HumanEmitter {
}
if !self.short_message {
for child in children {
assert!(child.level.can_be_top_or_sub().1);
assert!(child.level.can_be_subdiag());
let span = &child.span;
if let Err(err) = self.emit_messages_default_inner(
span,
Expand Down
41 changes: 23 additions & 18 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,6 @@ impl DiagCtxtInner {

// Return value is only `Some` if the level is `Error` or `DelayedBug`.
fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
assert!(diagnostic.level.can_be_top_or_sub().0);

if diagnostic.has_future_breakage() {
// Future breakages aren't emitted if they're Level::Allow,
// but they still need to be constructed and stashed below,
Expand All @@ -1368,9 +1366,12 @@ impl DiagCtxtInner {
// return early *and* have some kind of side-effect, except where
// noted.
match diagnostic.level {
Fatal | Error if self.treat_next_err_as_bug() => {
// `Fatal` and `Error` can be promoted to `Bug`.
diagnostic.level = Bug;
Bug => {}
Fatal | Error => {
if self.treat_next_err_as_bug() {
// `Fatal` and `Error` can be promoted to `Bug`.
diagnostic.level = Bug;
}
}
DelayedBug => {
// Note that because we check these conditions first,
Expand Down Expand Up @@ -1405,14 +1406,21 @@ impl DiagCtxtInner {
};
}
}
Warning if !self.flags.can_emit_warnings => {
if diagnostic.has_future_breakage() {
// The side-effect is at the top of this method.
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
ForceWarning(None) => {} // `ForceWarning(Some(...))` is below, with `Expect`
Warning => {
if !self.flags.can_emit_warnings {
// We are not emitting warnings.
if diagnostic.has_future_breakage() {
// The side-effect is at the top of this method.
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
}
return None;
}
return None;
}
Note | Help | FailureNote => {}
OnceNote | OnceHelp => panic!("bad level: {:?}", diagnostic.level),
Allow => {
// Nothing emitted for allowed lints.
if diagnostic.has_future_breakage() {
// The side-effect is at the top of this method.
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
Expand All @@ -1434,12 +1442,12 @@ impl DiagCtxtInner {
}
self.fulfilled_expectations.insert(expect_id.normalize());
if let Expect(_) = diagnostic.level {
// Nothing emitted here for expected lints.
TRACK_DIAGNOSTIC(diagnostic, &mut |_| None);
self.suppressed_expected_diag = true;
return None;
}
}
_ => {}
}

TRACK_DIAGNOSTIC(diagnostic, &mut |mut diagnostic| {
Expand Down Expand Up @@ -1816,16 +1824,13 @@ impl Level {
matches!(*self, FailureNote)
}

// Can this level be used in a top-level diagnostic message and/or a
// subdiagnostic message?
fn can_be_top_or_sub(&self) -> (bool, bool) {
// Can this level be used in a subdiagnostic message?
fn can_be_subdiag(&self) -> bool {
match self {
Bug | DelayedBug | Fatal | Error | ForceWarning(_) | FailureNote | Allow
| Expect(_) => (true, false),

Warning | Note | Help => (true, true),
| Expect(_) => false,

OnceNote | OnceHelp => (false, true),
Warning | Note | Help | OnceNote | OnceHelp => true,
}
}
}
Expand Down