Auto merge of #98758 - nnethercote:more-derive-output-improvements, r=Mark-Simulacrum

More derive output improvements

This PR includes:
- Some test improvements.
- Some cosmetic changes to derive output that make the code look more like what a human would write.
- Some more fundamental improvements to `cmp` and `partial_cmp` generation.

r? `@Mark-Simulacrum`
This commit is contained in:
bors 2022-07-08 12:44:14 +00:00
commit fbdb07f4e7
15 changed files with 655 additions and 568 deletions

View file

@ -2036,6 +2036,14 @@ impl TyKind {
pub fn is_unit(&self) -> bool {
matches!(self, TyKind::Tup(tys) if tys.is_empty())
}
pub fn is_simple_path(&self) -> Option<Symbol> {
if let TyKind::Path(None, Path { segments, .. }) = &self && segments.len() == 1 {
Some(segments[0].ident.name)
} else {
None
}
}
}
/// Syntax used to declare a trait object.