1
Fork 0

Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostics, r=jieyouxu

Use `bool` in favor of `Option<()>` for diagnostics

We originally only supported `Option<()>` for optional notes/labels, but we now support `bool`. Let's use that, since it usually leads to more readable code.

I'm not removing the support from the derive macro, though I guess we could error on it... 🤔
This commit is contained in:
Matthias Krüger 2024-08-21 18:15:05 +02:00 committed by GitHub
commit 937a18daf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 106 additions and 121 deletions

View file

@ -160,7 +160,7 @@ pub struct TypeLengthLimit {
pub span: Span,
pub shrunk: String,
#[note(middle_written_to_path)]
pub was_written: Option<()>,
pub was_written: bool,
pub path: PathBuf,
pub type_length: usize,
}

View file

@ -581,9 +581,9 @@ impl<'tcx> Instance<'tcx> {
let mut path = PathBuf::new();
let was_written = if let Some(path2) = written_to_path {
path = path2;
Some(())
true
} else {
None
false
};
tcx.dcx().emit_fatal(error::TypeLengthLimit {
// We don't use `def_span(def_id)` so that diagnostics point